Basic cycles in a un-directed gaph



I have a situation that can be reduced to finding basic cycles in an undirected graph of length 4(the cycles require to be length 4)

I don’t have much previous experience with graphs, but this seems a simple operation
for someone proficient in this field.

Is there an existing julia package with this functionality?


Not an expert, but it’s probably with LightGraphs.jl :thumbsup:


We have basic cyclicity tests in LightGraphs. If you get stuck or can’t find what you need in the docs, feel free to open up an issue there and we can try to help further.


If you are looking for a basis of fundamental cycles, then you should start with a spanning tree (as a subgraph). All other edges (u,v) define a cycle by joining them with the unique path from u to v in the spanning tree.

If you just want to find any cycle or show that none exist, you could look at this function that I use myself. It is based on a user type, but immediatly converts it to a LightGraphs type, so you should be fine.