← visual-cs

Tarjan's SCC Algorithm

Mode: Add Node
Speed
Add Node mode: click to place nodes  |  Add Edge mode: click node → click another  |  Drag nodes to rearrange

Algorithm Stack

Discovered SCCs

Node State

NodedisclowonStack

How It Works

Tarjan's algorithm finds all Strongly Connected Components in a directed graph in O(V + E) time.

It uses a single DFS traversal with a stack to track the current path. Each node gets a disc (discovery time) and low (lowest reachable disc via DFS subtree).

When disc[v] == low[v], node v is the root of an SCC — pop the stack until you reach v.

Legend

Unvisited node
Currently processing (on stack)
Current DFS node
SCC complete
Tree / forward edge
Back edge (cycle!)