Kosaraju
Finish order from one DFS, reverse every edge, then DFS from the latest finisher to paint each component.
Decision · step 17 of 27Bridges and Components: Kosaraju on the same graph
Pass 2: the unassigned vertex with the latest finish time is 0, finish 7. Start a DFS there on the reversed graph; it opens component 0.
What you will see
Pass 1 stamps finish times; edges flip; pass 2 floods components in order.
Cost
| Best | O(V + E) |
|---|---|
| Average | O(V + E) |
| Worst | O(V + E) |
| Space | O(V) |
How you work with it here
play it through, step one change at a time, scrub to any step, run it on your own input, predict what happens next.
Screen readers: Vertices announce name, discovery numbers where relevant and component; each step announces the structural conclusion (bridge found, component closed).
Reduced motion: Component colouring and ordering changes crossfade in place.
Before this
Related
Taught by the same lesson
Bridges and Components covers these too, in the same run.