
I wonder if someone knows an easy way to detect cycles in a graph. Any suggestion welcome ;) NC

You could tag each vertex or edge with a "visited" flag. Set "visited" to false initially. Then use a traversal algorithm to traverse the graph, starting at any vertex or edge. When each vertex or edge gets visited, check the state of the "visited" flag. If true, then stop because there is a cycle, because there is more than one route to that vertex or edge. If it's false, set it to true, and move on to the next vertex or edge. Regards, Markus. Chartier Nicolas wrote:
I wonder if someone knows an easy way to detect cycles in a graph. Any suggestion welcome ;)
NC
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Yep, Depth First Search: http://www.boost.org/doc/libs/1_35_0/libs/graph/doc/file_dependency_example.... :cycles Cheers, James. On 16 Apr 2008, at 21:53, Chartier Nicolas wrote:
I wonder if someone knows an easy way to detect cycles in a graph. Any suggestion welcome ;)
NC
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

In most cases if you ask how to find cycles you really mean 'how to find strongly connected components' : http://en.wikipedia.org/wiki/Strongly_connected_component think it over... Cheers, Michał Nowotka
participants (4)
-
Chartier Nicolas
-
James Jackson
-
Markus Svilans
-
Michał Nowotka