Loading...
Greedy Minimum Spanning Tree via Disjoint Set Union.
Sort edges and merge components
Disjoint Set Union for cycles
Guarantees MST for connected graph
Kruskal's treats every node as an individual tree. It sorts all edges by weight and tries to add them one by one. An edge is added if and only if it connects two different trees (components), merging them into one. This process repeats until only one tree remains.