ece 242
play

ECE 242 Data Structures Lecture 32 Minimum Spanning Trees - PDF document

ECE 242 Data Structures Lecture 32 Minimum Spanning Trees December 2, 2009 ECE242 L32: Minimum Spanning Trees Overview Problem: What is the minimum cost edges to connect all vertices in a graph? Spanning Tree Connects all vertices


  1. ECE 242 Data Structures Lecture 32 Minimum Spanning Trees December 2, 2009 ECE242 L32: Minimum Spanning Trees Overview ° Problem: What is the minimum cost edges to connect all vertices in a graph? ° Spanning Tree • Connects all vertices ° Minimum Spanning Tree • Minimum connection for all vertices ° Use minimum spanning tree algorithm to generate MST from a graph December 2, 2009 ECE242 L32: Minimum Spanning Trees

  2. Spanning Tree ° Connected subgraph that includes all vertices of the original connected graph ° Subgraph is a tree • If original graph has n vertices, the spanning tree has n vertices and n-1 edges. • No cycle in the subgraph December 2, 2009 ECE242 L32: Minimum Spanning Trees Minimum Spanning Trees ° Connect a set of vertices while minimizing expenses. ° Spanning tree • Given a connected, undirected graph G, a spanning tree is another graph which has all of G's vertices and a subset of G's edges Spanning tree has only v – 1 edges. • - Minimum number of edges required to connect all of the vertices. - Never contains a cycle. - May be more than one spanning tree for a given graph. December 2, 2009 ECE242 L32: Minimum Spanning Trees

  3. Spanning Tree ° Minimum number of edges to keep it connected ° If N vertices, spanning tree has N-1 edges December 2, 2009 ECE242 L32: Minimum Spanning Trees Minimum Spanning Tree (MST) Spanning tree with minimum weight 6 6 10 10 1 1 7 20 5 5 December 2, 2009 ECE242 L32: Minimum Spanning Trees

  4. Algorithm For Finding MST 1. All nodes are unselected 2. Mark node v selected 3. For each node in graph { Find the edge with minimum weight that connects one - unselected node with one selected node Mark this unselected node as selected - } December 2, 2009 ECE242 L32: Minimum Spanning Trees Demos For Finding MST ° Step 1: mark vertex A as selected A 1 2 10 D B 6 5 C December 2, 2009 ECE242 L32: Minimum Spanning Trees

  5. Demos For Finding MST ° Step 2: find the minimum weighted edge connected to vertex A, and mark the other A vertex on this edge as selected. 1 2 10 D B 6 5 C December 2, 2009 ECE242 L32: Minimum Spanning Trees Demos For Finding MST ° Step 3: find the minimum weighted edge connected A to vertices set { A, D } , and mark the other vertex on 1 this edge as selected. 2 10 D B 6 5 C December 2, 2009 ECE242 L32: Minimum Spanning Trees

  6. Demos For Finding MST ° Step 4: find the minimum weighted edge connected to vertices set { A, D, B} , A and mark the other vertex on this edge as selected. 1 2 10 D B 6 5 C December 2, 2009 ECE242 L32: Minimum Spanning Trees Demos For Finding MST ° Step 5: All vertex are marked as selected, So we find the minimum spanning tree A 1 2 10 D B 6 5 C December 2, 2009 ECE242 L32: Minimum Spanning Trees

  7. Finding Spanning Trees ° Every spanning tree in an unweighted graph has edges. ° If the graph is unweighted, then any tree is a “minimum” spanning tree. ° Both breadth- and depth-first search construct a tree, all nodes are visited (in time). ° Total running time December 2, 2009 ECE242 L32: Minimum Spanning Trees

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend