1 / 41

10

24. 4. 23. 9. 6. 18. 5. 11. 16. 8. 7. 14. 10. 21. Minimum Spanning Tree. 4. 9. 6. 5. 11. 8. 7. G = (V, E), c(e). T ,  eT c(e) = 50. Kruskal’s Algorithm:. Add cheapest edge that does not create a cycle. 24. 4. 23. 9. 6. 18. 5. 11. 16. 8. 7.

cassiep
Télécharger la présentation

10

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. 24 4 23 9 6 18 5 11 16 8 7 14 10 21 Minimum Spanning Tree 4 9 6 5 11 8 7 G = (V, E), c(e) T, eT c(e)= 50

  2. Kruskal’s Algorithm: Add cheapest edge that does not create a cycle 24 4 23 9 6 18 5 11 16 8 7 14 10 21

  3. Kruskal’s Algorithm: Add cheapest edge that does not create a cycle 4 24 23 9 6 18 5 11 16 8 7 14 10 21

  4. Kruskal’s Algorithm: Add cheapest edge that does not create a cycle 4 24 23 9 6 18 5 11 16 8 7 14 10 21

  5. Kruskal’s Algorithm: Add cheapest edge that does not create a cycle 4 24 23 6 9 18 5 11 16 8 7 14 10 21

  6. Kruskal’s Algorithm: Add cheapest edge that does not create a cycle 4 24 23 6 9 18 5 11 16 8 7 14 10 21

  7. Kruskal’s Algorithm: Add cheapest edge that does not create a cycle 4 24 23 6 9 18 5 11 16 8 7 14 10 21

  8. Kruskal’s Algorithm: Add cheapest edge that does not create a cycle 4 24 23 6 9 18 5 11 16 8 7 14 10 21

  9. Kruskal’s Algorithm: Add cheapest edge that does not create a cycle 4 24 23 6 9 18 5 11 16 8 7 ? 14 10 21

  10. Kruskal’s Algorithm: Add cheapest edge that does not create a cycle Ignore edges inside components 4 24 23 6 9 18 5 11 16 8 7 14 10 21

  11. Kruskal’s Algorithm: Add cheapest edge that does not create a cycle Ignore edges inside components 4 24 23 6 9 18 5 11 16 8 7 14 10 21

  12. Kruskal’s Algorithm: Add cheapest edge that does not create a cycle Ignore edges inside components 4 24 23 6 9 18 5 16 11 8 7 14 10 21

  13. Kruskal’s Algorithm: Add cheapest edge that does not create a cycle Ignore edges inside components 4 24 23 6 9 18 5 16 11 8 7 14 10 21

  14. Prim’s Algorithm: Grow a tree. At each step, add cheapest edge from tree node to non-tree node 24 4 23 9 6 18 5 11 16 8 7 14 10 21

  15. Prim’s Algorithm: Grow a tree. At each step, add cheapest edge from tree node to non-tree node 24 4 23 9 6 18 5 11 16 8 7 14 10 21

  16. Prim’s Algorithm: Grow a tree. At each step, add cheapest edge from tree node to non-tree node 24 4 6 23 9 18 5 11 16 8 7 14 10 21

  17. Prim’s Algorithm: Grow a tree. At each step, add cheapest edge from tree node to non-tree node 4 24 6 23 9 18 5 11 16 8 7 14 10 21

  18. Prim’s Algorithm: Grow a tree. At each step, add cheapest edge from tree node to non-tree node 4 24 6 23 9 18 5 11 16 8 7 14 10 21

  19. Prim’s Algorithm: Grow a tree. At each step, add cheapest edge from tree node to non-tree node 4 24 6 23 9 18 5 11 16 8 7 14 10 21 Can remove edges between tree nodes

  20. Prim’s Algorithm: Grow a tree. At each step, add cheapest edge from tree node to non-tree node 4 24 6 23 9 18 5 16 11 8 7 14 10 21

  21. Prim’s Algorithm: Grow a tree. At each step, add cheapest edge from tree node to non-tree node 4 24 6 23 9 18 5 16 11 8 7 14 10 21

  22. Prim’s Algorithm: Grow a tree. At each step, add cheapest edge from tree node to non-tree node 4 24 6 23 9 18 5 16 11 8 7 14 10 21

  23. Components Data Structure Supporting Find and Merge (Union-Find) node-comp array comp-size array Lists of nodes 1 : 1, 2, 6, 7 2 : 3 : 4 : 4 5 : 5 6 : 7 : 8 : 8, 9, 3 9 :

  24. Components Data Structure Supporting Find and Merge (Union-Find) node-comp array comp-size array Lists of nodes 1 : 1 2 : 2 3 : 3 4 : 4 5 : 5 6 : 6 7 : 7 8 : 8 9 : 9

  25. Components Data Structure Merge(1,2) node-comp array comp-size array Lists of nodes 1 : 1 2 : 2 3 : 3 4 : 4 5 : 5 6 : 6 7 : 7 8 : 8 9 : 9

  26. Components Data Structure Merge(1,2) node-comp array comp-size array Lists of nodes 1 : 1, 2 2 : 3 : 3 4 : 4 5 : 5 6 : 6 7 : 7 8 : 8 9 : 9

  27. Components Data Structure Merge(1,8) node-comp array comp-size array Lists of nodes 1 : 1, 2, 6, 7 2 : 3 : 4 : 4 5 : 5 6 : 7 : 8 : 8, 9, 3 9 :

  28. Components Data Structure Merge(1,8) node-comp array comp-size array Lists of nodes 1 : 1, 2, 6, 7 2 : 3 : 4 : 4 5 : 5 6 : 7 : 8 : 8, 9, 3 9 :

  29. Components Data Structure Merge(1,8) node-comp array comp-size array Lists of nodes 1 : 1, 2, 6, 7 2 : 3 : 4 : 4 5 : 5 6 : 7 : 8 : 8, 9, 3 9 :

  30. Components Data Structure Merge(1,8) node-comp array comp-size array Lists of nodes 1 : 1, 2, 6, 7 2 : 3 : 4 : 4 5 : 5 6 : 7 : 8 : 8, 9, 3 9 :

  31. Components Data Structure Merge(1,8) node-comp array comp-size array Lists of nodes 1 : 1, 2, 6, 7 2 : 3 : 4 : 4 5 : 5 6 : 7 : 8 : 8, 9, 3 9 :

  32. Components Data Structure Merge(1,8) node-comp array comp-size array Lists of nodes 1 : 1, 2, 6, 7, 8, 9, 3 2 : 3 : 4 : 4 5 : 5 6 : 7 : 8 : 9 :

  33. 1(1) 2(1) 6(1) 3(1) 4(1) 5(1) 8(1) 9(1) 7(1) Components Data Structure Pointer Version Merge(1,2)

  34. 1(1) 6(1) 3(1) 4(1) 5(1) 8(1) 9(1) 7(1) Components Data Structure Pointer Version Merge(1,2) 2

  35. 1(2) 6(1) 3(1) 4(1) 5(1) 8(1) 9(1) 7(1) Components Data Structure Pointer Version Merge(3,4) 2

  36. 1(2) 6(1) 5(1) 8(1) 9(1) 7(1) Components Data Structure Pointer Version Merge(3,4) 3 2 4

  37. 1(1) 6(1) 3(2) 5(1) 8(1) 9(1) 7(1) Components Data Structure Pointer Version Merge(1,3) 2 4

  38. 1(2) 6(1) 3(2) 5(1) 8(1) 9(1) 7(1) Components Data Structure Pointer Version Merge(1,3) 2 4

More Related