snehasispanigrahi
11,053 views
19 slides
Jun 07, 2010
Slide 1 of 19
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
About This Presentation
No description available for this slideshow.
Size: 337.95 KB
Language: en
Added: Jun 07, 2010
Slides: 19 pages
Slide Content
Kruskal Algorithm KRUSKAL(V,E,W) A ← Φ For each vertex v Є G[v] Do MAKESET[v] sort E into nondecreasing order of weight w Do if FINDSET [u]≠FINDSET[v] A ← A U {(U,V)} UNION(U,V) Return (A)
h g f b d c e a i Given: G is a connected undirected weighted graph 8 3 10 6 1 5 4 14 2 3 9 7 11 8
First sort the edges according to nondecreasing order of their weight
(h,g) - weight 1 (c,f) - weight 7 ( c,i) - weight 2 (b,c) - weight 8 (i,h) - weight 3 (c,d) - weight 8 ( i,g) - weight 3 (d,e) - weight 9 (a,b) - weight 4 (e,f) -weight 10 (a,h) - weight 5 (d,f) - weight 11 (g,f) - weight 6 (b,h) weight 14 h g f b d c e a i 8 3 10 6 1 5 4 14 2 3 9 7 11 8
(h,g): Select h g f b d c e a i 1
(c,i): Select h g f b d c e a i 1 2
Select (i,h): h g f b d c e a i 1 2 3
Reject h g f b d c e a i 2 3 3 1 (i,g):
Select h g f b d c e a i 4 2 3 1 ( a,b ):
Select h g f b d c e a i 4 5 1 3 2 (a,h):
(g,f): h g f b d c e a i 2 5 3 1 6 4 Select
Reject h g f b d c e a i 4 5 2 3 1 7 6 (c,f):
Select h g f b d c e a i 4 5 3 2 1 6 8 (c,d):
Reject h g f b d c e a i 4 5 3 1 8 2 6 8 (b,c):
Select h g f b d c e a i 4 5 2 3 1 6 8 9 (d,e):
Reject h g f b d c e a i 4 5 2 3 1 8 6 9 10 (e,f):
Reject h g f b d c e a i 4 5 3 2 1 6 8 11 9 (d,f):
Reject h g f b d c e a i 4 5 14 2 3 1 6 8 9 (b,h):
Minimum Spanning Tree Total weight(MST)=1+2+3+4+5+6+8+9=38 h g f b d c e a i 4 5 2 3 1 6 8 9