The minimum spanning tree problem

Similar documents
Minimum-Spanning-Tree problem. Minimum Spanning Trees (Forests) Minimum-Spanning-Tree problem

CSE 100 Minimum Spanning Trees Prim s and Kruskal

Minimum spanning trees

Minimum Spanning Trees My T. UF

Chapter 23. Minimum Spanning Trees

1 Minimum Spanning Trees (MST) b 2 3 a. 10 e h. j m

Announcements Problem Set 5 is out (today)!

Week 11: Minimum Spanning trees

Chapter 9. Greedy Technique. Copyright 2007 Pearson Addison-Wesley. All rights reserved.

Theory of Computing. Lecture 10 MAS 714 Hartmut Klauck

Decreasing a key FIB-HEAP-DECREASE-KEY(,, ) 3.. NIL. 2. error new key is greater than current key 6. CASCADING-CUT(, )

Lecture 13. Reading: Weiss, Ch. 9, Ch 8 CSE 100, UCSD: LEC 13. Page 1 of 29

CSC 1700 Analysis of Algorithms: Minimum Spanning Tree

Definition: A graph G = (V, E) is called a tree if G is connected and acyclic. The following theorem captures many important facts about trees.

COP 4531 Complexity & Analysis of Data Structures & Algorithms

Greedy Algorithms. At each step in the algorithm, one of several choices can be made.

We ve done. Introduction to the greedy method Activity selection problem How to prove that a greedy algorithm works Fractional Knapsack Huffman coding

Minimum Spanning Trees

CSC 8301 Design & Analysis of Algorithms: Kruskal s and Dijkstra s Algorithms

CS 6783 (Applied Algorithms) Lecture 5

22 Elementary Graph Algorithms. There are two standard ways to represent a

CIS 121 Data Structures and Algorithms Minimum Spanning Trees

Computer Science & Engineering 423/823 Design and Analysis of Algorithms

Minimum Spanning Trees

Data Structures and Algorithms

Week 12: Minimum Spanning trees and Shortest Paths

6.1 Minimum Spanning Trees

Kruskal s MST Algorithm

Minimum Spanning Tree (5A) Young Won Lim 5/11/18

Design and Analysis of Algorithms

CSE331 Introduction to Algorithms Lecture 15 Minimum Spanning Trees

Minimum Spanning Trees. CSE 373 Data Structures

Minimum Spanning Trees

CSE373: Data Structures & Algorithms Lecture 17: Minimum Spanning Trees. Dan Grossman Fall 2013

Weighted Graphs and Greedy Algorithms

Minimum Spanning Trees

Union/Find Aka: Disjoint-set forest. Problem definition. Naïve attempts CS 445

CS302 - Data Structures using C++

23.2 Minimum Spanning Trees

2pt 0em. Computer Science & Engineering 423/823 Design and Analysis of Algorithms. Lecture 04 Minimum-Weight Spanning Trees (Chapter 23)

22 Elementary Graph Algorithms. There are two standard ways to represent a

Announcements. HW4 due Friday. Summer 2016 CSE373: Data Structures & Algorithms 1

A New Quick Algorithm for Finding the Minimal Spanning Tree

5 MST and Greedy Algorithms

CSE 100: GRAPH ALGORITHMS

5 MST and Greedy Algorithms

Minimum Spanning Trees Outline: MST

Algorithm Design and Analysis

Minimum Spanning Trees Ch 23 Traversing graphs

Minimum-Cost Spanning Tree. Example

Minimum Spanning Tree

Example. Minimum-Cost Spanning Tree. Edge Selection Greedy Strategies. Edge Selection Greedy Strategies

Complexity of Prim s Algorithm

Context: Weighted, connected, undirected graph, G = (V, E), with w : E R.

Advanced Algorithms Class Notes for Monday, October 23, 2012 Min Ye, Mingfu Shao, and Bernard Moret

CS61B, Fall 2002 Discussion #15 Amir Kamil UC Berkeley 12/5/02

Introduction to Algorithms

Introduction to Algorithms

UC Berkeley CS 170: Efficient Algorithms and Intractable Problems Handout 8 Lecturer: David Wagner February 20, Notes 8 for CS 170

Minimum Spanning Trees

Depth-first Search (DFS)

Randomized Graph Algorithms

COMP 355 Advanced Algorithms

Review of course COMP-251B winter 2010

Minimal Spanning Tree

CS 5321: Advanced Algorithms Minimum Spanning Trees. Acknowledgement. Minimum Spanning Trees

Introduction to Optimization

SUGGESTION : read all the questions and their values before you start.

2.1 Greedy Algorithms. 2.2 Minimum Spanning Trees. CS125 Lecture 2 Fall 2016

DESIGN AND ANALYSIS OF ALGORITHMS GREEDY METHOD

Introduction to Algorithms

CS 561, Lecture 9. Jared Saia University of New Mexico

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

CHAPTER 23. Minimum Spanning Trees

Lecture 19. Broadcast routing

CS200: Graphs. Rosen Ch , 9.6, Walls and Mirrors Ch. 14

Priority queue ADT part 1

Minimum Spanning Trees

CSE 431/531: Algorithm Analysis and Design (Spring 2018) Greedy Algorithms. Lecturer: Shi Li

CS 310 Advanced Data Structures and Algorithms

Advanced algorithms. topological ordering, minimum spanning tree, Union-Find problem. Jiří Vyskočil, Radek Mařík 2012

Greedy algorithms. Given a problem, how do we design an algorithm that solves the problem? There are several strategies:

New approach to find minimum spanning tree for undirected graphs

CS521 \ Notes for the Final Exam

Greedy Algorithms. COMP 215 Lecture 6

looking ahead to see the optimum

CSE 521: Design and Analysis of Algorithms I

Greedy Algorithms Part Three

Minimum Spanning Trees. Minimum Spanning Trees. Minimum Spanning Trees. Minimum Spanning Trees

CS60020: Foundations of Algorithm Design and Machine Learning. Sourangshu Bhattacharya

Algorithms and Data Structures: Minimum Spanning Trees (Kruskal) ADS: lecture 16 slide 1

Spanning Tree. Lecture19: Graph III. Minimum Spanning Tree (MSP)

Spanning Trees. CSE373: Data Structures & Algorithms Lecture 17: Minimum Spanning Trees. Motivation. Observations. Spanning tree via DFS

Partha Sarathi Manal

Lecture 10. Elementary Graph Algorithm Minimum Spanning Trees

Homework 5: Graphs, Minimum Spanning Trees, and Dijkstra Shortest-Path

Undirected Graphs. Hwansoo Han

Algorithm Analysis Graph algorithm. Chung-Ang University, Jaesung Lee

Minimum Spanning Trees. Lecture II: Minimium Spanning Tree Algorithms. An Idea. Some Terminology. Dr Kieran T. Herley

Minimum Spanning Tree

Transcription:

The minimum spanning tree problem MST is a minimum cost connection problem on graphs The graph can model the connection in a (hydraulic, electric, telecommunication) network: the nodes are the points that must be connected and the edges the possible connections The problem consists in selecting edges so that all nodes are connected with the minimum total cost The solution is a Minimum Spanning Tree (MST) of the graph Formally, consider an undirected graph G=(V,E) A cost c i is associated with each edges e i, i=1,...,m of G The problem: find MST(G, c) the spanning tree of G with the minimum cost Two algorithms: Kruskal s algorithm (Greedy Algorithm) Prim s algorithm

1. Given graph G=(V,E) with n nodes and m edges, sort the edges as e 1, e 2,...,e m such that the associated costs are not decreasing (c 1 c 2... c m ). Set E 0 =, k=1 and the spanning tree ST 0 =(V, E 0 ) 2. If (V, E k-1 {e k }) is an acyclic graph then ST k =(V, E k ) with E k =E k-1 {e k }, otherwise E k =E k-1 e ST k =ST k-1 3. if E k =n-1 stop and ST k is the minimum spanning tree, otherwise k=k+1 and go to step 2.

It is a greedy algorithm: at each step it tries to insert in the solution the component with the minimum cost (local best decision) Easy to implement with a difficulty: how to check if the solution graph remains acyclic after the insertion of an edge? An alternative: Build the MST progressively joining disjoint trees that initially form a forest Start with a forest composed of n single nodes A selected edge is inserted only if the connected nodes belong to two distinct trees in the forest

Alternative Kruskal s algorithm 1. Initial spanning tree ST=(V, X); X = 2. Build n trees T k k=1,...,n each including a single node v V 3. Sort the edges in E such that the costs are non decreasing 4. For each edge e=(u,v) E T r = Tree_including(u) T s = Tree_including(v) If r s then X = X {e} Join_tree(T r, T s, e)

Example Consider the following graph V =9 E =17 Edge with cost 3 cannot be included since it closes a cycle 7 8 11 12 6 14 4 10 17 3 2 1 9 16 The MST cost is 44 13 5 15

The alternative implementation V =9 E =17 7 Edge with cost 3 cannot be inserted because it connects two nodes belonging to the same tree (so it closes a cycle) 8 11 12 6 14 4 10 17 3 2 1 9 16 When a single tree remains then the MST is found 13 5 15

Algorithm complexity: the number of needed operations in the worst case grows as a polynomial of order O( E log 2 E + E 2 ) that is, O( E 2 ): The algorithm sorts the edges (sorting requires a number of steps of order O( E log 2 E )) Then it performs E steps... And at each step it verifies that the solution remain acyclic (possible with procedure of order O( E )) Implementations exist with complexity O( E log 2 E ) The second algorithm for MST: Prim s algorithm is similar to the second version of Kruskal s algoritm It starts from a tree of the initial forest (a node) and progressively expand such a tree so that it includes all the other nodes

Prim s algorithm for MST 1. Given G=(V,E) with n nodes and m edges Select a node of G, V 0 ={v s } and set E 0 = and k=1 2. Connect a node v i V k-1 with a node v h V \V k-1 such that the cost of the edge (v i, v h ) be c( v i, v h ) = v j V ( v, v j k 1 min, v ) E V V [ c( v then update V k =V k-1 {v h } and E k =E k-1 {(v i, v h )} e 3. If E k =n-1 stop and ST k =(V k, E k ) is the MST, otherwise k=k+1 and go to 2. e k 1 j, v e )]

Prim s algorithm for MST Polynomial complexity: simple implementation is O( V E ): step 2 executed V -1 times and the edge selection has O( E ) complexity Example V =6 E =12 Initial node arbitrary chosen 12 9 7.5 7 8 16 10 17 11 9.5 19 10.5