Learn
Practice
Newsletter
Resources
F
Toggle theme
0
F
Toggle theme
0
Toggle menu
← Back to All Animations
Find Eventual Safe States
Bookmark
DFS
BFS (Kahn's)
Input
Cycle
All Safe
Custom
graph
=
[[1,2],[2,3],[4],[0],[]]
0
1
2
3
4
Call Stack
State: (U=Unvisited, V=Visiting, D=Done)
U
0
U
1
U
2
U
3
U
4
Topological Order:
Legend:
Unvisited
Processing
Visiting
Visited
Cycle
algo
master
.
io
Step:
Initialize state array (U=unvisited, V=visiting, S=safe, X=unsafe)
0 / 27
Input
Cycle
All Safe
Custom
graph
=
[[1,2],[2,3],[4],[0],[]]
0 / 27
0
1
2
3
4
Call Stack
State: (U=Unvisited, V=Visiting, D=Done)
U
0
U
1
U
2
U
3
U
4
Topological Order:
Legend:
Unvisited
Processing
Visiting
Visited
Cycle
algo
master
.
io
Step:
Initialize state array (U=unvisited, V=visiting, S=safe, X=unsafe)