Detecting cycles in a graph using DFS: 2 different approaches and what’s the difference
Answering my question: The graph has a cycle if and only if there exists a back edge. A back edge is an edge that is from a node to itself (selfloop) or one of its ancestor in the tree produced by DFS forming a cycle. Both approaches above actually mean the same. However, this method … Read more