SlideServe
Menu
Préférences
© SlideServe · v2026

Chapter 23: Minimum Spanning Tree

winola avatar
29 diapositives · 735 Views · Aug 29, 2014

Chapter 23: Minimum Spanning Tree. About this lecture. What is a Minimum Spanning Tree? Some History The Greedy Choice Lemma Kruskal’s Algorithm Prim’s Algorithm. Minimum Spanning Tree. Let G = ( V , E ) be an undirected, connected graph

Chapter 23: Minimum Spanning Tree - slide 1
01 / 29Chapter 23: Minimum Spanning Tree
1 / 17

Télécharger la présentation

Chapter 23: Minimum Spanning Tree
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Chapter 23: Minimum Spanning Tree

  2. About this lecture • What is a Minimum Spanning Tree? • Some History • The Greedy Choice Lemma • Kruskal’s Algorithm • Prim’s Algorithm

  3. Minimum Spanning Tree • Let G = (V,E) be an undirected, connected graph • A spanning tree of G is a tree, using only edges in E, that connects all vertices of G

  4. 8 7 4 9 2 11 4 14 7 6 8 10 2 1 Total cost = 4 + 8 + 7 + 9 + 2 + 4 + 1 + 2 = 37 Minimum Spanning Tree • Sometimes, the edges in G have weights • weight  cost of using the edge • A minimum spanning tree (MST) of a weighted G is a spanning tree such that the sum of edge weights is minimized

  5. Minimum Spanning Tree • MST of a graph may not be unique 8 7 4 9 2 11 4 14 7 6 8 10 2 1 8 7 4 9 2 11 4 14 7 6 8 10 2 1

  6. Some History • Borůvka [1926]: First algorithm • for electrical network of Moravia • Kruskal [1956]: Kruskal’s algorithm • Jarník [1930], Prim [1957]: Prim’s algorithm • Fredman-Tarjan [1987]: O(Elog*(V)) time • Gabow et al [1986]: O(E log log*(V) time • Chazelle [1999]: O(E (E,V)) time • Remark:log* =iterated log,(m,n) = inverse Ackermann

  7. Designing a greedy algorithm • Greedy-choice property: A global optimal solution can be achieved by making a local optimal (optimal) choice. • Optimal substructure:An optimal solution to the problem contains its optimal solution to subproblem.

  8. 8 7 4 9 2 11 4 14 7 6 8 10 2 1 Give an arbitrary ordering among these two edges, so that one costs “fewer” than the other Greedy Choice Lemma • Suppose all edge weights are distinct • If not, we give an arbitrary ordering among equal-weight edges • E.g.,

  9. eb , ec ea c 8 7 4 9 b a 2 11 4 14 7 6 8 10 2 1 Greedy Choice Lemma • Let ev to be the cheapest edge adjacent to v, for each vertex v Theorem: The minimum spanning tree of G contains every ev

  10. u w v Proof • Recall that all edge weights are distinct • Suppose on the contrary that MST of G does not contain some edge ev = (u,v) • Let T = optimal MST of G • By adding ev = (u,v) to T, we obtain a cycle u, v, w, …, u [why??]

  11. u w v u w v Proof • By our choice of ev , we must have weight of (u,v) cheaper than weight of (v,w) to T • If we delete (v,w) and include ev, we obtain a spanning tree cheaper than T •  contradiction !!

  12. Optimal Substructure Let E’ = a set of edges which are known to be in an MST of G = (V,E) Let G* = the graph obtained by contracting each component of G’ = (V,E’) into a single vertex Let T* be (the edges of) an MST of G* Theorem: T*∪E’ is an MST of G Proof: (By contradiction)

  13. Proof • Let T and W(T) denote the MST of G and its corresponding cost, respectively • If T*∪E’ is not an MST of G, then W(T) < W(T*) + W(E’) • Since E’ is a set of edges in MST of G, It implies that T* is not the MST of G*  Contradiction

  14. G eb , ec ea c 8 7 4 9 b a 2 11 G* 4 14 edges inT* 7 6 8 7 8 10 2 1 9 11 4 14 7 6 8 10 2 1 Example

  15. Kruskal’s Algorithm • Kruskal-MST(G) • Find the cheapest (non-self-loop) edge (u,v) in G • Contract (u,v) to obtain G* • Kruskal-MST(G*)

  16. 8 7 4 9 2 11 4 14 7 6 8 10 2 1 8 7 4 9 2 11 4 14 7 6 8 10 2 1 Example

  17. 8 7 4 9 2 11 4 14 7 6 8 10 2 1 Example 8 7 4 9 2 11 4 14 7 6 8 10 2 1

  18. 8 7 4 9 2 11 4 14 7 6 8 10 2 1 8 7 4 9 2 11 4 14 7 6 8 10 2 1 Example

  19. 8 7 4 9 2 11 4 14 7 6 8 10 2 1 8 7 4 9 2 11 4 14 7 6 8 10 2 1 Example

  20. 8 7 4 9 2 11 4 14 7 6 8 10 2 1 8 7 4 9 2 11 4 14 7 6 8 10 2 1 Example

  21. Performance • Kruskal’s algorithm can be implemented efficiently using Union-Find (Chapter 21) • First, sort edges according to the weights • At each step, pick the cheapest edge • If end-points are from different component, we perform Union (and include this edge to the MST) •  Time for Union-Find = O(E(E)) • Total Time: O(E log E + E (E))=O(E log V)

  22. Prim’s Algorithm • Prim-MST(G, u) • Set u as the source vertex • Find the cheapest (non-self-loop) edge from u, say, (u,v) • Merge v into u to obtain G* • Prim-MST(G*, u)

  23. 8 7 4 9 2 11 4 14 7 6 8 10 2 1 Example u 8 7 u 4 9 2 11 4 14 7 6 8 10 2 1

  24. Example u 8 7 4 9 2 11 4 14 7 6 8 10 2 1 u 8 7 4 9 2 11 4 14 7 6 8 10 2 1

  25. Example u 8 7 4 9 2 11 4 14 7 6 8 10 2 1 u 8 7 4 9 2 11 4 14 7 6 8 10 2 1

  26. Example u 8 7 4 9 2 11 4 14 7 6 8 10 2 1 u 8 7 4 9 2 11 4 14 7 6 8 10 2 1

  27. Example u 8 7 4 9 2 11 4 14 7 6 8 10 2 1 u 8 7 4 9 2 11 4 14 7 6 8 10 2 1

  28. Performance • Prim’s algorithm can be implemented efficiently using Binary Heap H: • First, insert all edges adjacent to u into H • At each step, extract the cheapest edge • If an end-point, say v, is not in MST, include this edge and v to MST • Insert all edges adjacent to v into H • At most O(E) Insert/Extract-Min •  Total Time: O(E log E)=O(E log V)

  29. Homework • Practice at home: 1-2, 1-5, 1-7, 2-2, 2-5 • Problem 23-4 (Due Dec. 28)