Kruskal’s Algorithm
Two classic greedy algorithms for finding a subset of edges that connects all vertices in a weighted undirected graph with minimum total edge weight and no cycles.
Method
Kruskal: sort edges by weight; add if they connect different components (Union-Find). Prim: grow a tree from a start vertex by always adding the cheapest edge connecting the tree to a new vertex (priority queue). Both produce MSTs.
Applications
Network design (telecom, roads), hierarchical clustering, approximation algorithms for TSP, image segmentation, circuit design.
Advantages
Optimal; efficient; simple; Kruskal works well on sparse graphs, Prim on dense; foundational for many approximation schemes.
Limitations
Defined for undirected graphs; does not directly solve directed or constrained spanning problems; Kruskal needs efficient Union-Find for large graphs. Accept edges in nondecreasing weight order only when they join separate components. A disconnected input produces a minimum spanning forest; negative and tied weights are allowed.
Alternatives
Borvka's algorithm, reverse-delete, Steiner tree algorithms for terminal subsets, matroid optimization.
Example
Connecting 4 cities with cheapest roads: pick edges 1,2,3 that do not cycle.
Editorial clarification
Accept edges in nondecreasing weight order only when they join separate components. A disconnected input produces a minimum spanning forest; negative and tied weights are allowed.
Sources
Educational reference only, not professional advice.
All algorithms