Find all cycles in graph, redux -


I know that there are a few very few replies on this question. However, none of them really got me to bring it.
Some argue that a cycle (almost) is similar to a strongly connected component (S), so one could use the algorithm designed for that goal.
Some people argue that the A cycle can be done through DFS and can check back-edges (such as boost graph documentation on file dependency).
Let me now suggest some suggestions: Can the all cycle in a graph be searched through DFS and can check for back-side? Based on the cycle, a method is based on
(here but found on SO). Personally, I am not getting it very comfortable so I am looking for a different solution.

Edit: My initial opinion was apparently wrong in the next answer by "Moron".
Initial Opinion: My idea is that it can actually do such things as DFS-visit (cddodo of SDS) has entered every node that has not yet arrived. In that sense, each top represents a possible beginning of a cycle, in addition, as DFS visits each side once, each edge leading to the starting point of a circle is also covered. Thus, it is possible to find the all cycles in the graph by checking DFS and back-edge. Note, if there are cycles of different participating nodes (such as triangles, rectangles, etc.), then extra work has to be done to distinguish the intense "size" of each cycle.

I have responded well in advance, so check it out:

Relevant part of the answer:

Make a deep-first search on your graph.

You are interested in identifying the back edges, that is, in the traversal, an edge which is an ancestor (formerly the DFS tree of the visit node, which is inspired by the edges of the nodes first coming). For example, if there are nodes in the DFS stack [A-> B-> C-> D] and when you detect D, you get the edge D-> B, which is back edge. Each back edge defines a circle.

More importantly, the cycle inspired by back-side is a basic set of cycles of the graph. "A basic set of cycles": You can construct all the cycles of the graph by performing the uniouncing and chunks of the original set. For example, consider the cycles [A1-> A2-> A3-> A1] and [A2-> B1-> B2-> B3-> A2]. You can add them to the circle: [A1-> A2-> B1-> B2-> B3-> A2-> A3-> A1).


Comments