Loading...
Grow a tree from any start vertex by repeatedly adding the lightest edge to a new vertex. Greedy is optimal by the cut property.
1procedure PRIM(G)2 choose any start vertex; T ← {start}3 while |T| < |V| do4 choose minimum weight edge (u, v) with exactly one endpoint in T5 add v to T; add (u, v) to MST6 end while7end procedure