Feb 5, 2009

How to determine if there is a cycle in the graph

How to determine if there is a cycle in the graph
If the graph is undirected Bfs + hashtable (bitvector)
If the graph is directed, dfs the tree and each node has a visited value, where 0 is unvisited, 1 is visiting or 2 is finished, you can see clrs p458

No comments:

Post a Comment