Help about finding cycles in infinite graph. #18
-
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Do you cite this?
As far as I can tell, It says, engine could process graphs with cycles, not find (all?) cycles in graph for you. |
Beta Was this translation helpful? Give feedback.
-
Dear nguyenhieuec, NoGraphs supports the following algorithms (see feature overview: DFS, BFS, topological search, Dijkstra, A* and MST. None of these algorithms can directly be used for finding all cycles in a graph. The topological search of NoGraphs finds a single reachable cycle in a directed graph (can be seen here ) and reports it. But the existence of a reachable cycle violates the precondition of the algorithm, is interpreted as an error, and thus, the algorithm stops after reporting the cycle. So, you get one cycle, but not all the others. This discussion might help you. Here, the difference between simple cycles, a cycle base and all cycles is explained. This could be helpful for defining your exact goal. And some algorithms are sketched or linked, one is even based on DFS. (From the argument add_inverted=True in your code I guess that you like to find cycles in an undirected graph). Here you can find information for the case of directed graphs. One of the comments says that simple_cycles of NetworkX implements the Johnson algorithm. And this algorithm is highly recommended by many comments. For small graphs, there is also an easy and short, but slow algorithm given. And there is an explanation, why DFS cannot be easily extended for finding all cycles. I hope that helps you with your problem. Regards |
Beta Was this translation helpful? Give feedback.
-
Thanks for the helpful comment. I will try to implement the Johnson algorithm. |
Beta Was this translation helpful? Give feedback.
Dear nguyenhieuec,
NoGraphs supports the following algorithms (see feature overview: DFS, BFS, topological search, Dijkstra, A* and MST. None of these algorithms can directly be used for finding all cycles in a graph.
The topological search of NoGraphs finds a single reachable cycle in a directed graph (can be seen here ) and reports it. But the existence of a reachable cycle violates the precondition of the algorithm, is interpreted as an error, and thus, the algorithm stops after reporting the cycle. So, you get one cycle, but not all the others.
This discussion might help you. Here, the difference between simple cycles, a cycle base and all cycles is explained. This could be helpful fo…