1 / 11

Prims Algorithm for finding a minimum spanning tree

Prims Algorithm for finding a minimum spanning tree. 115. 90. 52. 35. 45. 40. 55. 20. 110. 100. 120. 32. 50. 60. 88. 38. 30. 25. A. 70. 70.

nevan
Download Presentation

Prims Algorithm for finding a minimum spanning tree

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Prims Algorithmfor finding a minimum spanning tree 115 90 52 35 45 40 55 20 110 100 120 32 50 60 88 38 30 25 A 70 70 Starting at vertex A, choose the edge of least weight. Your choices are shown in green.. The edge with least weight 25 will be the first edge in the tree.

  2. From now on, the tree will be marked in blue. Consider all edges with one end in the blue tree so far and one end outside. Your choices are in green. Choose the one of least weight and add it to the tree. That is the edge marked with weight 30. 115 90 52 35 45 40 55 20 110 100 120 32 50 60 88 38 30 25 A 70 70

  3. Consider all edges with one end in the blue tree so far and one end outside. Your choices are in green. Notice that one edge of weight 70 now has both ends in the tree, so it is no longer a choice. Choose the one of least weight and add it to the tree. The least weight edge is marked with 50. 115 90 52 35 45 40 55 20 110 100 120 32 50 60 88 38 30 25 A 70 70

  4. Consider all edges with one end in the blue tree so far and one end outside. Your choices are in green. As we continue adding edges to the tree, some green edges are changed back to black because they have both ends in the tree. Choose the one of least weight and add it to the tree. The least weight edge is marked with 40. 115 90 52 35 45 40 55 20 110 100 120 32 50 60 88 38 30 25 A 70 70

  5. Consider all edges with one end in the blue tree so far and one end outside. Your choices are in green. Choose the one of least weight and add it to the tree. The least weight edge is marked with 55. 115 90 52 35 45 40 55 20 110 100 120 32 50 60 88 38 30 25 A 70 70

  6. Consider all edges with one end in the blue tree so far and one end outside. Your choices are in green. Choose the one of least weight and add it to the tree. The least weight edge is marked with 70. 115 90 52 35 45 40 55 20 110 100 120 32 50 60 88 38 30 25 A 70 70

  7. Consider all edges with one end in the blue tree so far and one end outside. Your choices are in green. Choose the one of least weight and add it to the tree. The least weight edge is marked with 38. 115 90 52 35 45 40 55 20 110 100 120 32 50 60 88 38 30 25 A 70 70

  8. Consider all edges with one end in the blue tree so far and one end outside. Your choices are in green. Choose the one of least weight and add it to the tree. The least weight edge is marked with 20. 115 90 52 35 45 40 55 20 110 100 120 32 50 60 88 38 30 25 A 70 70

  9. Consider all edges with one end in the blue tree so far and one end outside. Your choices are in green. Choose the one of least weight and add it to the tree. The least weight edge is marked with 32. 115 90 52 35 45 40 55 20 110 100 120 32 50 60 88 38 30 25 A 70 70

  10. Consider all edges with one end in the blue tree so far and one end outside. Your choices are in green. Choose the one of least weight and add it to the tree. The least weight edge is marked with 35. 115 90 52 35 45 40 55 20 110 100 120 32 50 60 88 38 30 25 A 70 70

  11. Done! Now the blue tree contains all the vertices of the graph, so it is a spanning tree. The total weight is: 395 115 90 52 35 45 40 55 20 110 100 120 32 50 60 88 38 30 25 A 70 70

More Related