Overview
Cycle Detection uses traversal state to find edges that prove a loop exists in a directed or undirected graph.
Determines whether a graph contains a cycle.
Compact metadata for implementation and discovery.
Cycle Detection uses traversal state to find edges that prove a loop exists in a directed or undirected graph.
Quick facts
Runtime and memory behavior at a glance.
Best
O(V + E)
Average
O(V + E)
Worst
O(V + E)
Space
O(V)
Show a back edge closing a loop in the graph.
Cycle Detection operates in O(V + E) time and O(V) space within the Graph Analysis family. Often compared with Depth-First Search and Topological Sort.
What each reference supports for this entry.
Textbook support for Cycle Detection's standard algorithm design, invariants, and complexity analysis.
Open sourceAlgorithm catalog support for Cycle Detection's problem context, known alternatives, and practical selection tradeoffs.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
DFS visitation state is a standard way to detect cycles.
Cycle detection helps determine whether a directed graph is a DAG.