{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# 18-mst - Algorithms Lecture 18 Minimum Spanning Trees[Sp'10...

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

Algorithms Lecture 18: Minimum Spanning Trees [ Sp’10 ] 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, we’ll 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, 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. 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 ) 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/ ).

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern