Kruskal's Algorithm is another way to find a Minimum Spanning Tree (MST) in a graph. It works by iteratively adding the cheapest available edge that connects two previously disconnected components, without forming a cycle. It is efficient for sparse graphs and uses a Union-Find data structure to detect cycles.
sort edges by weight (ascending)
MST = empty set
for each vertex v:
create a disjoint set {v}for each edge (u, v):
if find(u) ≠ find(v):
add (u, v) to MST
union(u, v)
Hand-picked resources to deepen your understanding
© 2025 See Algorithms. Code licensed under MIT, content under CC BY-NC 4.0.