Learn
Practice
Newsletter
Resources
F
Toggle theme
0
F
Toggle theme
0
Toggle menu
← Back to All Animations
Number of Connected Components
Bookmark
Input
2 Components
1 Component
3 Components
Merge 2 into 1
No Edges
Custom
n
=
5
,
edges
=
[[0,1],[1,2],[3,4]]
Input Graph
0
1
2
3
4
Union-Find Structure
0
root
1
root
2
root
3
root
4
root
Components: 5
Legend:
Standard
Processing
Active
Root
algo
master
.
io
Step:
Initialize Union-Find for 5 nodes (0 to 4). Each node starts as its own component. Components = 5
0 / 16
Input
2 Components
1 Component
3 Components
Merge 2 into 1
No Edges
Custom
n
=
5
,
edges
=
[[0,1],[1,2],[3,4]]
0 / 16
Input Graph
0
1
2
3
4
Union-Find Structure
0
root
1
root
2
root
3
root
4
root
Components: 5
Legend:
Standard
Processing
Active
Root
algo
master
.
io
Step:
Initialize Union-Find for 5 nodes (0 to 4). Each node starts as its own component. Components = 5