Académique Documents
Professionnel Documents
Culture Documents
Kruskals algorithm
Conclusions
Slide 2
Introduction
A Spanning Tree (ST) of a graph is a subgraph that contains all the vertices
and is a tree, i.e., no Cycle & Connected.
A graph may have many spanning trees.
16 ST
Slide 3
Introduction Cont
A Spanning Tree (ST) of a graph is a subgraph that contains all the vertices
and is a tree, i.e., no Cycle & Connected.
A graph may have many spanning trees.
Let, the edges were weighted.
Minimal Spanning Tree (MST) is spanning tree with the minimum sum of edges,
w(T )
( u , v )T
w(u , v)
Slide 4
Applications of MST
Central office
Expensive
Slide 5
Applications of MST Cont
Central office
Better Approach
Slide 6
Applications of MST Cont
Electronic circuitry
Set of pins wiring them together.
Slide 7
How We Can Find a MST
Greedy
Two Most Popular Algorithms
Primes Algorithm
Kruskals Algorithm
His main area of work was in number theory and mathematical analysis;
he proved a number of results on lattice point problems. He also
developed the graph theory algorithm which is now known as Prim's
algorithm.
Slide 8
How We Can Find a MST Cont
Greedy
Two Most Popular Algorithms
Primes Algorithm
Kruskals Algorithm
Slide 9
Primes Algorithm
Prims Selection rule Select the minimum weight edge between a tree-node
Slide 10
Primes Algorithm Cont
Prims Selection rule Select the minimum weight edge between a tree-node
Slide 11
Primes Algorithm Cont
Prims Selection rule Select the minimum weight edge between a tree-node
Slide 12
Primes Algorithm Cont
Prims Selection rule Select the minimum weight edge between a tree-node
Slide 13
Primes Algorithm Cont
Prims Selection rule Select the minimum weight edge between a tree-node
Slide 14
Primes Algorithm Cont
Prims Selection rule Select the minimum weight edge between a tree-node
Slide 15
Primes Algorithm Cont
Prims Selection rule Select the minimum weight edge between a tree-node
Slide 16
Primes Algorithm Cont
More Detail
r : Grow the minimum spanning tree from the root vertex r.
Q : is a priority queue, holding all vertices that are not in the tree
now.
Slide 17
Primes Algorithm Cont
8 7
b c d 9
root 4
2
a 11 i 14 e
4
7 6
8 10
h g f
1 2
V a b c d e f g h i
T 1 0 0 0 0 0 0 0 0
Key 0 - - - - - - - -
p -1 - - - - - - - -
Slide 18
Primes Algorithm Cont
8 7
b c d 9
root 4
2
a 11 i 14 e
4
7 6
8 10
h g f
1 2
V a b c d e f g h i
T 1 0 0 0 0 0 0 0 0
Key 0 4 - - - - - 8 -
p -1 a - - - - - a -
Slide 19
Primes Algorithm Cont
8 7
b c d 9
root 4
2
a 11 i 14 e
4
7 6
8 10
h g f
1 2
Important: Update Key[v] only if T[v]==0
V a b c d e f g h i
T 1 1 0 0 0 0 0 0 0
Key 0 4 8 - - - - 8 -
p -1 a b - - - - a -
Slide 20
Primes Algorithm Cont
8 7
b c d 9
root 4
2
a 11 i 14 e
4
7 6
8 10
h g f
1 2
V a b c d e f g h i
T 1 1 1 0 0 0 0 0 0
Key 0 4 8 7 - 4 - 8 2
p -1 a b c - c - a c
Slide 21
Primes Algorithm Cont
8 7
b c d 9
root 4
2
a 11 i 14 e
4
7 6
8 10
h g f
1 2
V a b c d e f g h i
T 1 1 1 0 0 0 0 0 1
Key 0 4 8 7 - 4 6 7 2
p -1 a b c - c i i c
Slide 22
Primes Algorithm Cont
8 7
b c d 9
root 4
2
a 11 i 14 e
4
7 6
8 10
h g f
1 2
V a b c d e f g h i
T 1 1 1 0 0 1 0 0 1
Key 0 4 8 7 10 4 2 7 2
p -1 a b c f c f i c
Slide 23
Primes Algorithm Cont
8 7
b c d 9
root 4
2
a 11 i 14 e
4
7 6
8 10
h g f
1 2
V a b c d e f g h i
T 1 1 1 0 0 1 1 0 1
Key 0 4 8 7 10 4 2 1 2
p -1 a b c f c f g c
Slide 24
Primes Algorithm Cont
8 7
b c d 9
root 4
2
a 11 i 14 e
4
7 6
8 10
h g f
1 2
V a b c d e f g h i
T 1 1 1 0 0 1 1 1 1
Key 0 4 8 7 10 4 2 1 2
p -1 a b c f c f g c
Slide 25
Primes Algorithm Cont
8 7
b c d 9
root 4
2
a 11 i 14 e
4
7 6
8 10
h g f
1 2
V a b c d e f g h i
T 1 1 1 1 0 1 1 1 1
Key 0 4 8 7 9 4 2 1 2
p -1 a b c d c f g c
Slide 26
Primes Algorithm Cont
8 7
b c d 9
root 4
2
a 11 i 14 e
4
7 6
8 10
h g f
1 2 All T[v] = 1
So Done
V a b c d e f g h i
T 1 1 1 1 1 1 1 1 1
Key 0 4 8 7 9 4 2 1 2
p -1 a b c d c f g c
Slide 27
Kruskals Algorithm
Basic Terminology
Cut : Partition of V. Ex: (S, V-S)
Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is in S and
Slide 28
Kruskals Algorithm Cont
Basic Terminology
Cut : Partition of V. Ex: (S, V-S)
Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is in S and
Slide 29
Kruskals Algorithm Cont
Basic Terminology
Cut : Partition of V. Ex: (S, V-S)
Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is in S and
Slide 30
Kruskals Algorithm Cont
Basic Terminology
Cut : Partition of V. Ex: (S, V-S)
Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is in S and
Slide 31
Kruskals Algorithm Cont
Basic Terminology
Cut : Partition of V. Ex: (S, V-S)
Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is in S and
Slide 32
Kruskals Algorithm Cont
Basic Terminology
Cut : Partition of V. Ex: (S, V-S)
Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is in S and
Slide 33
Kruskals Algorithm Cont
Basic Terminology
Cut : Partition of V. Ex: (S, V-S)
Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is in S and
Slide 34
Kruskals Algorithm Cont
Basic Terminology
Cut : Partition of V. Ex: (S, V-S)
Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is in S and
Slide 35
Kruskals Algorithm Cont
Basic Terminology
Cut : Partition of V. Ex: (S, V-S)
Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is in S and
Slide 36
Primes Vs Kruskals
Time Comparison
P
r
i
m
w Slide 37
Conclusions
MST Still works are going on
Boruvka's Algorithm
Inventor of MST
Prims algorithm in parallel
Huge Number of Applications
Networking
Data mining
Clustering, Classification etc.
Slide 38
Questions or Suggestions
Thank You!