Kruskal's Algorithm

1/0
1.0x

Kruskal's Algorithm

O(E log E)Space: O(V + E)

Pseudocode

1procedure Kruskal(graph)
2 sort all edges by weight
3 initialize union-find for each vertex
4 MST ← empty set
5 for each edge (u, v, w) in sorted order
6 if find(u) ≠ find(v) then
7 add edge (u, v) to MST
8 union(u, v)
9 else skip edge (would form cycle)
10 return MST