1 / 19

Minimum Spanning Trees

Minimum Spanning Trees. Subgraph. A graph G is a subgraph of graph H if The vertices of G are a subset of the vertices of H , and The edges of G are a subset of the edges of H . Spanning Tree.

talmai
Download Presentation

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

  2. Subgraph • A graph G is a subgraphof graph H if • The vertices of G are a subset of the vertices of H, and • The edges of G are a subset of the edges of H.

  3. Spanning Tree • A spanning tree of a graph G is a subgraph of G that is a tree and includes all the vertices of G. • Every connected graph has a spanning tree • Start with G. If G is a tree then it is a ST of G. If not, G has a cycle. Remove any edge of the cycle. The result is a connected subgraph of G. Repeat. Process must terminate since the number of edges is finite.

  4. Spanning Trees

  5. Spanning Trees a spanning tree

  6. Spanning Trees another spanning tree (can have many)

  7. Weighted Graphs A weighted graph is a graph with a mapping of edges to R+ assigning a weight to each edge A minimum spanning tree of a weighted graph is a spanning tree of minimum total weight (sum of the weights of the edges in the tree)

  8. Minimum Spanning Trees 3 4 1 4 3 7 2 6 1

  9. Minimum Spanning Trees 3 4 1 4 3 7 2 6 1 1. Choose any vertex

  10. Minimum Spanning Trees 3 4 1 4 3 7 2 6 1 2. Choose minimum weight edge connected to that vertex

  11. Minimum Spanning Trees 3 4 1 4 3 7 2 6 1 3. Choose minimum weight edge connected to chosen vertices

  12. Minimum Spanning Trees 3 4 1 4 3 7 2 6 1 4. Choose minimum weight edge connected to chosen vertices

  13. Minimum Spanning Trees 3 4 1 4 3 7 2 6 1 5. Choose minimum weight edge connected to chosen vertices without creating a cycle

  14. Minimum Spanning Trees 3 4 1 4 3 7 2 6 1 6. Choose minimum weight edge connected to chosen vertices without creating a cycle

  15. Prim’s algorithm • To find a MST of a connected weighted graph G, we build a tree one edge at a time • Start with T being any node of G • Pick a minimum weight edge that does not create a cycle and that connects a node in T to a node not in T. Add that edge to T. • Repeat until all nodes of G have been added to T. • A “Greedy algorithm”

  16. Proof that Prim’s algorithm works Invariant: At every stage, T is a subgraph of a MST True initially since T is just a single node The algorithm runs until all nodes have been added to T, so in the end the invariant says that T is a MST. So we just need to show that each stage of the algorithm preserves the invariant.

  17. Proof that the algorithm maintains the invariant Proof by contradiction. Suppose there is a stage at which the invariant is true before and false after. Let e be the edge added when the invariant is first violated. Suppose e joins node v in T to node w not in T. So T is a subgraph of a MST but T+e is not. Let T’ be a MST of which T is a subgraph. Edge e is not in T’.

  18. Proof that the algorithm maintains the invariant Since T’ is a spanning tree, there is a path p from v to win T’. Path p does not go through e since e is not part of T’. So p+e is a cycle consisting of two different paths from u to v. Path p must include an edge f which has one end in T and the other not in T. Edge f must have weight ≥ the weight of e, otherwise the algorithm would have chosen to add edge f to T instead of e. Removing f from T’ and adding e results in a spanning tree of weight ≤ the weight of T’ and including T as a subgraph, contradicting the assumption that T+e was not a subgraph of a MST. ✔

  19. Finis

More Related