Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Kruskal's Minimum Spanning Tree
Bookmark
Input
5 Vertices
4 Vertices
6 Vertices
Square Graph
Custom
n
=
5
,
edges
=
[{u:0,v:1,w:2},{u:0,v:3,w:6},{u:1,v:2,w:3},{u:1,v:3,w:8},{u:1,v:4,w:5},{u:2,v:4,w:7},{u:3,v:4,w:9}]
Graph
2
6
3
8
5
7
9
0
1
2
3
4
Sorted Edges
(not yet sorted)
Union-Find
Legend:
Standard
Processing
Current
In MST
Cycle
Graph
2
6
3
8
5
7
9
0
1
2
3
4
Sorted Edges
(not yet sorted)
Union-Find
Legend:
Standard
Processing
Current
In MST
Cycle
Graph
2
3
5
6
7
8
9
0
1
2
3
4
Sorted Edges
Edge
Weight
(0-1)
2
(1-2)
3
(1-4)
5
(0-3)
6
(2-4)
7
(1-3)
8
(3-4)
9
Union-Find
0
root
1
root
2
root
3
root
4
root
MST Edges: 0/4 | Weight: 0
Legend:
Standard
Processing
Current
In MST
Cycle
Graph
2
3
5
6
7
8
9
0
1
2
3
4
Sorted Edges
Edge
Weight
(0-1)
2
(1-2)
3
(1-4)
5
(0-3)
6
(2-4)
7
(1-3)
8
(3-4)
9
Union-Find
0
root
1
root
2
root
3
root
4
root
MST Edges: 0/4 | Weight: 0
Legend:
Standard
Processing
Current
In MST
Cycle
Graph
2
3
5
6
7
8
9
0
1
2
3
4
Sorted Edges
Edge
Weight
(0-1)
2
✓
(1-2)
3
(1-4)
5
(0-3)
6
(2-4)
7
(1-3)
8
(3-4)
9
Union-Find
0
root
1
2
root
3
root
4
root
MST Edges: 1/4 | Weight: 2
Legend:
Standard
Processing
Current
In MST
Cycle
Graph
2
3
5
6
7
8
9
0
1
2
3
4
Sorted Edges
Edge
Weight
(0-1)
2
✓
(1-2)
3
(1-4)
5
(0-3)
6
(2-4)
7
(1-3)
8
(3-4)
9
Union-Find
0
root
1
2
root
3
root
4
root
MST Edges: 1/4 | Weight: 2
Legend:
Standard
Processing
Current
In MST
Cycle
Graph
2
3
5
6
7
8
9
0
1
2
3
4
Sorted Edges
Edge
Weight
(0-1)
2
✓
(1-2)
3
✓
(1-4)
5
(0-3)
6
(2-4)
7
(1-3)
8
(3-4)
9
Union-Find
0
root
1
2
3
root
4
root
MST Edges: 2/4 | Weight: 5
Legend:
Standard
Processing
Current
In MST
Cycle
Graph
2
3
5
6
7
8
9
0
1
2
3
4
Sorted Edges
Edge
Weight
(0-1)
2
✓
(1-2)
3
✓
(1-4)
5
✓
(0-3)
6
(2-4)
7
(1-3)
8
(3-4)
9
Union-Find
0
root
1
2
4
3
root
MST Edges: 3/4 | Weight: 10
Legend:
Standard
Processing
Current
In MST
Cycle
Graph
2
3
5
6
7
8
9
0
1
2
3
4
Sorted Edges
Edge
Weight
(0-1)
2
✓
(1-2)
3
✓
(1-4)
5
✓
(0-3)
6
(2-4)
7
(1-3)
8
(3-4)
9
Union-Find
0
root
1
2
4
3
root
MST Edges: 3/4 | Weight: 10
Legend:
Standard
Processing
Current
In MST
Cycle
Graph
2
3
5
6
7
8
9
0
1
2
3
4
Sorted Edges
Edge
Weight
(0-1)
2
✓
(1-2)
3
✓
(1-4)
5
✓
(0-3)
6
✓
(2-4)
7
(1-3)
8
(3-4)
9
Union-Find
0
root
1
2
3
4
MST Edges: 4/4 | Weight: 16
Legend:
Standard
Processing
Current
In MST
Cycle
Graph
2
3
5
6
7
8
9
0
1
2
3
4
Sorted Edges
Edge
Weight
(0-1)
2
✓
(1-2)
3
✓
(1-4)
5
✓
(0-3)
6
✓
(2-4)
7
(1-3)
8
(3-4)
9
Union-Find
0
root
1
2
3
4
MST Edges: 4/4 | Weight: 16
Legend:
Standard
Processing
Current
In MST
Cycle
algo
master
.
io
Step:
Given a graph with 5 vertices and 7 edges. Find the Minimum Spanning Tree using Kruskal's algorithm.
0 / 16
Input
5 Vertices
4 Vertices
6 Vertices
Square Graph
Custom
n
=
5
,
edges
=
[{u:0,v:1,w:2},{u:0,v:3,w:6},{u:1,v:2,w:3},{u:1,v:3,w:8},{u:1,v:4,w:5},{u:2,v:4,w:7},{u:3,v:4,w:9}]
0 / 16
algo
master
.
io
Step:
Given a graph with 5 vertices and 7 edges. Find the Minimum Spanning Tree using Kruskal's algorithm.