📐 Topological Sort — Kahn's Algorithm
USACO C++ Book · Interactive Visualizer
📐 Topological Sort — Kahn's Algorithm (BFS) Full Demo
Topological Sort
O(V+E)
Step 0/9
📊 Directed Acyclic Graph (DAG), node number = in-degree
🗂 Data Structures
Queue (nodes with in-degree 0)
Topological Order
In-degree inDeg[]
Time:
O(V+E)
Space:
O(V)
💻 Code
Hint
Click
Next Step ▶
to start and observe how Kahn's algorithm builds the topological order by processing nodes with in-degree 0.
◀ Prev
Next Step ▶
↺ Reset
0/9
Keyboard:
→
Next
←
Prev
R
Reset