next up previous
Next: Data Structure for Prim's Up: No Title Previous: No Title

PRIM-DIJKSTRA'S MST ALGORITHM

figure11

figure16

figure21

PRIM-DIJKSTRA'S MST ALGORITHM

Input: G=(V,E,W)
Output: tex2html_wrap_inline312

tex2html_wrap_inline314
Select a vertex tex2html_wrap_inline316 and move v to tex2html_wrap_inline320
For i=1 to n-1 do
Let tex2html_wrap_inline326 be an edge such that tex2html_wrap_inline328 , and for all such edges, tex2html_wrap_inline326 has the minimum weight.

tex2html_wrap_inline332
tex2html_wrap_inline334

tex2html_wrap_inline336
endfor

tex2html_wrap_inline338

Theorem: Let tex2html_wrap_inline340 be a weighted connected graph and tex2html_wrap_inline342 be a MST of G. Let tex2html_wrap_inline346 is a subtree of T. If tex2html_wrap_inline350 is the minimum weight edge such that tex2html_wrap_inline352 and tex2html_wrap_inline354 then tex2html_wrap_inline356 is a subtree of a MST of G.

Proof:

  1. If tex2html_wrap_inline360 , done
  2. Let tex2html_wrap_inline362
    Then tex2html_wrap_inline364 has a cycle:

figure65

By the choice of tex2html_wrap_inline350
tex2html_wrap_inline367
Consider tex2html_wrap_inline370
Its weight is no more than the weight of T and it is a spanning tree.
tex2html_wrap_inline374 is a subtree of a MST of G





Sushil Prasad
Thu Nov 4 14:09:59 EST 1999