...
/Solution: Find the Minimum Spanning Tree - Kruskal’s Solution
Solution: Find the Minimum Spanning Tree - Kruskal’s Solution
In this review, we give a detailed analysis on finding the minimum spanning tree of the given graph using Kruskal's solution.
We'll cover the following...
We'll cover the following...
Solution: Kruskal’s Algorithm
Kruskal’s algorithm is a minimum-spanning-tree algorithm that finds an edge of the least possible weight.
It is a greedy algorithm, as it finds a minimum spanning tree for a connected weighted graph—adding increasing cost arcs at each step.
Pseudocode
KruskalMST(G):
A = ∅
for each v ∈ G.V:
MAKE-SET(v)
for each (u, v) in G.E ordered by weight(u, v), increasing:
if FIND-SET(u) ≠ FIND-SET(v):
A = A ∪ {(u, v)}
UNION(u, v)
return A
Animation
The animation below gives a demo of how Kruskal’s algorithm is applied to a graph to find its minimum spanning tree.