Top Banner
Minimum Spanning Trees CIS 606 Spring 2010
17

Minimum Spanning Trees

Jan 03, 2016

Download

Documents

tatyana-ruiz

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 - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Minimum Spanning Trees

Minimum Spanning Trees

CIS 606Spring 2010

Page 2: Minimum Spanning Trees

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

that1. everyone stays connected: can reach every

house from all other houses, and2. total repair cost is minimum.

Page 3: Minimum Spanning Trees

Model as a graph

Page 4: Minimum Spanning Trees

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 some MST. So we will add only safe edges.

Page 5: Minimum Spanning Trees

Generic MST algorithm

Page 6: Minimum Spanning Trees

Finding a safe edge

Page 7: Minimum Spanning Trees
Page 8: Minimum Spanning Trees
Page 9: Minimum Spanning Trees
Page 10: Minimum Spanning Trees
Page 11: Minimum Spanning Trees

Kruskal’s Algorithm

Page 12: Minimum Spanning Trees

Kruskal’s Algorithm

Page 13: Minimum Spanning Trees

Analysis

Page 14: Minimum Spanning Trees

Prim’s Algorithm

Page 15: Minimum Spanning Trees

Prim’s Algorithm

Page 16: Minimum Spanning Trees

Prim’s Algorithm

Page 17: Minimum Spanning Trees

Analysis