Minimum Spanning Trees

Slides:



Advertisements
Similar presentations
O(N 1.5 ) divide-and-conquer technique for Minimum Spanning Tree problem Step 1: Divide the graph into  N sub-graph by clustering. Step 2: Solve each.
Advertisements

IKI 10100: Data Structures & Algorithms Ruli Manurung (acknowledgments to Denny & Ade Azurat) 1 Fasilkom UI Ruli Manurung (Fasilkom UI)IKI10100: Lecture10.
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.
1 Greedy 2 Jose Rolim University of Geneva. Algorithmique Greedy 2Jose Rolim2 Examples Greedy  Minimum Spanning Trees  Shortest Paths Dijkstra.
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:
Chapter 9: Greedy Algorithms The Design and Analysis of Algorithms.
Minimum-Cost Spanning Tree weighted connected undirected graph spanning tree cost of spanning tree is sum of edge costs find spanning tree that has minimum.
Minimum Spanning Trees CIS 606 Spring Problem A town has a set of houses and a set of roads. A road connects 2 and only 2 houses. A road connecting.
Spanning Trees. Spanning trees Suppose you have a connected undirected graph –Connected: every node is reachable from every other node –Undirected: edges.
Minimum Spanning Trees
Minimum Spanning Trees. Subgraph A graph G is a subgraph of graph H if –The vertices of G are a subset of the vertices of H, and –The edges of G are a.
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.
Minimum Spanning Tree Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
Midwestern State University Minimum Spanning Trees Definition of MST Generic MST algorithm Kruskal's algorithm Prim's algorithm 1.
1.1 Data Structure and Algorithm Lecture 13 Minimum Spanning Trees Topics Reference: Introduction to Algorithm by Cormen Chapter 13: Minimum Spanning Trees.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Graph Algorithms: Minimum.
WEIGHTED GRAPHS. Weighted Graphs zGraph G = (V,E) such that there are weights/costs associated with each edge Õw((a,b)): cost of edge (a,b) Õrepresentation:
CS 146: Data Structures and Algorithms July 21 Class Meeting
0 Course Outline n Introduction and Algorithm Analysis (Ch. 2) n Hash Tables: dictionary data structure (Ch. 5) n Heaps: priority queue data structures.
COSC 2007 Data Structures II Chapter 14 Graphs III.
Spanning Trees Introduction to Spanning Trees AQR MRS. BANKS Original Source: Prof. Roger Crawfis from Ohio State University.
Dijkstra’s Algorithm. Announcements Assignment #2 Due Tonight Exams Graded Assignment #3 Posted.
Module 5 – Networks and Decision Mathematics Chapter 23 – Undirected Graphs.
Minimum Spanning Trees CS 146 Prof. Sin-Min Lee Regina Wang.
Lecture19: Graph III Bohyung Han CSE, POSTECH CSED233: Data Structures (2014F)
1 Prim’s algorithm. 2 Minimum Spanning Tree Given a weighted undirected graph G, find a tree T that spans all the vertices of G and minimizes the sum.
CSCI2100 Data Structures Tutorial 12
Minimum- Spanning Trees
Graphs Upon completion you will be able to:
Prims Algorithm for finding a minimum spanning tree
Design and Analysis of Algorithms - Chapter 91 Greedy algorithms Optimization problems solved through a sequence of choices that are: b feasible b locally.
Lecture 12 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
Midwestern State University Minimum Spanning Trees Definition of MST Generic MST algorithm Kruskal's algorithm Prim's algorithm 1.
Chapter 9 : Graphs Part II (Minimum Spanning Trees)
Single-Source Shortest Paths
Minimum Spanning Tree Chapter 13.6.
Minimum Spanning Trees
Lecture 22 Minimum Spanning Tree
Minimum Spanning Trees
Lecture 12 Algorithm Analysis
Short paths and spanning trees
Graph Algorithm.
Minimum-Cost Spanning Tree
Minimum Spanning Trees
Connected Components Minimum Spanning Tree
Spanning Trees.
Minimum-Cost Spanning Tree
Data Structures – LECTURE 13 Minumum spanning trees
Chapter 23 Minimum Spanning Tree
Minimum-Cost Spanning Tree
Kruskal’s Minimum Spanning Tree Algorithm
Lecture 12 Algorithm Analysis
Minimum Spanning Tree Algorithms
CSCI2100 Data Structures Tutorial
Minimum Spanning Trees
Networks Kruskal’s Algorithm
Minimum Spanning Tree.
Minimum Spanning Trees
Fundamental Structures of Computer Science II
Lecture 14 Shortest Path (cont’d) Minimum Spanning Tree
Weighted Graphs & Shortest Paths
CSC 380: Design and Analysis of Algorithms
Minimum spanning trees
Lecture 12 Algorithm Analysis
Prim’s algorithm for minimum spanning trees
Lecture 14 Minimum Spanning Tree (cont’d)
Lecture 13 Shortest Path (cont’d) Minimum Spanning Tree
Minimum-Cost Spanning Tree
Presentation transcript:

Minimum Spanning Trees

Example Application for MST Minimum Spanning Tree for Electrical wiring

Spanning Trees Connected and having no cycles. A graph having more than V – 1 edges contains at least one cycle.

Minimum Spanning Tree (MST) What is minimum spanning tree? A tree that covers (spans) all the vertices of a connected graph which has the minimum total cost of edges in the tree. A MST exists for a graph iff the graph is connected. The same problem makes sense for directed graphs too, but the solution is more difficult.

Minimum Spanning Tree (MST) Our problem is finding a minimum spanning tree in an undirected and connected graph.

Example: Minimum Spanning Tree v1 2 v2 4 1 3 10 2 v3 v4 7 v5 8 4 5 6 v6 1 v7 Example undirected and connected graph v1 v2 v5 v3 v6 v7 2 1 4 6 v4 The corresponding minimum spanning tree

Properties: Minimum Spanning Tree If the number of vertices of a connected undirected graph is |V|, then its minimum spanning tree will have |V| vertices |V| - 1 edges. A MST does not contain any cycle, since it is a tree. If we add an extra edge to a MST, then it will have a cycle.

Example Application for MST power outlet or light Electrical wiring of a house using minimum amount of wires (cables)

Example Application for MST Minimum Spanning Tree for Electrical wiring

Prim’s Algorithm for MST MST is constructed in successive stages. At each stage: A new vertex is added to the tree by choosing the edge (u,v) such that the cost of (u,v), w(u,v), is the smallest among all edges where u is in the tree and v is not.

1 2 3 4 5 6 7

6 8 5 3 7 9 15

Prim’s Algorithm: Example Start with vertex v1. It is the initial current tree which we will grow to an MST V1 0 V4 1 V2 2 V3 4 V6  v1 v2 v5 v3 v6 v7 4 2 1 5 8 7 3 10 6 v4 Content of the priority queue A connected, undirected graph G is given above.

Prim’s Algorithm: Example Select an edge from graph: that is not in the current tree, that has the minimum cost, and that can be connected to the current tree. Step 1 v1 v2 v5 v3 v6 v7 4 2 1 5 8 7 3 10 6 v4 V4 1 V2 2 V3 4 Content of the priority queue

Prim’s Algorithm: Example The edges that can be connected are: (v1,v2): cost 2 (v1,v4): cost 1 (v1,v3): cost 2 Step 1 v1 v2 v5 v3 v6 v7 4 2 1 5 8 7 3 10 6 v4 V4 1 V2 2 V3 4 Content of the priority queue

Prim’s Algorithm: Example We include the vertex v4, that is connected to the selected edge, to the current tree. In this way we grow the tree. Step 2 v1 v2 v5 v3 v6 v7 4 2 1 5 8 7 3 10 6 v4 V2 2 V3 2 V7 4 V5 7 V6 8 Content of the priority queue

Content of the priority queue Prim’s Algorithm Repeat steps: 1, and 2 Add either edge (v4, v3) v1 v2 v5 v3 v6 v7 4 2 1 5 8 7 3 10 6 v4 V3 2 V7 4 V5 7 V6 8 Content of the priority queue

Content of the priority queue Prim’s Algorithm Grow the tree! v1 v2 v5 v3 v6 v7 4 2 1 5 8 7 3 10 6 v4 V7 4 V6 5 V5 7 Content of the priority queue

Content of the priority queue Prim’s Algorithm Add edge (v4, v7) v1 v2 v5 v3 v6 v7 4 2 1 5 8 7 3 10 6 v4 V7 4 V6 5 V5 7 Content of the priority queue

Content of the priority queue Prim’s Algorithm Grow the tree! v1 v2 v5 v3 v6 v7 4 2 1 5 8 7 3 10 6 v4 V6 1 V5 6 Content of the priority queue

Content of the priority queue Prim’s Algorithm Add edge (v7, v6) v1 v2 v5 v3 v6 v7 4 2 1 5 8 7 3 10 6 v4 V6 1 V5 6 Content of the priority queue

Content of the priority queue Prim’s Algorithm Grow the tree! v1 v2 v5 v3 v6 v7 4 2 1 5 8 7 3 10 6 v4 V5 6 Content of the priority queue

Content of the priority queue Prim’s Algorithm Add edge (v7, v5) v1 v2 v5 v3 v6 v7 4 2 1 5 8 7 3 10 6 v4 V5 6 Content of the priority queue

Prim’s Algorithm: Example Grow the tree! v1 v2 v5 v3 v6 v7 4 2 1 5 8 7 3 10 6 v4 Content of the priority queue

Prim’s Algorithm: Example v1 v2 v5 v3 v6 v7 2 1 4 6 v4 Finished! The resulting MST is shown below!

PRIM’s algorithm is similar to the Dijkstra’s shortest path algorithm PRIM’s algorithm is similar to the Dijkstra’s shortest path algorithm. Complexities are the same.