Put each vertex into a set by it's self count = 0 sort the edges in increasing order while count < |V| let e =(u,v) be the minimum edge not yet tested if u and v are in different sets, add e to T merge the sets of u and v
MST_KRUSKAL(G,w) (1) T = {} (2) for each vertex v in V[G] (3) MakeSet(v) (4) sort the edges of E by nondecreasing weight w (5) foreach edge (u,v) in E in order (6) if FindSet(u) != FindSet(v) (7) T = T union {(u,v)} (8) Union(u,v) (9) return T
start at a node, add it to the tree while there are not nodes in the tree, select the minimum edge from a node on the tree to a node not on the tree add this (edge, node) to the tree
MST-PRIM(G,w,r) (1) Q = V[G] (2) foreach u in Q (3) key[u] = inf (4) key[r] = 0 (5) r.parent= NULL (6) while !Q.isEmpty() (7) u = Q.ExtractMin() (8) foreach v adjacient to u (9) if v in Q and w(u,v) < key[v] (10) v.parent = u (11) key[v] = w(u,v)