Algorithm. Kruskal's Algorithm (with union-find) [00P3]

Given a union-find data structure, we can implement Kruskal's Algorithm as follows:

\mathsf {Kruskal}(G):
T \gets empty set of edges
U \gets \mathsf {MakeSets}(V)
Sort the edges from smallest to biggest weight
\mathsf {for} each edge e = (u,v):
\mathsf {if} U.\mathsf {Find}(u) \neq U.\mathsf {Find}(v):
Add e to T
U.\mathsf {Union}(u,v)