Graph | Question 6

Last Updated :
Discuss
Comments

How do we detect cycle in an udirected graph using DFS?

If current vertex has an adjacent that is already visited, then there is a cycle

If current vertex has an adjacent that is already visited and is not parent (in DFS Tree) of the current vertex, then there is a cycle.

We cannot use DFS to detect cycle

If we make a recursive call for the same vertex again, then there is a cycle.

Tags:
Share your thoughts in the comments