Learn
Practice
Newsletter
Resources
F
Toggle theme
0
F
Toggle theme
0
Toggle menu
← Back to All Animations
Topological Sort
Bookmark
DFS
BFS (Kahn's)
Input
DAG 1
DAG 2
With cycle
Diamond
Custom
numNodes
=
6
,
edges
=
[[5,2],[5,0],[4,0],[4,1],[2,3],[3,1]]
0
1
2
3
4
5
Call Stack
State: (U=Unvisited, V=Visiting, D=Done)
U
0
U
1
U
2
U
3
U
4
U
5
Topological Order:
Legend:
Unvisited
Processing
Visiting
Visited
Cycle
algo
master
.
io
Step:
Initialize state array (U=unvisited, V=visiting, D=done)
0 / 42
Input
DAG 1
DAG 2
With cycle
Diamond
Custom
numNodes
=
6
,
edges
=
[[5,2],[5,0],[4,0],[4,1],[2,3],[3,1]]
0 / 42
0
1
2
3
4
5
Call Stack
State: (U=Unvisited, V=Visiting, D=Done)
U
0
U
1
U
2
U
3
U
4
U
5
Topological Order:
Legend:
Unvisited
Processing
Visiting
Visited
Cycle
algo
master
.
io
Step:
Initialize state array (U=unvisited, V=visiting, D=done)