next up previous
Next: Proof Of Correctness Up: KRUSKAL'S ALGORITHM Previous: KRUSKAL'S ALGORITHM

Kruskal's Algorithm (Refined)

Operations:
  1. UNION(i,j), of sets i and j, contains elements of sets i and j
  2. FIND tex2html_wrap_inline472 iff tex2html_wrap_inline474 set i

a) Construct a min-heap E of edges in E
b) Each tex2html_wrap_inline316 forms singleton set by itself, such that FIND tex2html_wrap_inline484 .

c) tex2html_wrap_inline314 {Tree is empty}
d) while tex2html_wrap_inline488 do
Delete the root edge {v,w} from min-heap E and restore heap E
if FIND tex2html_wrap_inline494 FIND tex2html_wrap_inline496 has no cycle*/
then tex2html_wrap_inline498
/*now, combine the components of tex2html_wrap_inline500 joined by {v,w} into one*/

UNION ( FIND(v), FIND(w))

end if

end while

figure153



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