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

ece 242
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

ECE242 L32: Minimum Spanning Trees December 2, 2009

ECE 242 Data Structures

Lecture 32

Minimum Spanning Trees

ECE242 L32: Minimum Spanning Trees December 2, 2009

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

slide-2
SLIDE 2

ECE242 L32: Minimum Spanning Trees December 2, 2009

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

ECE242 L32: Minimum Spanning Trees December 2, 2009

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.
slide-3
SLIDE 3

ECE242 L32: Minimum Spanning Trees December 2, 2009

Spanning Tree

° Minimum number of edges to keep it connected ° If N vertices, spanning tree has N-1 edges

ECE242 L32: Minimum Spanning Trees December 2, 2009

Minimum Spanning Tree (MST) 6 7 1 5 10 20 6 10 1 5

Spanning tree with minimum weight

slide-4
SLIDE 4

ECE242 L32: Minimum Spanning Trees December 2, 2009

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

}

ECE242 L32: Minimum Spanning Trees December 2, 2009

Demos For Finding MST °Step 1: mark vertex A as selected A B C D 2 1 10 5 6

slide-5
SLIDE 5

ECE242 L32: Minimum Spanning Trees December 2, 2009

Demos For Finding MST °Step 2: find the minimum weighted edge connected to vertex A, and mark the other vertex on this edge as selected. A B C D 2 1 10 5 6

ECE242 L32: Minimum Spanning Trees December 2, 2009

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

slide-6
SLIDE 6

ECE242 L32: Minimum Spanning Trees December 2, 2009

Demos For Finding MST °Step 4: find the minimum weighted edge connected to vertices set { A, D, B} , and mark the other vertex

  • n this edge as selected.

A B C D 2 1 10 5 6

ECE242 L32: Minimum Spanning Trees December 2, 2009

Demos For Finding MST °Step 5: All vertex are marked as selected, So we find the minimum spanning tree A B C D 2 1 10 5 6

slide-7
SLIDE 7

ECE242 L32: Minimum Spanning Trees December 2, 2009

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