Find cycles in a direct graph (simplecycles error: function not defined)

Hi, I need to find cycles in a direct graph and return the vector of nodes of each cycle. I am using Graphs, LightGraphs, SimpleWeightedGraphs.

Example: For a direct graph with the arcs [(1 3), (2 4), (3 1), (4 5), (5, 2)], one solution should be a vector with two cycles [[1 3 1], [2 4 5 2]]

I look at the documentation, and it seems that the function “simplecycles()” would be a solution, but it is not running (ERROR: “UndefVarError: simplecycles not defined”), I dont know how to fix this error. Is there another function for similar application? Thanks

Hi, I use the full line “Graphs.simplecycles(g)” and the function “simplecycles” worked well! I think it work as expected to solve the problem. :upside_down_face:

Hi! You shouldn’t be using both of these at the same time, and don’t need to either. Graphs contains the newer versions of LightGraphs, so you can remove the LightGraphs dependency.

That should solve the issue too, and allow you to call simplecycles directly without needing to specify Graphs.simplecycles - the conflict between Graphs and LightGraphs is what is causing the original issue.

3 Likes

Thanks!