Presentation is loading. Please wait.

Presentation is loading. Please wait.

Minimum Spanning tree Select any vertex

Similar presentations


Presentation on theme: "Minimum Spanning tree Select any vertex"— Presentation transcript:

1 Minimum Spanning tree Select any vertex
Prim’s algorithm Select any vertex Select the shortest edge connected to that vertex Select the shortest edge which connects a previously chosen vertex to a new vertex Repeat step 3 until all vertices have been connected

2 Example A cable company want to connect five villages to their network which currently extends to the market town of Avenford. What is the minimum length of cable needed? 5 Brinleigh Cornwell 3 4 6 8 8 Avenford Donster Fingley 7 5 4 2 Edan

3 Prim’s algorithm in tabular form
First put the information from the network into a distance matrix A B C D E F - 3 4 7 5 8 6 2

4 A B C D E F - 3 4 7 5 8 6 2 1 3 Brinleigh Avenford
Start at vertex A. Label column A “1” . Delete row A Select the smallest entry in column A (AB, length 3) A B C D E F - 3 4 7 5 8 6 2 Avenford Brinleigh 3

5 A B C D E F - 3 4 7 5 8 6 2 1 2 3 4 Brinleigh Avenford Edan
Label column B “2” Delete row B Select the smallest uncovered entry in either column A or column B (AE, length 4) A B C D E F - 3 4 7 5 8 6 2 Avenford Brinleigh 3 Edan 4

6 A B C D E F - 3 4 7 5 8 6 2 1 2 3 3 4 2 Brinleigh Avenford Donster
Label column E “3” Delete row E Select the smallest uncovered entry in either column A, B or E (ED, length 2) A B C D E F - 3 4 7 5 8 6 2 Avenford Brinleigh 3 Edan 4 Donster 2

7 A B C D E F - 3 4 7 5 8 6 2 1 2 4 3 4 3 4 2 Cornwell Brinleigh
Label column D “4” Delete row D Select the smallest uncovered entry in either column A, B, D or E (DC, length 4) Cornwell 4 Avenford Brinleigh 3 Edan 4 Donster 2

8 A B C D E F - 3 4 7 5 8 6 2 1 2 5 4 3 4 3 5 4 2 Cornwell Brinleigh
Label column C “5” Delete row C Select the smallest uncovered entry in either column A, B, D, E or C (EF, length 5) Cornwell 4 Avenford Brinleigh 3 Fingley 5 Edan 4 Donster 2

9 A B C D E F - 3 4 7 5 8 6 2 1 2 5 4 3 6 4 3 5 4 2 Cornwell Brinleigh
FINALLY Label column F “6” Delete row F Cornwell 4 Avenford Brinleigh 3 Fingley 5 Edan 4 Donster 2

10 A B C D E F - 3 4 7 5 8 6 2 1 2 5 4 3 6 4 3 5 4 2 Cornwell Brinleigh
FINALLY Label column F “6” Delete row F Cornwell 4 Avenford Brinleigh 3 Fingley 5 Edan 4 Donster 2 The spanning tree is shown in the diagram Length = 18Km


Download ppt "Minimum Spanning tree Select any vertex"

Similar presentations


Ads by Google