Questions tagged [cyclic-graph]
55 questions
1
vote
1 answer
How to convert a directed graph to its most minimal form?
I'm dealing with rooted, directed, potentially cyclic graphs. Each vertex in the graph has a label, which might or might not be unique. Edges do not have labels. The graph has a designated root vertex from which every vertex is reachable. The order…

Joshua Wise
- 613
- 4
- 15
1
vote
1 answer
Converting cyclic graph to acyclic in a weighted graph
I am given a connected, weighted graph, with non-negative weights. I want to convert it to a connected, acyclic graph such that sum of weights of the removed edges is minimised. The output would be the removed edges.
My thoughts: Since a connected,…

Ankit Kumar
- 1,145
- 9
- 30
1
vote
0 answers
How to calculate changing vertex weights in directed graphwith cyclic dependencies?
I am making a small game in Java to practice programming and came across this little issue that I can't seem to solve on my own.
In this game, I want to build a virtual shop where I can buy and sell items.
Most items can only be obtained in the game…

neph
- 55
- 7
1
vote
1 answer
Is there a way to build a structure with cyclic links without runtime overhead?
I am trying to implement a cyclic linked data structure in Rust. My Nodes are defined as:
#[derive(Debug)]
enum Node<'a> {
Link(&'a Node<'a>),
Leaf,
}
I am trying to build a minimal structure like this (extra brackets for better lifetime…

Felk
- 7,720
- 2
- 35
- 65
1
vote
0 answers
Can we convert a adjacency list model of a cyclic graph into nested set model in RDBMS?
If a cyclic graph is stored in adjacency list model, then we query using CTEs which is very slow. But if there is a way to convert adjacency list model of cyclic graph into nested set model, then I guess the queries might run a little faster. I know…

Sai Ram
- 101
- 1
- 3
1
vote
1 answer
How can you find the diameter of a cyclic graph using BFS?
For cyclic graphs with a number of vertices larger than 5, running BFS in each node and picking a maximum out of those lengths stops working.
For example:
Number each vertex from 1 to 6 in a cyclic manner.
Now, using BFS: -from node 1:
takes node…

Jean-Alexandru Stn
- 11
- 3
0
votes
0 answers
Finding longest path in a Directed Cyclic Graph
I have a Directed Cyclic Graph and need to find longest path from point A to point B. The graph is a 2D array. I already wrote code that can find longest path in Acyclic Graph, but when I change the graph to the Cyclic one it doesn't work. Here's…

dawidsk12345
- 67
- 1
- 8
0
votes
0 answers
Testing whether a path in a directed graph does not cause cycles
This is a different question from what I have found so far related to cycles in graph as they relate to finding cycles in general but I need to find a cycle in a specific situation.
Consider the following graph:
n1: [n2]
n2: [n3]
n3: [n4]
n4: [n5,…

Pawel Uchida-Psztyc
- 3,735
- 2
- 20
- 41
0
votes
0 answers
Finding a cycle path in directed graph
I am making a directed Graph class. I want find if there is any Cycle and update a vector with it's path accordingly. My Function some times work but others add two times the last edge of the path.So i guess it needs to be tydied up.
Example: having…
0
votes
2 answers
logic for method to detect cycle in an undirected graph
I was trying to detect a cycle in a directed graph.
While coming up with the logic to solve it, I figured out that a simple graph traversal eq. dfs is sufficient because while doing dfs we can just have a condition to see if any node is already…

user21692
- 21
- 6
0
votes
1 answer
Write a predicate that works for cyclic graph to check if there exists a path between two nodes using prolog
I am trying to wrote a predicate isway(A, B) which should work for cyclic graphs. The expected outcome I am trying to get is, if there a path exists between 2 nodes or not. example: if I ask isway(a, f), expect it to answer either yes or no. below…

mkpisk
- 152
- 1
- 9
0
votes
1 answer
Modification of code for printing cycles in the graph
#include
using namespace std;
void addEdge(vector >&adj,int u,int v)
{
adj[u].push_back(v);
}
bool DFS(vector >adj,int x,vector&visited,vector&recStack,stack&s)
{
…

Nithish
- 139
- 5
0
votes
0 answers
find length of simple path in graph (cyclic) having maximum value sum ,with the given constraints
Given : unweighted undirected graph(cyclic) G(V,E), each vertex has two values (say A and B) which are given and no two adjacent vertices are of same A value.
Find the simple path having maximum sum of B values of vertices, with the following…

tatya bichu
- 1
- 3
0
votes
1 answer
how exactly an atom/1 predicate works in prolog?
I have been trying to solve a pathfinding problem in Prolog.where the predicates are
edge(a,b).
edge(a,c).
edge(b,d).
edge(c,d).
edge(d,e).
edge(d,f).
edge(f,g).
the rules is
edge(X,Y) :- edge(X,Z), edge(Z,Y).
then when I compiled and run the…

læran91
- 283
- 1
- 15
0
votes
2 answers
Will Dijkstra ever a path with cycle?
Note: There is no negative cost.
I am considering to implement U-turn in routing, which uses Dijkstra.
Will Dijkstra ever recommend route A-B-C-B-D over A-B-D? When encountering B for the first time, B is marked as visited after visiting its…

na9090
- 125
- 2
- 13