graph question : cycle detection - undirected graph
Can DFS be used to detect cycles in an undirected graph? Using the code in the example file_dependencies.cpp on an undirected graph - it detects cycles even though there is none. Do we have to do more than simply look for back edges for an undirected graph? or should I convert it to directed then use this function? Thanks, Matt -- Matthew Galati ISE Lehigh University IBM Service Parts Solutions 610.758.4042 (Office) 610.882.0779 (Home) magh@lehigh.edu, magal11@us.ibm.com http://sagan.ie.lehigh.edu/mgalati/
Hi Matthew,
Luckily, another user already had the same problem you did.
There is now a special version of DFS for undirected graphs:
http://www.boost.org/libs/graph/doc/undirected_dfs.html
Cheers,
Jeremy
--On Thursday, November 14, 2002 10:16 AM -0500 Matthew Galati
Can DFS be used to detect cycles in an undirected graph? Using the code in the example file_dependencies.cpp on an undirected graph - it detects cycles even though there is none. Do we have to do more than simply look for back edges for an undirected graph? or should I convert it to directed then use this function?
Thanks, Matt
participants (2)
-
Jeremy Siek
-
Matthew Galati