Lecture Notes on 26 Apr 2013 Prim's Algorithm for Minimum Cost Spanning Tree * Graph G = (V, E) is a connected graph with a set of vertices V and a set of edges E having non-negative weights. * T is the set of edges in the minimum cost spanning tre. * U is the set of vertices in the minimum cost spanning tree. /* to begin with the minimum cost spanning tree is empty */ T = NULL /* set of edges E is ordered in increasing weight */ /* start the tree from an arbitrary vertex */ U = {1} /* maintain two arrays: closest[v] and lowcost[u, v] */ while (U <= V) { /* find the least weight edge (u, v) such that u is in U and v is V - U */ /* add edge to minimum cost spanning tree */ Insert (T, u, v) /* add v to set of connected vertices */ Insert (U, v) }