This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Algorithms Lecture 18: Minimum Spanning Trees [ Sp10 ] 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 18 Minimum Spanning Trees 18.1 Introduction Suppose we are given a connected, undirected, weighted graph. This is a graph G = ( V , E ) together with a function w : E R that assigns a weight w ( e ) to each edge e . For this lecture, well assume that the weights are real numbers. Our task is to find 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, Ill assume that all the edge weights are distinct: w ( e ) 6 = w ( e ) for any pair of edges e and e . 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. 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 HORTEREDGE 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 ) 18.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-first search and breadth-first 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 c Copyright 2011 Jeff Erickson. Released under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )....
View Full Document
This note was uploaded on 10/14/2011 for the course ECON 101 taught by Professor Smith during the Spring '11 term at West Virginia University Institute of Technology.
- Spring '11