Minimum Spanning T
Minimum Spanning T
Graphs - Definitions
Graph
a set of vertices (nodes) and edges connecting them
we say G = ( V, E ) where
V is a set of vertices: V = { vi }
An edge connects two vertices: e = ( vi , vj )
E is a set of edges: E = { (vi , vj ) }
Vertices
Edges
< i, c, f, g, h >
Path of length 5
< a, b >
Path of length 2
GENERIC-MST(G, w)
1. A ← Φ
2. while A does not form a spanning tree
3. do find an edge (u,v) that is safe for A
4. A ← A U {(u,v)}
5. return A
Cycle determination
Choose c as its
Our forest now has 2 two-element trees representative
and 5 single vertex ones
11/29/2006 Mr D C Jinwala, Algorithms & Computational Complexity, M Tech(CO), SVNIT, 200607 18
Kruskal’s Algorithm in operation
Add it to the forest,
The next cheapest edge joining a and b into a
is a-b 2-element tree
Choose b as its
representative
The rep of d is d
The rep of h is c
The rep of i is c
The rep of h is c
Proof:
If the edge is in T, this is trivial.
Suppose (x,y) is not in T Then there must be a path in T from x to y
since T is connected.
If (v,w) is the first edge on this path with one edge in V', if we
delete it and replace it with (x, y) we get a spanning tree.
This tree must have smaller weight than T, since W(v,w)>W(x,y).
Thus T could not have been the MST.
While in Prim,
the MST grows in a natural manner…
staring from an arbitrary root.