Minimal Spanning Trees

Similar documents
The Critical-Path Algorithm

The Decreasing-Time Algorithm

The Traveling Salesman Problem Nearest-Neighbor Algorithm

Recursive Sequences. Lecture 24 Section 5.6. Robb T. Koether. Hampden-Sydney College. Wed, Feb 27, 2013

Rotations and Translations

Recursive Sequences. Lecture 24 Section 5.6. Robb T. Koether. Hampden-Sydney College. Wed, Feb 26, 2014

Solving Recursive Sequences by Iteration

while Loops Lecture 13 Sections Robb T. Koether Wed, Sep 26, 2018 Hampden-Sydney College

Sampling Distribution Examples Sections 15.4, 15.5

Scheduling and Digraphs

The Pairwise-Comparison Method

The Traveling Salesman Problem Brute Force Method

Binary Tree Applications

Street-Routing Problems

Stack Applications. Lecture 27 Sections Robb T. Koether. Hampden-Sydney College. Wed, Mar 29, 2017

Boolean Expressions. Lecture 31 Sections 6.6, 6.7. Robb T. Koether. Hampden-Sydney College. Wed, Apr 8, 2015

XPath Lecture 34. Robb T. Koether. Hampden-Sydney College. Wed, Apr 11, 2012

Density Curves Sections

Boxplots. Lecture 17 Section Robb T. Koether. Hampden-Sydney College. Wed, Feb 10, 2010

The Coefficient of Determination

Total Orders. Lecture 41 Section 8.5. Robb T. Koether. Hampden-Sydney College. Mon, Apr 8, 2013

Recursive Descent Parsers

Displaying Distributions - Quantitative Variables

The Plurality-with-Elimination Method

The string Class. Lecture 21 Sections 2.9, 3.9, Robb T. Koether. Wed, Oct 17, Hampden-Sydney College

XML Attributes. Lecture 33. Robb T. Koether. Hampden-Sydney College. Wed, Apr 25, 2018

The Traveling Salesman Problem Cheapest-Link Algorithm

Nondeterministic Programming in C++

XPath. Lecture 36. Robb T. Koether. Wed, Apr 16, Hampden-Sydney College. Robb T. Koether (Hampden-Sydney College) XPath Wed, Apr 16, / 28

Linked Lists. Lecture 16 Sections Robb T. Koether. Hampden-Sydney College. Wed, Feb 22, 2017

Regular Expressions. Lecture 10 Sections Robb T. Koether. Hampden-Sydney College. Wed, Sep 14, 2016

LR Parsing - Conflicts

Scope and Parameter Passing

Function Definition Syntax Tree

The Graphics Pipeline

The Class Construct Part 1

Recursion. Lecture 2 Sections Robb T. Koether. Hampden-Sydney College. Wed, Jan 17, 2018

Mipmaps. Lecture 35. Robb T. Koether. Hampden-Sydney College. Wed, Nov 18, 2015

Webpage Navigation. Lecture 27. Robb T. Koether. Hampden-Sydney College. Mon, Apr 2, 2018

Magnification and Minification

Scope and Parameter Passing

PHP Queries and HTML Forms Lecture 23

Implementing Linked Lists

Building the Abstract Syntax Trees

The CYK Parsing Algorithm

The Normal Distribution

Pointers. Lecture 1 Sections Robb T. Koether. Hampden-Sydney College. Wed, Jan 14, 2015

Introduction to Compiler Design

XQuery FLOWR Expressions Lecture 35

Pointer Arithmetic. Lecture 4 Chapter 10. Robb T. Koether. Hampden-Sydney College. Wed, Jan 25, 2017

List Iterators. Lecture 27 Section Robb T. Koether. Hampden-Sydney College. Wed, Apr 8, 2015

Aggregation. Lecture 7 Section Robb T. Koether. Hampden-Sydney College. Wed, Jan 29, 2014

Recursive Linked Lists

List Iterator Implementation

The Projection Matrix

Recursion. Lecture 26 Sections , Robb T. Koether. Hampden-Sydney College. Mon, Apr 6, 2015

Operators. Lecture 12 Section Robb T. Koether. Hampden-Sydney College. Fri, Feb 9, 2018

jquery Lecture 34 Robb T. Koether Wed, Apr 10, 2013 Hampden-Sydney College Robb T. Koether (Hampden-Sydney College) jquery Wed, Apr 10, / 29

Inheritance: The Fundamental Functions

The Graphics Pipeline

Recognition of Tokens

Triggers. Lecture 14. Robb T. Koether. Hampden-Sydney College. Wed, Feb 14, 2018

List Iterators. Lecture 34 Section Robb T. Koether. Hampden-Sydney College. Wed, Apr 24, 2013

Abstract Data Types. Lecture 23 Section 7.1. Robb T. Koether. Hampden-Sydney College. Wed, Oct 24, 2012

Friends and Unary Operators

Form Validation. Lecture 25. Robb T. Koether. Hampden-Sydney College. Wed, Mar 23, 2018

DTDs and XML Attributes

Function Usage. Lecture 15 Sections 6.3, 6.4. Robb T. Koether. Hampden-Sydney College. Mon, Oct 1, 2018

Stack Applications. Lecture 25 Sections Robb T. Koether. Hampden-Sydney College. Mon, Mar 30, 2015

Introduction to Databases

Specular Reflection. Lecture 19. Robb T. Koether. Hampden-Sydney College. Wed, Oct 4, 2017

Pointers. Lecture 2 Sections Robb T. Koether. Hampden-Sydney College. Fri, Jan 18, 2013

Insertions, Deletions, and Updates

Pointers. Lecture 2 Sections Robb T. Koether. Hampden-Sydney College. Mon, Jan 20, 2014

Integer Overflow. Lecture 8 Section 2.5. Robb T. Koether. Hampden-Sydney College. Mon, Jan 27, 2014

The Constructors. Lecture 7 Sections Robb T. Koether. Hampden-Sydney College. Wed, Feb 1, 2017

Ambient and Diffuse Light

Programming Languages

Programming Languages

Inheritance: The Fundamental Functions

The Class Construct Part 2

MySQL Creating a Database Lecture 3

The Model Stack. Lecture 8. Robb T. Koether. Hampden-Sydney College. Wed, Sep 6, 2017

The x86 Instruction Set

Fundamental Data Types

The Mesh Class. Lecture 26. Robb T. Koether. Wed, Oct 28, Hampden-Sydney College

Basic CSS Lecture 17

Stacks and their Applications

Dynamic Allocation of Memory

Shading Triangles. Lecture 37. Robb T. Koether. Hampden-Sydney College. Mon, Nov 30, 2015

Basic PHP. Lecture 19. Robb T. Koether. Hampden-Sydney College. Mon, Feb 26, 2108

Array Lists. Lecture 15. Robb T. Koether. Hampden-Sydney College. Fri, Feb 16, 2018

Dynamic Allocation of Memory

LR Parsing - The Items

XML and AJAX Lecture 28

Review. Lecture 39. Robb T. Koether. Mon, Dec 5, Hampden-Sydney College. Robb T. Koether (Hampden-Sydney College) Review Mon, Dec 5, / 14

Binary Tree Implementation

Array Lists. Lecture 15. Robb T. Koether. Hampden-Sydney College. Mon, Feb 22, 2016

Binary Tree Implementation

Basic PHP Lecture 17

Transcription:

Minimal Spanning Trees Lecture 33 Sections 7.1-7.3 Robb T. Koether Hampden-Sydney College Wed, Apr 11, 20 Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 1 / 17

1 Networks and Trees 2 Minimal Spanning Trees 3 Kruskal s Algorithm 4 Examples 5 Assignment Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 2 / 17

Outline 1 Networks and Trees 2 Minimal Spanning Trees 3 Kruskal s Algorithm 4 Examples 5 Assignment Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 3 / 17

Networks and Trees Definition (Network) A network is a connected graph. Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 4 / 17

Networks and Trees Definition (Network) A network is a connected graph. Definition (Tree) A tree is a network that contains no circuits. Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 4 / 17

Properties of Trees If T is a tree with N vertices, then T has exactly N 1 edges. If any edge of T is removed, then the resulting graph is not connected. Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 5 / 17

Properties of Trees Add edges to connect the graph without making a circuit. Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 6 / 17

Properties of Trees Erase edges to remove circuits without disconnecting the graph. Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 7 / 17

Properties of Trees Theorem A graph G with N vertices is a tree if any two of the following three properties hold. (1) T has exactly N 1 edges. (2) T is connected. (3) T contains no circuits. Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 8 / 17

Outline 1 Networks and Trees 2 Minimal Spanning Trees 3 Kruskal s Algorithm 4 Examples 5 Assignment Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 9 / 17

Examples Printer Server Printer Suppose we want to connect devices in a network. Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 10 / 17

Examples 10 Printer 8 16 25 15 17 30 14 12 20 16 22 16 Server Printer We want all the devices connected to each other. Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 10 / 17

Examples 10 Printer 8 16 25 15 17 30 14 12 20 16 22 16 Server Printer But no two devices need to be connected by more than a single path. Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 10 / 17

Examples 10 Printer 12 13 30 15 8 14 25 20 17 17 16 22 Server Printer Given the distances, which lines do we keep? Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 10 / 17

Examples 10 Printer 12 13 30 15 8 14 25 20 17 17 16 22 Server Printer The best choice is the tree of minimal total length Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 10 / 17

Examples 10 Printer 12 15 16 Server 8 Printer The total length of this tree is 61 Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 10 / 17

Minimal Spanning Trees Definition (Spanning Tree) Given a graph G, a spanning tree of G is a subgraph T that is a tree and includes all the vertices of G. Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 11 / 17

Minimal Spanning Trees Definition (Spanning Tree) Given a graph G, a spanning tree of G is a subgraph T that is a tree and includes all the vertices of G. Definition (Minimal Spanning Tree) Given a weighted graph G, a minimal spanning tree of G is a spanning tree T that has the smallest total weight of all possible spanning trees of G. Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 11 / 17

Outline 1 Networks and Trees 2 Minimal Spanning Trees 3 Kruskal s Algorithm 4 Examples 5 Assignment Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 12 / 17

Kruskal s Algorithm Kruskal s Algorithm Given a graph G of N vertices, we may construct a minimal spanning tree as follows. (1) Include all the vertices of G in T. (2) Add to T the edge of minimal weight. (3) Repeatedly add to T edges of minimal weight of the remaining edges while being careful not to create a circuit. (4) Once we have added N 1 edges, T is a minimal spanning tree of G. Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 13 / 17

Outline 1 Networks and Trees 2 Minimal Spanning Trees 3 Kruskal s Algorithm 4 Examples 5 Assignment Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 14 / 17

Power Grid A 12 23 B 26 C 22 D E 25 F 20 27 23 14 G 21 20 H 14 I 42 35 28 J 22 20 12 K 21 15 38 33 32 24 L 34 14 N O M Given the possible links, find the minimal spanning tree. Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 15 / 17

Power Grid A 12 23 B 26 C 22 D E 25 F 20 27 23 14 G 21 20 H 14 I 42 35 28 J 22 20 12 K 21 15 38 33 32 24 L 34 14 N O M The minimal spanning tree. Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 15 / 17

Power Grid A B D 12 C E 25 F 20 14 G 20 H 14 20 21 L I 28 J 12 K 15 14 N O M Total weight is 251. Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 15 / 17

Practice A E 15 40 34 42 F B 29 41 27 C 44 16 31 38 G 20 28 D H 45 47 48 26 32 36 46 22 L I 37 24 M 35 25 J 17 N K 19 33 23 O 43 39 21 30 P Find the minimal spanning tree. Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 16 / 17

Outline 1 Networks and Trees 2 Minimal Spanning Trees 3 Kruskal s Algorithm 4 Examples 5 Assignment Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 17 / 17

Assignment Assignment Chapter 7 Exercises 1, 3, 7, 35, 37, 39, 40, 45. Robb T. Koether (Hampden-Sydney College) Minimal Spanning Trees Wed, Apr 11, 20 / 17