Iterative implementation of Kosaraju's algorithm (works on relatively big graphs):
- DFS on reversed graph (for magic order of nodes, so that the SCCs have some key property)
- DFS on original graph in decreasing order (where the order is obtain from 1st pass)
The algorithm outputs the SCCs of the original graph.