Minimum Spanning Trees Flashcards
prim, generic minimu spanning tree (9 cards)
what type of problems use MST ?
problems with roads anc cities
what is the psdoeocde code for genric mst ?
GENERIC-MST.G; w/
A= empty queue
while A does not form a spanning tree
find an edge (u,v) that is safe for A
A = A U {(u,v)}
return A
what is a safe edge ?
The edge connects two disconnected components of the graph.
Adding the edge will not create a cycle in the partial spanning tree.
pedoucode for Prim’s
Prim(g,s,w)
Initlaize-single-source
r.key=0;
Q=G.V
While Q=empty
u = ExtractMin(Q)
for all v E G.Adj[u]
if v.key > w(u,v) & v E Q
v.pi=u
v.key=w(u,v)
Key Pair, Root Queue, Extract, Visit, Update
“Key Pair”: Initialize each vertex’s key to ∞ and predecessor (π) to NIL.
“Root”: Set the starting vertex (r) key to 0.
“Queue”: Add all vertices to the priority queue (Q).
“Extract”: Extract the minimum key vertex u from the queue.
“Visit”: For each neighbor v of u, check the edge condition (w(u, v) < v:key).
“Update”: If the edge is better, update v’s key and predecessor.
do example of page 656
what is running time of prim’s ?
O(E log V)
prove path relatzation propety ?
what is the covergence property ?