Minimum spanning trees
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
A cable company want to connect five villages to their network
which currently extends to the market town of Avonford. What is the
minimum length of cable needed?
Avonford Fingley
Brinleigh Cornwell
Donster
Edan
2
7
4
5
8 6
4
5
3
8
Example
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
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
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
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
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
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
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
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
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
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
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
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
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
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
•Both algorithms will always give solutions with
the same length.
•They will usually select edges in a different order
– you must show this in your workings.
•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

More Related Content

PPTX
kruskal prim
PPT
minimum spanning tree
PPTX
Kruskal & Prim's Algorithm
PPTX
Minimum Spanning Tree
PPT
Minimum spanning tree
PPTX
Minimum Spanning Tree (Data Structure and Algorithm)
PPTX
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
DOC
Graph theory1234
kruskal prim
minimum spanning tree
Kruskal & Prim's Algorithm
Minimum Spanning Tree
Minimum spanning tree
Minimum Spanning Tree (Data Structure and Algorithm)
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
Graph theory1234

Similar to kruskal.ppt (20)

PPTX
prim's and kruskal's algorithm
PPT
17 prims-kruskals (1)
PPTX
uva-201026072839.pptxvcvczcvzvcxbxcvbcxvbvcxbcx
PDF
Minimum Spanning Tree (MST), Kruskal's algorithm and Prim's Algorithm, and th...
PPTX
Minimum spanning tree
PPT
Greedy Approach in Design Analysis and Algorithms
PPTX
Prim's and Kruskal's Algorithm
PPTX
Decision Maths 1 Chapter 3 Algorithms on Graphs (including Floyd A2 content)....
PPTX
Minimum Spinning Tree Full Explaination pptx
PPTX
A tree is an acyclic, undirected, connected graph • A spanning tree of a grap...
PPTX
My presentation minimum spanning tree
PPTX
Ram minimum spanning tree
PPTX
Kruskal Algorithm
PPT
3 Greedy-lec.pptggggghhhhhhhyyyyyyyyyyyyyy
PDF
Unit3_1.pdf
PPT
Graph Theory PPT presentation created by Selvam.
PDF
Minimum-Spanning-Tree.pdf ramswaroop memorial University
PPTX
DM Min SPan Tree Minimum spanning tree .pptx
PPTX
Use of the Tree.
PPTX
7. Spanning trees
prim's and kruskal's algorithm
17 prims-kruskals (1)
uva-201026072839.pptxvcvczcvzvcxbxcvbcxvbvcxbcx
Minimum Spanning Tree (MST), Kruskal's algorithm and Prim's Algorithm, and th...
Minimum spanning tree
Greedy Approach in Design Analysis and Algorithms
Prim's and Kruskal's Algorithm
Decision Maths 1 Chapter 3 Algorithms on Graphs (including Floyd A2 content)....
Minimum Spinning Tree Full Explaination pptx
A tree is an acyclic, undirected, connected graph • A spanning tree of a grap...
My presentation minimum spanning tree
Ram minimum spanning tree
Kruskal Algorithm
3 Greedy-lec.pptggggghhhhhhhyyyyyyyyyyyyyy
Unit3_1.pdf
Graph Theory PPT presentation created by Selvam.
Minimum-Spanning-Tree.pdf ramswaroop memorial University
DM Min SPan Tree Minimum spanning tree .pptx
Use of the Tree.
7. Spanning trees
Ad

More from erosslo (6)

PPT
tema1.ppt
PPT
Java2-Clases.ppt
PDF
[Robert_B._Cialdini]_Influence__The_Psychology_of_(z-lib.org).pdf
PDF
Koldijk et. al - 2018 - Detecting Work Stress.pdf
PDF
Emotion semantics show both cultural variation anduniversal structure.pdf
PDF
Predicting longterm-dynamics-of-soil-salinity-and-sodicity-on-a-global-scale2...
tema1.ppt
Java2-Clases.ppt
[Robert_B._Cialdini]_Influence__The_Psychology_of_(z-lib.org).pdf
Koldijk et. al - 2018 - Detecting Work Stress.pdf
Emotion semantics show both cultural variation anduniversal structure.pdf
Predicting longterm-dynamics-of-soil-salinity-and-sodicity-on-a-global-scale2...
Ad

Recently uploaded (20)

PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PPTX
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
PDF
Empowerment Technology for Senior High School Guide
PDF
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
DOCX
Cambridge-Practice-Tests-for-IELTS-12.docx
PPTX
TNA_Presentation-1-Final(SAVE)) (1).pptx
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PDF
Complications of Minimal Access-Surgery.pdf
PPTX
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
PDF
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
PDF
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
PDF
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
PPTX
Virtual and Augmented Reality in Current Scenario
PDF
International_Financial_Reporting_Standa.pdf
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PDF
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
PPTX
20th Century Theater, Methods, History.pptx
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
FORM 1 BIOLOGY MIND MAPS and their schemes
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
Empowerment Technology for Senior High School Guide
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
Cambridge-Practice-Tests-for-IELTS-12.docx
TNA_Presentation-1-Final(SAVE)) (1).pptx
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Practical Manual AGRO-233 Principles and Practices of Natural Farming
Complications of Minimal Access-Surgery.pdf
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
Virtual and Augmented Reality in Current Scenario
International_Financial_Reporting_Standa.pdf
A powerpoint presentation on the Revised K-10 Science Shaping Paper
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
20th Century Theater, Methods, History.pptx
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf

kruskal.ppt

  • 2. 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
  • 3. A cable company want to connect five villages to their network which currently extends to the market town of Avonford. What is the minimum length of cable needed? Avonford Fingley Brinleigh Cornwell Donster Edan 2 7 4 5 8 6 4 5 3 8 Example
  • 4. 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
  • 5. 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
  • 6. 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
  • 7. 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
  • 8. 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
  • 9. 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
  • 10. 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
  • 11. 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
  • 12. 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
  • 13. 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
  • 14. 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
  • 15. 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
  • 16. 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
  • 17. 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
  • 18. •Both algorithms will always give solutions with the same length. •They will usually select edges in a different order – you must show this in your workings. •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