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.
This question is part of this quiz :
Quiz On Graph Data Structure