RK DSA Studio

Directed cycle

Detect a cycle when an edge reaches a vertex still on the active DFS path.

Remember: An edge back to an active call closes a cycle.

Example: A → B → C → A forms a directed cycle.

Time: O(V + E). Auxiliary space: O(V).

Formula: Directed: edge to visiting node. Undirected: ignore the parent edge.

Up to 8 unique integer vertex labels and 16 edges. Edges: from,to; separate edges with semicolons. Directed graph. Check all components. Graph storage O(V + E) is excluded from auxiliary space.

Complexities describe the underlying algorithm; tutorial snapshots and rendering can use additional resources.

The interactive workspace loads here when JavaScript is available. You can still browse the learning notes and links above without it.