Why it matters
SCC is fundamental for directed graph analysis. Kosaraju is one classic approach.
Advertisement
The architecture
DFS on original: record finish order.
DFS on reverse graph in reverse finish order.
Each tree = one SCC.
Advertisement
How it works end to end
First DFS: post-order stack.
Reverse edges.
Second DFS: pop stack, each tree = SCC.
Alternative: Tarjan (one pass).