Kruskal Algorithm

snehasispanigrahi 11,053 views 19 slides Jun 07, 2010
Slide 1
Slide 1 of 19
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19

About This Presentation

No description available for this slideshow.


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
Tags