Reputation: 1101
I came across this interesting problem of counting number of cycles in a digraph.
For detecting a cycle in graph we can use DFS, but in order to detect number of cycles, DFS wont be of much use, as some edges will be common in some cycles.
I am trying to figure out if spanning tree might be of any help here.
Any thoughts?
Upvotes: 2
Views: 947
Reputation: 3287
Here is an algorithm to derive a structure to help solve the cycle count problem:
The remaining graph has only nodes with both indegree and outdegree greater than or equal to 2. It contains references to nodes of the original graph.
Upvotes: 4