Minimum Spanning Tree (MST) problem
Given an undirected, connected graph with edge-costs given by , find a spanning tree such that is minimised
Prim’s algorithm

Running time is where is number of vertices, edges respectively
- while loop runs time from to
- explored set , number of edges between explored and non-explored is
Correctness of Prim’s algorithm
Assumption : All edge costs are distinct
Theorem
For any , let be the edge of minimum cost having one end-point in and other end-point in . Then, every MST contains the edge
- Suppose there is a MST which does not contain this edge whose endpoints are and
- We will (carefully) find an edge in such that
- And replacing with gives a spanning tree of smaller cost. Contradiction
