Two stacks
S: all visited vertices in DFS. P: 'possibly open' SCCs — vertices that might still merge with others.
Advertisement
Back edges
Back edge to earlier vertex u: pop from P until top is u or below. Handles merging.
Advertisement
SCC completion
When DFS finishes at vertex u and u is top of P, pop from S until reaching u — that's the SCC.
Complexity
O(V+E). Same as Tarjan.