Loading algorithms…
Loading visualizer…
Detect cycles in a directed graph with three-color DFS: white unvisited, gray on the recursion stack, black fully explored. A back edge to a gray node means cycle.
Color every vertex white (6 vertices). The search moves each node white → gray (on the stack) → black (finished).
Click a node to choose where the search starts · Toggle DAG / cyclic to compare outcomes
Detect cycles in a directed graph with three-color DFS: white unvisited, gray on the recursion stack, black fully explored. A back edge to a gray node means cycle.