SlideShare a Scribd company logo
2
Most read
7
Most read
17
Most read
Minimum spanning treesMinimum spanning trees
1
MST
A minimum spanning tree connects all nodes in a given graph
A MST must be a connected and undirected graph
A MST can have weighted edges
Multiple MSTs can exist within a given undirected graph
Multiple MSTs can be generated depending on which algorithm is
used
If you wish to have an MST start at a specific node
However, if there are weighted edges and all weighted edges are
unique, only one MST will exist
2
Borůvka’s Algorithm
• The first MST Algorithm was created by
Otakar Borůvka in 1926
• The algorithm was used to create efficient
connections between the electricity
network in the Czech Republic
• No longer used since Prim’s and Kruskal’s
algorithms were discovered
3
Prim’s Algorithm
• Initially discovered in 1930 by Vojtěch
Jarník, then rediscovered in 1957 by
Robert C. Prim
• Similar to Dijkstra’s Algorithm regarding a
connected graph
• Starts off by picking any node within the
graph and growing from there
4
Kruskal’s Algorithm
• Created in 1957 by Joseph Kruskal
• Finds the MST by taking the smallest weight in the graph
and connecting the two nodes and repeating until all
nodes are connected to just one tree
• This is done by creating a priority queue using the
weights as keys
• Each node starts off as it’s own tree
• While the queue is not empty, if the edge retrieved
connects two trees, connect them, if not, discard it
• Once the queue is empty, you are left with the minimum
spanning tree
5
Minimum Connector Algorithms
Kruskal’s algorithm
1. Select the shortest edge in a
network
2. Select the next shortest edge
which does not create a cycle
3. Repeat step 2 until all vertices
have been connected
Prim’s algorithm
1. Select any vertex
2. Select the shortest edge
connected to that vertex
3. Select the shortest edge
connected to any vertex
already connected
4. Repeat step 3 until all
vertices have been
connected
Prim’s algorithm
1. Select any vertex
2. Select the shortest edge
connected to that vertex
3. Select the shortest edge
connected to any vertex
already connected
4. Repeat step 3 until all
vertices have been
connected
6
A cable company want to connect five villages to their network
which currently extends to the market town of Addis Ababa. What
is the minimum length of cable needed?
Addis Hawassa
Adama Awash
Dilla
Wolita
2
7
4
5
8 6
4
5
3
8
Example
7
We model the situation as a network, then the
problem is to find the minimum connector for the
network
A F
B C
D
E
2
7
4
5
8 6
4
5
3
8
8
A
F
B
C
D
E
2
7
4
5
8 6
4
5
3
8
List the edges in
order of size:
ED 2
AB 3
AE 4
CD 4
BC 5
EF 5
CF 6
AF 7
BF 8
CF 8
Kruskal’s Algorithm
9
Select the shortest
edge in the network
ED 2
Kruskal’s Algorithm
A
F
B
C
D
E
2
7
4
5
8 6
4
5
3
8
10
Select the next shortest
edge which does not
create a cycle
ED 2
AB 3
Kruskal’s Algorithm
A
F
B
C
D
E
2
7
4
5
8 6
4
5
3
8
11
Select the next shortest
edge which does not
create a cycle
ED 2
AB 3
CD 4 (or AE 4)
Kruskal’s Algorithm
A
F
B
C
D
E
2
7
4
5
8 6
4
5
3
8
12
Select the next shortest
edge which does not
create a cycle
ED 2
AB 3
CD 4
AE 4
Kruskal’s Algorithm
A
F
B
C
D
E
2
7
4
5
8 6
4
5
3
8
13
Select the next shortest
edge which does not
create a cycle
ED 2
AB 3
CD 4
AE 4
BC 5 – forms a cycle
EF 5
Kruskal’s Algorithm
A
F
B
C
D
E
2
7
4
5
8 6
4
5
3
8
14
All vertices have been
connected.
The solution is
ED 2
AB 3
CD 4
AE 4
EF 5
Total weight of tree: 18
Kruskal’s Algorithm
A
F
B
C
D
E
2
7
4
5
8 6
4
5
3
8
15
A
F
B
C
D
E
2
7
4
5
8 6
4
5
3
8
Select any vertex
A
Select the shortest
edge connected to
that vertex
AB 3
Prim’s Algorithm
16
A
F
B
C
D
E
2
7
4
5
8 6
4
5
3
8
Select the shortest
edge connected to
any vertex already
connected.
AE 4
Prim’s Algorithm
17
Select the shortest
edge connected to
any vertex already
connected.
ED 2
Prim’s Algorithm
A
F
B
C
D
E
2
7
4
5
8 6
4
5
3
8
18
Select the shortest
edge connected to
any vertex already
connected.
DC 4
Prim’s Algorithm
A
F
B
C
D
E
2
7
4
5
8 6
4
5
3
8
19
Select the shortest
edge connected to
any vertex already
connected.
EF 5
Prim’s Algorithm
A
F
B
C
D
E
2
7
4
5
8 6
4
5
3
8
20
Prim’s Algorithm
A
F
B
C
D
E
2
7
4
5
8 6
4
5
3
8
All vertices have been
connected.
The solution is
AB 3
AE 4
ED 2
DC 4
EF 5
Total weight of tree: 18
21
•Both algorithms will always give solutions with the
same length.
•They will usually select edges in a different order
•Occasionally they will use different edges – this
may happen when you have to choose between
edges with the same length. In this case there is
more than one minimum connector for the
network.
Some points to note
22
Questions?
23

More Related Content

PPTX
My presentation minimum spanning tree
PPTX
Minimum Spanning Tree
PPT
Spanning trees
PPT
Minimum spanning tree
PPT
minimum spanning trees Algorithm
PDF
Minimum spanning tree
PPTX
Knapsack problem using greedy approach
PPTX
Spanning trees & applications
My presentation minimum spanning tree
Minimum Spanning Tree
Spanning trees
Minimum spanning tree
minimum spanning trees Algorithm
Minimum spanning tree
Knapsack problem using greedy approach
Spanning trees & applications

What's hot (20)

PDF
Shortest Path in Graph
PPTX
PRIM'S ALGORITHM
PDF
All pairs shortest path algorithm
PPT
KRUSKAL'S algorithm from chaitra
PDF
Expression trees
PPTX
PPTX
Prims and kruskal algorithms
PPT
Graph algorithms
PPTX
Knapsack Problem
PPTX
Kruskal Algorithm
PPTX
Kruskal Algorithm
PPTX
Presentation on Breadth First Search (BFS)
PPTX
Minimum spanning tree
PPTX
A presentation on prim's and kruskal's algorithm
PPTX
Dijkstra s algorithm
PPT
SINGLE-SOURCE SHORTEST PATHS
PPTX
Shortest path problem
PPTX
Chomsky Normal Form
PPTX
Prim's algorithm
PPTX
Kruskal & Prim's Algorithm
Shortest Path in Graph
PRIM'S ALGORITHM
All pairs shortest path algorithm
KRUSKAL'S algorithm from chaitra
Expression trees
Prims and kruskal algorithms
Graph algorithms
Knapsack Problem
Kruskal Algorithm
Kruskal Algorithm
Presentation on Breadth First Search (BFS)
Minimum spanning tree
A presentation on prim's and kruskal's algorithm
Dijkstra s algorithm
SINGLE-SOURCE SHORTEST PATHS
Shortest path problem
Chomsky Normal Form
Prim's algorithm
Kruskal & Prim's Algorithm
Ad

Viewers also liked (17)

DOCX
olproject
PPT
Happy workers happy library
PPTX
Upplýsingtækni í árborg 18.5.2015
PDF
Acc 557 homework 1 5 complete solution
PPTX
Iowa assessments practice problems
PPTX
Comp1900 Tahseen
PDF
http://whatisarsi.carpaltunnelnaturalcures.com
PPTX
Cassandra At Wize Commerce
ODP
Trabajo informaticaopenofficegeorgigenadiev
PPTX
Phys LO
PPTX
Academic english1124
PPTX
Kaspersky
PPT
Foto premiazione (id)art_fest2011
PDF
The world has changed retail - 24 august 2010
PPS
Cary Nadler, Phd.
ODP
Anegats
olproject
Happy workers happy library
Upplýsingtækni í árborg 18.5.2015
Acc 557 homework 1 5 complete solution
Iowa assessments practice problems
Comp1900 Tahseen
http://whatisarsi.carpaltunnelnaturalcures.com
Cassandra At Wize Commerce
Trabajo informaticaopenofficegeorgigenadiev
Phys LO
Academic english1124
Kaspersky
Foto premiazione (id)art_fest2011
The world has changed retail - 24 august 2010
Cary Nadler, Phd.
Anegats
Ad

Similar to minimum spanning tree (20)

PPTX
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
PPT
kruskal.ppt
PPTX
kruskal prim
PPTX
Minimum Spanning Tree (Data Structure and Algorithm)
PPTX
Ram minimum spanning tree
PPTX
Decision Maths 1 Chapter 3 Algorithms on Graphs (including Floyd A2 content)....
PPTX
Minimum Spanning Tree
PPTX
DATA STRUCTURE AND ALGORITHM LMS MST KRUSKAL'S ALGORITHM
PPT
PPTX
Network flow
PPTX
Greedy technique - Algorithm design techniques using data structures
PPT
MinSpanningTreespresantion.ppt
PPTX
Prim's and Kruskal's Algorithm
PPTX
Dijkstra’s Algorithm and Prim’s Algorithm in Graph Theory and Combinatorics
PPTX
Dijkstra’s Algorithm and Prim’s Algorithm in Graph Theory and Combinatorics
PPTX
Minimum spanning tree.pptx data structure programming
PPTX
7. Algorithm Design and analysis ppt.pptx
PPTX
Algorithm
PPTX
OR II - M3.pptx
PPTX
uva-201026072839.pptxvcvczcvzvcxbxcvbcxvbvcxbcx
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
kruskal.ppt
kruskal prim
Minimum Spanning Tree (Data Structure and Algorithm)
Ram minimum spanning tree
Decision Maths 1 Chapter 3 Algorithms on Graphs (including Floyd A2 content)....
Minimum Spanning Tree
DATA STRUCTURE AND ALGORITHM LMS MST KRUSKAL'S ALGORITHM
Network flow
Greedy technique - Algorithm design techniques using data structures
MinSpanningTreespresantion.ppt
Prim's and Kruskal's Algorithm
Dijkstra’s Algorithm and Prim’s Algorithm in Graph Theory and Combinatorics
Dijkstra’s Algorithm and Prim’s Algorithm in Graph Theory and Combinatorics
Minimum spanning tree.pptx data structure programming
7. Algorithm Design and analysis ppt.pptx
Algorithm
OR II - M3.pptx
uva-201026072839.pptxvcvczcvzvcxbxcvbcxvbvcxbcx

More from Melaku Bayih Demessie (10)

PPTX
Chapter 4 computer network and the internet2
PDF
Introduction to Cloud computing
PPTX
Selected topics in Computer Science
PDF
Turingmachines
PPTX
Greencomputing
PPTX
Reed solomon code
PPT
C2.0 propositional logic
PPTX
Chapter 5 of 1
PPTX
Dynamic programming
PPTX
Divide and Conquer
Chapter 4 computer network and the internet2
Introduction to Cloud computing
Selected topics in Computer Science
Turingmachines
Greencomputing
Reed solomon code
C2.0 propositional logic
Chapter 5 of 1
Dynamic programming
Divide and Conquer

minimum spanning tree

  • 1. Minimum spanning treesMinimum spanning trees 1
  • 2. MST A minimum spanning tree connects all nodes in a given graph A MST must be a connected and undirected graph A MST can have weighted edges Multiple MSTs can exist within a given undirected graph Multiple MSTs can be generated depending on which algorithm is used If you wish to have an MST start at a specific node However, if there are weighted edges and all weighted edges are unique, only one MST will exist 2
  • 3. Borůvka’s Algorithm • The first MST Algorithm was created by Otakar Borůvka in 1926 • The algorithm was used to create efficient connections between the electricity network in the Czech Republic • No longer used since Prim’s and Kruskal’s algorithms were discovered 3
  • 4. Prim’s Algorithm • Initially discovered in 1930 by Vojtěch Jarník, then rediscovered in 1957 by Robert C. Prim • Similar to Dijkstra’s Algorithm regarding a connected graph • Starts off by picking any node within the graph and growing from there 4
  • 5. Kruskal’s Algorithm • Created in 1957 by Joseph Kruskal • Finds the MST by taking the smallest weight in the graph and connecting the two nodes and repeating until all nodes are connected to just one tree • This is done by creating a priority queue using the weights as keys • Each node starts off as it’s own tree • While the queue is not empty, if the edge retrieved connects two trees, connect them, if not, discard it • Once the queue is empty, you are left with the minimum spanning tree 5
  • 6. Minimum Connector Algorithms Kruskal’s algorithm 1. Select the shortest edge in a network 2. Select the next shortest edge which does not create a cycle 3. Repeat step 2 until all vertices have been connected Prim’s algorithm 1. Select any vertex 2. Select the shortest edge connected to that vertex 3. Select the shortest edge connected to any vertex already connected 4. Repeat step 3 until all vertices have been connected Prim’s algorithm 1. Select any vertex 2. Select the shortest edge connected to that vertex 3. Select the shortest edge connected to any vertex already connected 4. Repeat step 3 until all vertices have been connected 6
  • 7. A cable company want to connect five villages to their network which currently extends to the market town of Addis Ababa. What is the minimum length of cable needed? Addis Hawassa Adama Awash Dilla Wolita 2 7 4 5 8 6 4 5 3 8 Example 7
  • 8. We model the situation as a network, then the problem is to find the minimum connector for the network A F B C D E 2 7 4 5 8 6 4 5 3 8 8
  • 9. A F B C D E 2 7 4 5 8 6 4 5 3 8 List the edges in order of size: ED 2 AB 3 AE 4 CD 4 BC 5 EF 5 CF 6 AF 7 BF 8 CF 8 Kruskal’s Algorithm 9
  • 10. Select the shortest edge in the network ED 2 Kruskal’s Algorithm A F B C D E 2 7 4 5 8 6 4 5 3 8 10
  • 11. Select the next shortest edge which does not create a cycle ED 2 AB 3 Kruskal’s Algorithm A F B C D E 2 7 4 5 8 6 4 5 3 8 11
  • 12. Select the next shortest edge which does not create a cycle ED 2 AB 3 CD 4 (or AE 4) Kruskal’s Algorithm A F B C D E 2 7 4 5 8 6 4 5 3 8 12
  • 13. Select the next shortest edge which does not create a cycle ED 2 AB 3 CD 4 AE 4 Kruskal’s Algorithm A F B C D E 2 7 4 5 8 6 4 5 3 8 13
  • 14. Select the next shortest edge which does not create a cycle ED 2 AB 3 CD 4 AE 4 BC 5 – forms a cycle EF 5 Kruskal’s Algorithm A F B C D E 2 7 4 5 8 6 4 5 3 8 14
  • 15. All vertices have been connected. The solution is ED 2 AB 3 CD 4 AE 4 EF 5 Total weight of tree: 18 Kruskal’s Algorithm A F B C D E 2 7 4 5 8 6 4 5 3 8 15
  • 16. A F B C D E 2 7 4 5 8 6 4 5 3 8 Select any vertex A Select the shortest edge connected to that vertex AB 3 Prim’s Algorithm 16
  • 17. A F B C D E 2 7 4 5 8 6 4 5 3 8 Select the shortest edge connected to any vertex already connected. AE 4 Prim’s Algorithm 17
  • 18. Select the shortest edge connected to any vertex already connected. ED 2 Prim’s Algorithm A F B C D E 2 7 4 5 8 6 4 5 3 8 18
  • 19. Select the shortest edge connected to any vertex already connected. DC 4 Prim’s Algorithm A F B C D E 2 7 4 5 8 6 4 5 3 8 19
  • 20. Select the shortest edge connected to any vertex already connected. EF 5 Prim’s Algorithm A F B C D E 2 7 4 5 8 6 4 5 3 8 20
  • 21. Prim’s Algorithm A F B C D E 2 7 4 5 8 6 4 5 3 8 All vertices have been connected. The solution is AB 3 AE 4 ED 2 DC 4 EF 5 Total weight of tree: 18 21
  • 22. •Both algorithms will always give solutions with the same length. •They will usually select edges in a different order •Occasionally they will use different edges – this may happen when you have to choose between edges with the same length. In this case there is more than one minimum connector for the network. Some points to note 22