1.1 Data Structure and Algorithm Lecture 13 Minimum Spanning Trees Topics Reference: Introduction to Algorithm by Cormen Chapter 13: Minimum Spanning Trees.

Slides:



Advertisements
Similar presentations
Greedy Algorithms Greed is good. (Some of the time)
Advertisements

Minimum Spanning Trees Definition of MST Generic MST algorithm Kruskal's algorithm Prim's algorithm.
Graph Algorithms. Jaruloj Chongstitvatana Chapter 3: Greedy Algorithms 2 Outline Graph Representation Shortest path Minimum spanning trees.
Minimum Spanning Tree CSE 331 Section 2 James Daly.
Minimum Spanning Tree (MST) form a tree that connects all the vertices (spanning tree). minimize the total edge weight of the spanning tree. Problem Select.
UNC Chapel Hill Lin/Foskey/Manocha Minimum Spanning Trees Problem: Connect a set of nodes by a network of minimal total length Some applications: –Communication.
Chapter 23 Minimum Spanning Trees
Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 13 Minumum spanning trees Motivation Properties of minimum spanning trees Kruskal’s.
Graph Algorithms: Minimum Spanning Tree We are given a weighted, undirected graph G = (V, E), with weight function w:
Lecture 18: Minimum Spanning Trees Shang-Hua Teng.
1 Minimum Spanning Trees Definition of MST Generic MST algorithm Kruskal's algorithm Prim's algorithm.
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
Analysis of Algorithms CS 477/677
Lecture 12 Minimum Spanning Tree. Motivating Example: Point to Multipoint Communication Single source, Multiple Destinations Broadcast – All nodes in.
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 11 Instructor: Paul Beame.
Minimum Spanning Trees. a b d f g e c a b d f g e c.
Minimum Spanning Tree Algorithms. What is A Spanning Tree? u v b a c d e f Given a connected, undirected graph G=(V,E), a spanning tree of that graph.
Midwestern State University Minimum Spanning Trees Definition of MST Generic MST algorithm Kruskal's algorithm Prim's algorithm 1.
Design and Analysis of Computer Algorithm September 10, Design and Analysis of Computer Algorithm Lecture 5-2 Pradondet Nilagupta Department of Computer.
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
Lecture 1: The Greedy Method 主講人 : 虞台文. Content What is it? Activity Selection Problem Fractional Knapsack Problem Minimum Spanning Tree – Kruskal’s Algorithm.
Minimum Spanning Trees Definition of MST Generic MST algorithm Kruskal's algorithm Prim's algorithm Binary Search Trees1.
Algorithms: Design and Analysis Summer School 2013 at VIASM: Random Structures and Algorithms Lecture 3: Greedy algorithms Phan Th ị Hà D ươ ng 1.
MST Many of the slides are from Prof. Plaisted’s resources at University of North Carolina at Chapel Hill.
2IL05 Data Structures Fall 2007 Lecture 13: Minimum Spanning Trees.
Spring 2015 Lecture 11: Minimum Spanning Trees
UNC Chapel Hill Lin/Foskey/Manocha Minimum Spanning Trees Problem: Connect a set of nodes by a network of minimal total length Some applications: –Communication.
Minimum Spanning Trees and Kruskal’s Algorithm CLRS 23.
1 Minimum Spanning Trees. Minimum- Spanning Trees 1. Concrete example: computer connection 2. Definition of a Minimum- Spanning Tree.
1 Greedy Algorithms and MST Dr. Ying Lu RAIK 283 Data Structures & Algorithms.
Chapter 23: Minimum Spanning Trees: A graph optimization problem Given undirected graph G(V,E) and a weight function w(u,v) defined on all edges (u,v)
© 2007 Seth James Nielson Minimum Spanning Trees … or how to bring the world together on a budget.
© 2007 Seth James Nielson Minimum Spanning Trees … or how to bring the world together on a budget.
1 2/23/2016 ITCS 6114 Topological Sort Minimum Spanning Trees.
1 Week 3: Minimum Spanning Trees Definition of MST Generic MST algorithm Kruskal's algorithm Prim's algorithm.
MST Lemma Let G = (V, E) be a connected, undirected graph with real-value weights on the edges. Let A be a viable subset of E (i.e. a subset of some MST),
Lecture 12 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
Minimum Spanning Trees Problem Description Why Compute MST? MST in Unweighted Graphs MST in Weighted Graphs –Kruskal’s Algorithm –Prim’s Algorithm 1.
Algorithm Design and Analysis June 11, Algorithm Design and Analysis Pradondet Nilagupta Department of Computer Engineering This lecture note.
Minimum Spanning Tree. p2. Minimum Spanning Tree G=(V,E): connected and undirected w: E  R, weight function a b g h i c f d e
Midwestern State University Minimum Spanning Trees Definition of MST Generic MST algorithm Kruskal's algorithm Prim's algorithm 1.
November 22, Algorithms and Data Structures Lecture XII Simonas Šaltenis Nykredit Center for Database Research Aalborg University
Lecture ? The Algorithms of Kruskal and Prim
Minimum Spanning Trees
Introduction to Algorithms
Minimum Spanning Tree Chapter 13.6.
Spanning Trees Kruskel’s Algorithm Prim’s Algorithm
Minimum Spanning Trees
CSC 413/513: Intro to Algorithms
Minimum Spanning Trees
Lecture 12 Algorithm Analysis
CISC 235: Topic 10 Graph Algorithms.
Minimum Spanning Trees
Algorithms and Data Structures Lecture XII
Data Structures – LECTURE 13 Minumum spanning trees
Greedy Algorithm (17.4/16.4) Greedy Algorithm (GA)
Chapter 23 Minimum Spanning Tree
CS 583 Analysis of Algorithms
Lecture 12 Algorithm Analysis
Minimum Spanning Trees
Minimum Spanning Trees
Minimum spanning tree Shortest path algorithms
Greedy Algorithms Comp 122, Spring 2004.
Lecture 12 Algorithm Analysis
Total running time is O(E lg E).
Advanced Algorithms Analysis and Design
Binhai Zhu Computer Science Department, Montana State University
Chapter 23: Minimum Spanning Trees: A graph optimization problem
Minimum Spanning Trees
Presentation transcript:

1.1 Data Structure and Algorithm Lecture 13 Minimum Spanning Trees Topics Reference: Introduction to Algorithm by Cormen Chapter 13: Minimum Spanning Trees

1.2 Data Structure and Algorithm Minimum Spanning Tree(MST) In circuit design, sometimes we need to make short some of the pins of the circuit by connecting them with wire. To interconnect a set of n pins, we can use an arrangement of n-1 wires, each connecting 2 pins. Of all arrangements, the one that uses the least amount of wire is usually the most desirable. We can model this wiring problem with a connected, undirected weighted graph G(V,E). We will find an acyclic subset T from E that connects all the vertices and whose total weight is minimized. Since T is acyclic and connects all vertices, it is called a spanning tree. The spanning tree which has minimum weight is called minimum spanning tree.

1.3 Data Structure and Algorithm Spanning Tree Example A connected, undirected Graph Many possible Spanning tree

1.4 Data Structure and Algorithm Minimum Spanning Tree Example A weighted Graph Minimum Spanning tree

1.5 Data Structure and Algorithm Some Definition A cut ( S, V-S ) of an undirected graph G =(V,E) is a partition of V. An edge (u,v) crosses the cut ( S, V-S ) if one of its endpoints is in S and the other is in V-S A cut respects the set A of edges if no edge in A crosses the cut. An edge is a light edge crossing a cut if its weight is the minimum of any edge crossing the cut S V-S

1.6 Data Structure and Algorithm Generic MST Generic_MST(G,w)  A = 0 //empty set  while A does not form a spanning tree do  find an edge (u,v) that is safe for A  A = A U {(u,v)}  return A

1.7 Data Structure and Algorithm Kruskal’s Algorithm This is a greedy algorithm. A greedy algorithm chooses some local optimum (ie. picking an edge with the least weight in a MST). Kruskal's algorithm works as follows:  Take a graph with 'n' vertices, keep adding the shortest (least cost) edge, while avoiding the creation of cycles, until (n - 1) edges have been added.  NOTE: Sometimes two or more edges may have the same cost. The order in which the edges are chosen, in this case, does not matter. Different MSTs may result, but they will all have the same total cost, which will always be the minimum cost

1.8 Data Structure and Algorithm Kruskal’s Algorithm Example(1)

1.9 Data Structure and Algorithm Kruskal’s Algorithm Example(2)

1.10 Data Structure and Algorithm Kruskal’s Algorithm Example(3)

1.11 Data Structure and Algorithm Kruskal’s Algorithm Example(4)

1.12 Data Structure and Algorithm Kruskal’s Algorithm Example(5)

1.13 Data Structure and Algorithm Kruskal’s Algorithm Example(6)

1.14 Data Structure and Algorithm Kruskal’s Algorithm Example(7)

1.15 Data Structure and Algorithm Kruskal’s Algorithm Example(8)

1.16 Data Structure and Algorithm Kruskal’s Algorithm Example(9)

1.17 Data Structure and Algorithm Kruskal’s Algorithm Example(10)

1.18 Data Structure and Algorithm Kruskal’s Algorithm Example(11)

1.19 Data Structure and Algorithm Kruskal’s Algorithm Example(12)

1.20 Data Structure and Algorithm Kruskal’s Algorithm Example(13)

1.21 Data Structure and Algorithm Kruskal’s Algorithm Example(14)

1.22 Data Structure and Algorithm Kruskal’s Algorithm MST_KRUSKAL ( G, w )  A = 0 //empty set  for each vertex of V[G] do  Make_Set(v)  Sort the edges of E by nondecreasing weight w  for each edge (u,v) of E, in order by nondecreasing weight do  if Find_Set(u) <> Find_Set(v) then  A = A U {(u,v)}  Union (u,v)  return A

1.23 Data Structure and Algorithm Prim’s Algorithm This algorithm builds the MST one vertex at a time. It starts at any vertex in a graph (vertex A, for example), and finds the least cost vertex (vertex B, for example) connected to the start vertex. Now, from either 'A' or 'B', it will find the next least costly vertex connection, without creating a cycle (vertex C, for example). Now, from either 'A', 'B', or 'C', it will find the next least costly vertex connection, without creating a cycle, and so on it goes. Eventually, all the vertices will be connected, without any cycles, and an MST will be the result. NOTE: Two or more edges may have the same cost, so when there is a choice by two or more vertices that is exactly the same, then one will be chosen, and an MST will still result

1.24 Data Structure and Algorithm Prim’s Algorithm Example(1)

1.25 Data Structure and Algorithm Prim’s Algorithm Example(2)

1.26 Data Structure and Algorithm Prim’s Algorithm Example(3)

1.27 Data Structure and Algorithm Prim’s Algorithm Example(4)

1.28 Data Structure and Algorithm Prim’s Algorithm Example(5)

1.29 Data Structure and Algorithm Prim’s Algorithm Example(6)

1.30 Data Structure and Algorithm Prim’s Algorithm Example(7)

1.31 Data Structure and Algorithm Prim’s Algorithm Example(8)

1.32 Data Structure and Algorithm Prim’s Algorithm Example(9)

1.33 Data Structure and Algorithm Prim’s Algorithm MST_PRIM (G,w,r) // r = starting node  Q = V[G] //priority queue containing vertex  for each u of Q do  key[u] = infinite  key[r] = 0  pre[r] = NIL //pre = parent  while Q is not empty do  u = ExtractMin(Q)  for each v of Adj[u] do  if v in Q and w(u,v) <key[v] then  pre[v] = u  key[v] = w(u,v)