Learn
Practice
Newsletter
Resources
F
Toggle theme
0
F
Toggle theme
0
Toggle menu
← Back to All Animations
Detect Cycle in Undirected Graph (Union-Find)
Bookmark
Input
Graph with Cycle
No Cycle (Path)
Diamond Shape
Disconnected
Square with Diagonal
Custom
n
=
5
,
edges
=
[[0,1],[1,2],[2,3],[3,4],[4,1]]
Input Graph
0
1
2
3
4
Union-Find Structure
Legend:
Standard
Processing
Active
Connected
Cycle
algo
master
.
io
Step:
Given an undirected graph with 5 vertices and 5 edges. Detect if the graph contains a cycle using Union-Find.
0 / 21
Input
Graph with Cycle
No Cycle (Path)
Diamond Shape
Disconnected
Square with Diagonal
Custom
n
=
5
,
edges
=
[[0,1],[1,2],[2,3],[3,4],[4,1]]
0 / 21
Input Graph
0
1
2
3
4
Union-Find Structure
Legend:
Standard
Processing
Active
Connected
Cycle
algo
master
.
io
Step:
Given an undirected graph with 5 vertices and 5 edges. Detect if the graph contains a cycle using Union-Find.