Cycledetection
Cycle detection is the problem of determining whether a graph contains a cycle, a closed path where the starting and ending vertices coincide and no edges or, depending on definition, vertices are repeated along the way. Cycle detection is distinguished by whether the input graph is directed or undirected, as the presence and meaning of cycles differ between the two.
In directed graphs, a common approach is depth-first search with color marking or a recursion stack. During
In undirected graphs, cycle presence can be detected with DFS while tracking the parent edge, because visiting
Applications of cycle detection include deadlock detection in operating systems, verification of circuit designs, dependency resolution