DFS Topological Sort
Reverse postorder of a DFS is a topological order, and a back edge means there is none.
Decision · step 2 of 14Topological Sort: DFS finish order
Enter 0. Its edges go to 1, 2. Unvisited: 1, 2. Go into 1 first.
What you will see
Vertices are pushed on a stack when they finish; popping the stack gives the 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
Topological Sort covers these too, in the same run.