# 12-mst - Algorithms Lecture 12 Minimum Spanning Trees We...

This preview shows pages 1–3. Sign up to view the full content.

Algorithms Lecture 12: Minimum Spanning Trees We must all hang together, gentlemen, or else we shall most assuredly hang separately. — Benjamin Franklin, at the signing of the Declaration of Independence (July 4, 1776) It is a very sad thing that nowadays there is so little useless information. — Oscar Wilde A ship in port is safe, but that is not what ships are for. — Rear Admiral Grace Murray Hopper 12 Minimum Spanning Trees 12.1 Introduction Suppose we are given a connected, undirected, weighted graph. This is a graph G = ( V , E ) together with a function w : E IR that assigns a weight w ( e ) to each edge e . For this lecture, we’ll assume that the weights are real numbers. Our task is to ﬁnd the minimum spanning tree of G , that is, the spanning tree T minimizing the function w ( T ) = X e T w ( e ) . To keep things simple, I’ll assume that all the edge weights are distinct: w ( e ) 6 = w ( e 0 ) for any pair of edges e and e 0 . Distinct weights guarantee that the minimum spanning tree of the graph is unique. Without this condition, there may be several different minimum spanning trees. For example, if all the edges have weight 1, then every spanning tree is a minimum spanning tree with weight V - 1. 8 5 10 2 3 18 16 12 14 30 4 26 A weighted graph and its minimum spanning tree. If we have an algorithm that assumes the edge weights are unique, we can still use it on graphs where multiple edges have the same weight, as long as we have a consistent method for breaking ties. One way to break ties consistently is to use the following algorithm in place of a simple comparison. S HORTER E DGE takes as input four integers i , j , k , l , and decides which of the two edges ( i , j ) and ( k , l ) has ‘smaller’ weight. S HORTER E DGE ( i , j , k , l ) if w ( i , j ) < w ( k , l ) return ( i , j ) if w ( i , j ) > w ( k , l ) return ( k , l ) if min ( i , j ) < min ( k , l ) return ( i , j ) if min ( i , j ) > min ( k , l ) return ( k , l ) if max ( i , j ) < max ( k , l ) return ( i , j ) ⟨⟨ if max(i,j) < max(k,l) ⟩⟩ return ( k , l ) 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Algorithms Lecture 12: Minimum Spanning Trees 12.2 The Only Minimum Spanning Tree Algorithm There are several different methods for computing minimum spanning trees, but really they are all instances of the following generic algorithm. The situation is similar to the previous lecture, where we saw that depth-ﬁrst search and breadth-ﬁrst search were both instances of a single generic traversal algorithm. The generic minimum spanning tree algorithm maintains an acyclic subgraph F of the input graph G , which we will call an intermediate spanning forest . F is a subgraph of the minimum spanning tree of G , and every component of F is a minimum spanning tree of its vertices. Initially, F consists of n one-node trees. The generic algorithm merges trees together by adding certain edges between them. When the algorithm halts, F consists of a single n -node tree, which must be the minimum spanning tree. Obviously,
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 12/15/2009 for the course 942 cs taught by Professor A during the Spring '09 term at University of Illinois at Urbana–Champaign.

### Page1 / 8

12-mst - Algorithms Lecture 12 Minimum Spanning Trees We...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online