1 / 17

Minimum Spanning Trees

Minimum Spanning Trees. CIS 606 Spring 2010. Problem. A town has a set of houses and a set of roads. A road connects 2 and only 2 houses. A road connecting houses u and v has a repair cost w ( u , v ). Goal : Repair enough (and no more) roads such that

Télécharger la présentation

Minimum Spanning Trees

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. Minimum Spanning Trees CIS 606 Spring 2010

  2. Problem • A town has a set of houses and a set of roads. • A road connects 2 and only 2 houses. • A road connecting houses u andvhas a repair costw(u, v). • Goal: Repair enough (and no more) roads such that • everyone stays connected: can reach every house from all other houses, and • total repair cost is minimum.

  3. Model as a graph

  4. Growing a minimum spanning tree • Some properties of an MST: • It has |V – 1| edges. • It has no cycles. • It might not be unique • Building up the solution • We will build a set A of edges. • Initially, A has no edges. • As we add edges to A, maintain a loop invariant: • Loop invariant: A is a subset of some MST. • Add only edges that maintain the invariant. If A is a subset of some MST, an edge (u, v) is safe for A if and only if A U (u, v) is also a subset of someMST. So we will add only safe edges.

  5. Generic MST algorithm

  6. Finding a safe edge

  7. Kruskal’s Algorithm

  8. Kruskal’s Algorithm

  9. Analysis

  10. Prim’s Algorithm

  11. Prim’s Algorithm

  12. Prim’s Algorithm

  13. Analysis

More Related