Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Graph Algorithms: Minimum.

Slides:



Advertisements
Similar presentations
Lecture 15. Graph Algorithms
Advertisements

IKI 10100: Data Structures & Algorithms Ruli Manurung (acknowledgments to Denny & Ade Azurat) 1 Fasilkom UI Ruli Manurung (Fasilkom UI)IKI10100: Lecture10.
1 Greedy 2 Jose Rolim University of Geneva. Algorithmique Greedy 2Jose Rolim2 Examples Greedy  Minimum Spanning Trees  Shortest Paths Dijkstra.
Graph Algorithms: Minimum Spanning Tree We are given a weighted, undirected graph G = (V, E), with weight function w:
Minimum Spanning Tree Algorithms
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.
Design and Analysis of Algorithms Minimum Spanning trees
Chapter 9: Graphs Spanning Trees Mark Allen Weiss: Data Structures and Algorithm Analysis in Java Lydia Sinapova, Simpson College.
Minimum Spanning Trees What is a MST (Minimum Spanning Tree) and how to find it with Prim’s algorithm and Kruskal’s algorithm.
Shortest Path Algorithms. Kruskal’s Algorithm We construct a set of edges A satisfying the following invariant:  A is a subset of some MST We start with.
CS 146: Data Structures and Algorithms July 21 Class Meeting
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Graph Algorithms Shortest-Path.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Graph (II) Shortest path, Minimum spanning tree GGuy
2IL05 Data Structures Fall 2007 Lecture 13: Minimum Spanning Trees.
Spring 2015 Lecture 11: Minimum Spanning Trees
0 Course Outline n Introduction and Algorithm Analysis (Ch. 2) n Hash Tables: dictionary data structure (Ch. 5) n Heaps: priority queue data structures.
Minimum Spanning Trees CSE 2320 – Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington 1.
Algorithm Course Dr. Aref Rashad February Algorithms Course..... Dr. Aref Rashad Part: 5 Graph Algorithms.
Spanning Trees CSIT 402 Data Structures II 1. 2 Two Algorithms Prim: (build tree incrementally) – Pick lower cost edge connected to known (incomplete)
Graphs. Definitions A graph is two sets. A graph is two sets. –A set of nodes or vertices V –A set of edges E Edges connect nodes. Edges connect nodes.
Kruskal’s and Dijkstra’s Algorithm.  Kruskal's algorithm is an algorithm in graph theory that finds a minimum spanning tree for a connected weighted.
Minimum spanning trees (MST) Def: A spanning tree of a graph G is an acyclic subset of edges of G connecting all vertices in G. A sub-forest of G is an.
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.
1 Greedy Technique Constructs a solution to an optimization problem piece by piece through a sequence of choices that are: b feasible b locally optimal.
Minimum Spanning Trees CSE 373 Data Structures Lecture 21.
WEEK 12 Graphs IV Minimum Spanning Tree Algorithms.
Spanning Trees Dijkstra (Unit 10) SOL: DM.2 Classwork worksheet Homework (day 70) Worksheet Quiz next block.
Lecture 12 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
Data Structures & Algorithms Graphs Richard Newman based on book by R. Sedgewick and slides by S. Sahni.
Minimum Spanning Trees
Chapter 9 : Graphs Part II (Minimum Spanning Trees)
Introduction to Algorithms
Minimum Spanning Tree Chapter 13.6.
Minimum Spanning Trees
Minimum Spanning Trees and Shortest Paths
Lecture 12 Algorithm Analysis
Short paths and spanning trees
Data Structures & Algorithms Graphs
Graph Algorithm.
Minimum Spanning Trees
Minimum Spanning Tree Neil Tang 3/25/2010
Graph Algorithm.
Minimum Spanning Tree.
CSE373: Data Structures & Algorithms Lecture 12: Minimum Spanning Trees Catie Baker Spring 2015.
CSE373: Data Structures & Algorithms Lecture 20: Minimum Spanning Trees Linda Shapiro Spring 2016.
Minimum Spanning Trees
CSE 373 Data Structures and Algorithms
Minimum-Cost Spanning Tree
Data Structures – LECTURE 13 Minumum spanning trees
Lecture 12 Algorithm Analysis
CSE373: Data Structures & Algorithms Lecture 19: Spanning Trees
Minimum Spanning Tree Algorithms
Shortest Paths and Minimum Spanning Trees
Minimum Spanning Tree Neil Tang 4/3/2008
Minimum Spanning Trees
Minimum Spanning Tree.
Minimum Spanning Trees
Fundamental Structures of Computer Science II
CSE 373: Data Structures and Algorithms
Minimum spanning trees
CSE 417: Algorithms and Computational Complexity
CSE 373: Data Structures and Algorithms
Lecture 12 Algorithm Analysis
Prim’s Minimum Spanning Tree Algorithm Neil Tang 4/1/2008
Algorithm Course Dr. Aref Rashad
Lecture 14 Minimum Spanning Tree (cont’d)
Chapter 9: Graphs Spanning Trees
Minimum Spanning Trees
Presentation transcript:

Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Graph Algorithms: Minimum Spanning Tree

Minimum Spanning Tree Problem Find a minimum-cost set of edges that connect all vertices of a graph at lowest total cost Applications  Connecting “nodes” with a minimum of “wire” Networking Circuit design  Collecting nearby nodes Clustering, taxonomy construction  Approximating graphs Most graph algorithms are faster on trees

Minimum Spanning Tree A tree is an acyclic, undirected, connected graph A spanning tree of a graph is a tree containing all vertices from the graph A minimum spanning tree is a spanning tree, where the sum of the weights on the tree’s edges are minimal

Minimum Spanning Tree (cont’d) Graph: Minimum spanning tree: Dijkstra’s weighted shortest/ minimum cost path problem  Number of edges in MST is |V| - 1  No fixed start vertex like Dijkstra’s  Undirected graph  Minimizing summation of total edge cost instead of finding distinct shortest path

Minimum Spanning Tree (cont’d) Problem  Given an undirected, weighted graph G = (V, E) with weights w(u, v) for each edge (u, v)  E  Find an acyclic, connected graph G’ = (V’, E’), E’  E, that minimizes  (u, v)  E’ w(u, v)  G’ is a minimum spanning tree of G There can be more than one minimum spanning tree of a graph G  Two algorithms Prim’s algorithm Kruskal’s algorithm Differ in how a minimum edge is selected

Minimum Spanning Tree Solution #1 (Prim’s Algorithm (1957))  Start with an empty tree T  T = {x}, where x is an arbitrary node in the input graph  While T is not a spanning tree Find the lowest-weight edge that connects a vertex in T to a vertex not in T Add this edge to T  T will be a minimum spanning tree

Prim’s Algorithm: Example Input graph: Minimum spanning tree:

Prim’s Algorithm Similar to Dijkstra’s shortest-path algorithm Except  v.known = v in T  v.dist = weight of lowest-weight edge connecting v to a known vertex in T  v.path = last neighboring vertex changing (lowering) v’s dist value (same as before)  Undirected graph, so two entries for every edge in the adjacency list

Prim’s Algorithm (cont’d) Running time same as Dijkstra: O(|E| log |V|) using binary heaps

Prim’s Algorithm: Example

Prim’s Algorithm: Example (cont’d) Edges can be read from this final table

Prim’s Algorithm: Analysis Running time = O(|V| 2 ) without heap  Optimal for dense graph O(|E| log |V|) using binary heaps  Good for sparse graph

Minimum Spanning Tree Solution #2 (Kruskal’s algorithm (1956))  Start with T = V (with no edges)  For each edge in increasing order by weight If adding edge to T does not create a cycle Then add edge to T  T will be a minimum spanning tree

Kruskal’s Algorithm: Example Input graph: 1 st 2 nd 3 rd 4 th 5 th 6 th Collection of Trees |V| single-node Trees Algorithm Terminates Now only one Tree It is a MST

Kruskal’s Algorithm Uses Disjoint Set and Priority Queue data structures The edges can be sorted, but building a heap in linear time is a better option deleteMins give the edge to be tested in order deleteMin: O(|V| log |V|) find: O(|E| log |V|)

Kruskal’s Algorithm: Analysis Worst-case: O(|E| log |E|) Since |E| = O(|V| 2 ), worst-case also O(|E| log |V|)  Running time dominated by heap operations Typically terminates before considering all edges, so faster in practice

Summary Finding set of edges that minimally connect all vertices in a graph Fast algorithm with many important applications Utilizes advanced data structures to achieve fast performance