SlideShare ist ein Scribd-Unternehmen logo
1 von 18
Minimum spanning trees
Minimum Connector Algorithms


        Kruskal’s algorithm                       Prim’s algorithm

1.   Select the shortest edge in a      1.   Select any vertex
     network
                                        2.   Select the shortest edge
2.   Select the next shortest edge           connected to that vertex
     which does not create a cycle
                                        3.   Select the shortest edge
3.   Repeat step 2 until all vertices        connected to any vertex
     have been connected                     already connected

                                        4.   Repeat step 3 until all
                                             vertices have been
                                             connected
Example
 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?
            Brinleigh         5                 Cornwell

             3
                                                    4
                         8             6

                                        8
 Avonford                         Fingley                  Donster
                     7
                               5
                 4                          2

                             Edan
We model the situation as a network, then the
problem is to find the minimum connector for the
network

                 B           5               C

         3
                                                 4
                     8               6

                                      8
    A                            F                   D
                 7
                              5
             4                           2

                         E
Kruskal’s Algorithm
                                                    List the edges in
                                                    order of size:
            B           5               C           ED   2
                                                    AB   3
    3                                               AE   4
                                            4
                8               6                   CD   4
                                                    BC   5
                                 8                  EF   5
A                                               D   CF   6
            7               F
                                                    AF   7
                         5                          BF   8
        4                                           CF   8
                                    2


                    E
Kruskal’s Algorithm

                                                    Select the shortest
                                                    edge in the network
            B           5               C
                                                    ED 2
    3
                                            4
                8               6

                                 8
A                                               D
            7               F

                         5
        4                           2


                    E
Kruskal’s Algorithm
                                                    Select the next shortest
                                                    edge which does not
            B           5                           create a cycle
                                        C
                                                    ED 2
    3                                               AB 3
                                            4
                8               6

                                 8
A                                               D
            7               F

                         5
        4                           2


                    E
Kruskal’s Algorithm
                                                    Select the next shortest
                                                    edge which does not
            B           5                           create a cycle
                                        C
                                                    ED 2
    3                                               AB 3
                                            4
                8               6                   CD 4 (or AE 4)

                                 8
A                                               D
            7               F

                         5
        4                           2


                    E
Kruskal’s Algorithm
                                                    Select the next shortest
                                                    edge which does not
            B           5                           create a cycle
                                        C
                                                    ED   2
    3                                               AB   3
                                            4
                8               6                   CD   4
                                                    AE   4
                                 8
A                                               D
            7               F

                         5
        4                           2


                    E
Kruskal’s Algorithm
                                                    Select the next shortest
                                                    edge which does not
            B           5                           create a cycle
                                        C
                                                    ED   2
    3                                               AB   3
                                            4
                8               6                   CD   4
                                                    AE   4
                                 8                  BC   5 – forms a cycle
A                                               D   EF   5
            7               F

                         5
        4                           2


                    E
Kruskal’s Algorithm
                                                    All vertices have been
                                                    connected.
            B           5               C           The solution is
    3                                               ED   2
                                            4
                8               6                   AB   3
                                                    CD   4
                                 8                  AE   4
A                                               D   EF   5
            7               F

                         5
        4                                           Total weight of tree: 18
                                    2


                    E
Prim’s Algorithm
                                                    Select any vertex

            B           5                           A
                                        C
                                                    Select the shortest
    3                                               edge connected to
                                            4
                8               6                   that vertex

                                 8                  AB 3
A                                               D
            7               F

                         5
        4                           2


                    E
Prim’s Algorithm
                                                    Select the shortest
                                                    edge connected to
            B           5                           any vertex already
                                        C           connected.
    3                                               AE 4
                                            4
                8               6

                                 8
A                                               D
            7               F

                         5
        4                           2


                    E
Prim’s Algorithm
                                                    Select the shortest
                                                    edge connected to
            B           5                           any vertex already
                                        C           connected.
    3                                               ED 2
                                            4
                8               6

                                 8
A                                               D
            7               F

                         5
        4                           2


                    E
Prim’s Algorithm
                                                    Select the shortest
                                                    edge connected to
            B           5                           any vertex already
                                        C           connected.
    3                                               DC 4
                                            4
                8               6

                                 8
A                                               D
            7               F

                         5
        4                           2


                    E
Prim’s Algorithm
                                                    Select the shortest
                                                    edge connected to
            B           5                           any vertex already
                                        C           connected.
    3                                               CB 5 – forms a cycle
                                            4
                8               6
                                                    EF 5
                                 8
A                                               D
            7               F

                         5
        4                           2


                    E
Prim’s Algorithm
                                                    All vertices have been
                                                    connected.
            B           5               C           The solution is
    3                                               ED   2
                                            4
                8               6                   AB   3
                                                    CD   4
                                 8                  AE   4
A                                               D   EF   5
            7               F

                         5
        4                                           Total weight of tree: 18
                                    2


                    E
Some points to note


•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.

Weitere ähnliche Inhalte

Was ist angesagt?

19 prim,kruskal alg. in data structure
19 prim,kruskal alg. in data structure19 prim,kruskal alg. in data structure
19 prim,kruskal alg. in data structureEMEY GUJJAR
 
Radix sort concept
Radix sort conceptRadix sort concept
Radix sort conceptZeeshan Ali
 
[Question Paper] Electronic and Communication Technology (Revised Course) [Ja...
[Question Paper] Electronic and Communication Technology (Revised Course) [Ja...[Question Paper] Electronic and Communication Technology (Revised Course) [Ja...
[Question Paper] Electronic and Communication Technology (Revised Course) [Ja...Mumbai B.Sc.IT Study
 
Single sourceshortestpath by emad
Single sourceshortestpath by emadSingle sourceshortestpath by emad
Single sourceshortestpath by emadKazi Emad
 
Incremental Graph Queries for Cypher
Incremental Graph Queries for CypherIncremental Graph Queries for Cypher
Incremental Graph Queries for CypheropenCypher
 
Unit 5 graphs minimum spanning trees
Unit 5   graphs minimum spanning treesUnit 5   graphs minimum spanning trees
Unit 5 graphs minimum spanning treeskalyanineve
 
Range Minimum Queries
Range Minimum QueriesRange Minimum Queries
Range Minimum QueriesBenjamin Sach
 
Bellman ford algorithm
Bellman ford algorithmBellman ford algorithm
Bellman ford algorithmA. S. M. Shafi
 
Lecture 15 ME 176 7 Root Locus Technique
Lecture 15 ME 176 7 Root Locus TechniqueLecture 15 ME 176 7 Root Locus Technique
Lecture 15 ME 176 7 Root Locus TechniqueLeonides De Ocampo
 
Cee 312(6)(structural analysis)
Cee 312(6)(structural analysis)Cee 312(6)(structural analysis)
Cee 312(6)(structural analysis)apudgr8
 
4.5 solve by finding square roots
4.5 solve by finding square roots4.5 solve by finding square roots
4.5 solve by finding square rootsNorthside ISD
 
Lecture 16 data structures and algorithms
Lecture 16 data structures and algorithmsLecture 16 data structures and algorithms
Lecture 16 data structures and algorithmsAakash deep Singhal
 

Was ist angesagt? (18)

19 primkruskal
19 primkruskal19 primkruskal
19 primkruskal
 
19 prim,kruskal alg. in data structure
19 prim,kruskal alg. in data structure19 prim,kruskal alg. in data structure
19 prim,kruskal alg. in data structure
 
Radix sort concept
Radix sort conceptRadix sort concept
Radix sort concept
 
Kruskal Algorithm
Kruskal AlgorithmKruskal Algorithm
Kruskal Algorithm
 
[Question Paper] Electronic and Communication Technology (Revised Course) [Ja...
[Question Paper] Electronic and Communication Technology (Revised Course) [Ja...[Question Paper] Electronic and Communication Technology (Revised Course) [Ja...
[Question Paper] Electronic and Communication Technology (Revised Course) [Ja...
 
Minimum Spanning Tree
Minimum Spanning TreeMinimum Spanning Tree
Minimum Spanning Tree
 
Sorting2
Sorting2Sorting2
Sorting2
 
Single sourceshortestpath by emad
Single sourceshortestpath by emadSingle sourceshortestpath by emad
Single sourceshortestpath by emad
 
Mergesort
MergesortMergesort
Mergesort
 
Incremental Graph Queries for Cypher
Incremental Graph Queries for CypherIncremental Graph Queries for Cypher
Incremental Graph Queries for Cypher
 
Unit 5 graphs minimum spanning trees
Unit 5   graphs minimum spanning treesUnit 5   graphs minimum spanning trees
Unit 5 graphs minimum spanning trees
 
Range Minimum Queries
Range Minimum QueriesRange Minimum Queries
Range Minimum Queries
 
Bellman ford algorithm
Bellman ford algorithmBellman ford algorithm
Bellman ford algorithm
 
Network analysis
Network analysisNetwork analysis
Network analysis
 
Lecture 15 ME 176 7 Root Locus Technique
Lecture 15 ME 176 7 Root Locus TechniqueLecture 15 ME 176 7 Root Locus Technique
Lecture 15 ME 176 7 Root Locus Technique
 
Cee 312(6)(structural analysis)
Cee 312(6)(structural analysis)Cee 312(6)(structural analysis)
Cee 312(6)(structural analysis)
 
4.5 solve by finding square roots
4.5 solve by finding square roots4.5 solve by finding square roots
4.5 solve by finding square roots
 
Lecture 16 data structures and algorithms
Lecture 16 data structures and algorithmsLecture 16 data structures and algorithms
Lecture 16 data structures and algorithms
 

Andere mochten auch

Prims Algorithm
Prims AlgorithmPrims Algorithm
Prims AlgorithmSriram Raj
 
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra Sahil Kumar
 
Prim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning treePrim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning treeoneous
 
GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)
GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)
GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)Madhu Bala
 
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)Mohanlal Sukhadia University (MLSU)
 
Minimum Spanning Tree
Minimum Spanning TreeMinimum Spanning Tree
Minimum Spanning Treezhaokatherine
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applicationsTech_MX
 
Prims and kruskal algorithms
Prims and kruskal algorithmsPrims and kruskal algorithms
Prims and kruskal algorithmsSaga Valsalan
 

Andere mochten auch (16)

Greedy minimum spanning tree- prim's algorithm
Greedy minimum spanning tree- prim's algorithmGreedy minimum spanning tree- prim's algorithm
Greedy minimum spanning tree- prim's algorithm
 
Prims Algorithm
Prims AlgorithmPrims Algorithm
Prims Algorithm
 
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
 
Prim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning treePrim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning tree
 
Mst(engl)
Mst(engl)Mst(engl)
Mst(engl)
 
GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)
GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)
GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)
 
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
 
9 cm402.18
9 cm402.189 cm402.18
9 cm402.18
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
 
Prim algorithm
Prim algorithmPrim algorithm
Prim algorithm
 
Minimum Spanning Tree
Minimum Spanning TreeMinimum Spanning Tree
Minimum Spanning Tree
 
Prim's algorithm
Prim's algorithmPrim's algorithm
Prim's algorithm
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applications
 
Cis cvs risc
Cis cvs riscCis cvs risc
Cis cvs risc
 
Prims and kruskal algorithms
Prims and kruskal algorithmsPrims and kruskal algorithms
Prims and kruskal algorithms
 

Mehr von Hemant Gautam

Make a fool geekssay.com sharing
Make a fool geekssay.com sharingMake a fool geekssay.com sharing
Make a fool geekssay.com sharingHemant Gautam
 
1 men die-younger geekssay.com sharing
1 men die-younger geekssay.com sharing1 men die-younger geekssay.com sharing
1 men die-younger geekssay.com sharingHemant Gautam
 
Shopping cart project geekssay.com
Shopping cart project geekssay.comShopping cart project geekssay.com
Shopping cart project geekssay.comHemant Gautam
 
Segmentation geekssay.com
Segmentation  geekssay.comSegmentation  geekssay.com
Segmentation geekssay.comHemant Gautam
 
Atm traffic management geekssay.com
Atm traffic management  geekssay.comAtm traffic management  geekssay.com
Atm traffic management geekssay.comHemant Gautam
 
Disk scheduling geekssay.com
Disk scheduling geekssay.comDisk scheduling geekssay.com
Disk scheduling geekssay.comHemant Gautam
 
Knapsack Algorithm www.geekssay.com
Knapsack Algorithm www.geekssay.comKnapsack Algorithm www.geekssay.com
Knapsack Algorithm www.geekssay.comHemant Gautam
 
College Monitoring system BY: Geekssay.com
College Monitoring system BY: Geekssay.comCollege Monitoring system BY: Geekssay.com
College Monitoring system BY: Geekssay.comHemant Gautam
 

Mehr von Hemant Gautam (8)

Make a fool geekssay.com sharing
Make a fool geekssay.com sharingMake a fool geekssay.com sharing
Make a fool geekssay.com sharing
 
1 men die-younger geekssay.com sharing
1 men die-younger geekssay.com sharing1 men die-younger geekssay.com sharing
1 men die-younger geekssay.com sharing
 
Shopping cart project geekssay.com
Shopping cart project geekssay.comShopping cart project geekssay.com
Shopping cart project geekssay.com
 
Segmentation geekssay.com
Segmentation  geekssay.comSegmentation  geekssay.com
Segmentation geekssay.com
 
Atm traffic management geekssay.com
Atm traffic management  geekssay.comAtm traffic management  geekssay.com
Atm traffic management geekssay.com
 
Disk scheduling geekssay.com
Disk scheduling geekssay.comDisk scheduling geekssay.com
Disk scheduling geekssay.com
 
Knapsack Algorithm www.geekssay.com
Knapsack Algorithm www.geekssay.comKnapsack Algorithm www.geekssay.com
Knapsack Algorithm www.geekssay.com
 
College Monitoring system BY: Geekssay.com
College Monitoring system BY: Geekssay.comCollege Monitoring system BY: Geekssay.com
College Monitoring system BY: Geekssay.com
 

Kürzlich hochgeladen

HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 

Kürzlich hochgeladen (20)

HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 

Kruskals prims shared by: geekssay.com

  • 2. Minimum Connector Algorithms Kruskal’s algorithm Prim’s algorithm 1. Select the shortest edge in a 1. Select any vertex network 2. Select the shortest edge 2. Select the next shortest edge connected to that vertex which does not create a cycle 3. Select the shortest edge 3. Repeat step 2 until all vertices connected to any vertex have been connected already connected 4. Repeat step 3 until all vertices have been connected
  • 3. Example 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? Brinleigh 5 Cornwell 3 4 8 6 8 Avonford Fingley Donster 7 5 4 2 Edan
  • 4. We model the situation as a network, then the problem is to find the minimum connector for the network B 5 C 3 4 8 6 8 A F D 7 5 4 2 E
  • 5. Kruskal’s Algorithm List the edges in order of size: B 5 C ED 2 AB 3 3 AE 4 4 8 6 CD 4 BC 5 8 EF 5 A D CF 6 7 F AF 7 5 BF 8 4 CF 8 2 E
  • 6. Kruskal’s Algorithm Select the shortest edge in the network B 5 C ED 2 3 4 8 6 8 A D 7 F 5 4 2 E
  • 7. Kruskal’s Algorithm Select the next shortest edge which does not B 5 create a cycle C ED 2 3 AB 3 4 8 6 8 A D 7 F 5 4 2 E
  • 8. Kruskal’s Algorithm Select the next shortest edge which does not B 5 create a cycle C ED 2 3 AB 3 4 8 6 CD 4 (or AE 4) 8 A D 7 F 5 4 2 E
  • 9. Kruskal’s Algorithm Select the next shortest edge which does not B 5 create a cycle C ED 2 3 AB 3 4 8 6 CD 4 AE 4 8 A D 7 F 5 4 2 E
  • 10. Kruskal’s Algorithm Select the next shortest edge which does not B 5 create a cycle C ED 2 3 AB 3 4 8 6 CD 4 AE 4 8 BC 5 – forms a cycle A D EF 5 7 F 5 4 2 E
  • 11. Kruskal’s Algorithm All vertices have been connected. B 5 C The solution is 3 ED 2 4 8 6 AB 3 CD 4 8 AE 4 A D EF 5 7 F 5 4 Total weight of tree: 18 2 E
  • 12. Prim’s Algorithm Select any vertex B 5 A C Select the shortest 3 edge connected to 4 8 6 that vertex 8 AB 3 A D 7 F 5 4 2 E
  • 13. Prim’s Algorithm Select the shortest edge connected to B 5 any vertex already C connected. 3 AE 4 4 8 6 8 A D 7 F 5 4 2 E
  • 14. Prim’s Algorithm Select the shortest edge connected to B 5 any vertex already C connected. 3 ED 2 4 8 6 8 A D 7 F 5 4 2 E
  • 15. Prim’s Algorithm Select the shortest edge connected to B 5 any vertex already C connected. 3 DC 4 4 8 6 8 A D 7 F 5 4 2 E
  • 16. Prim’s Algorithm Select the shortest edge connected to B 5 any vertex already C connected. 3 CB 5 – forms a cycle 4 8 6 EF 5 8 A D 7 F 5 4 2 E
  • 17. Prim’s Algorithm All vertices have been connected. B 5 C The solution is 3 ED 2 4 8 6 AB 3 CD 4 8 AE 4 A D EF 5 7 F 5 4 Total weight of tree: 18 2 E
  • 18. Some points to note •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.