Graph Search Applications, Minimum Spanning Tree

Slides:



Advertisements
Similar presentations
Lecture 15. Graph Algorithms
Advertisements

Graphs CSC 220 Data Structure. Introduction One of the Most versatile data structures like trees. Terminology –Nodes in trees are vertices in graphs.
Discrete Structures Lecture 13: Trees Ji Yanyan United International College Thanks to Professor Michael Hvidsten.
Data Structures & Algorithms Graph Search Richard Newman based on book by R. Sedgewick and slides by S. Sahni.
Discussion #36 Spanning Trees
Graph Algorithms: Minimum Spanning Tree We are given a weighted, undirected graph G = (V, E), with weight function w:
Spanning Trees.
Spanning Trees. 2 Spanning trees Suppose you have a connected undirected graph Connected: every node is reachable from every other node Undirected: edges.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 10 Instructor: Paul Beame.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 11 Instructor: Paul Beame.
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. 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 Trees What is a MST (Minimum Spanning Tree) and how to find it with Prim’s algorithm and Kruskal’s algorithm.
Minimum Spanning Tree in Graph - Week Problem: Laying Telephone Wire Central office.
Graphs CS 400/600 – Data Structures. Graphs2 Graphs  Used to represent all kinds of problems Networks and routing State diagrams Flow and capacity.
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Minimum Spanning Trees
Chapter 14 Graphs. © 2004 Pearson Addison-Wesley. All rights reserved Terminology G = {V, E} A graph G consists of two sets –A set V of vertices,
COSC 2007 Data Structures II Chapter 14 Graphs III.
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.
1 Minimum Spanning Trees (some material adapted from slides by Peter Lee, Ananda Guna, Bettina Speckmann)
Union-Find  Application in Kruskal’s Algorithm  Optimizing Union and Find Methods.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 13: Graphs Data Abstraction & Problem Solving with C++
© 2006 Pearson Addison-Wesley. All rights reserved 14 A-1 Chapter 14 Graphs.
Minimum- Spanning Trees
© 2006 Pearson Addison-Wesley. All rights reserved14 B-1 Chapter 14 (continued) Graphs.
Breadth-First Search (BFS)
Graphs Representation, BFS, DFS
Introduction to Algorithms
May 12th – Minimum Spanning Trees
Minimum Spanning Tree Chapter 13.6.
Programming Abstractions
Spanning Trees.
C.Eng 213 Data Structures Graphs Fall Section 3.
Lecture 12 Graph Algorithms
Lecture 12 Algorithm Analysis
CISC 235: Topic 10 Graph Algorithms.
I206: Lecture 15: Graphs Marti Hearst Spring 2012.
CS120 Graphs.
Short paths and spanning trees
Graph Search Applications
Graph Algorithm.
Graphs Representation, BFS, DFS
Minimum Spanning Tree.
Connected Components Minimum Spanning Tree
Graph Algorithm.
Minimum Spanning Tree.
Minimum Spanning Tree.
CSE 373 Data Structures and Algorithms
Spanning Trees.
Chapter 11 Graphs.
Spanning Trees Longin Jan Latecki Temple University based on slides by
Minimum Spanning Trees
Strongly Connected Components
Minimum Spanning Tree.
CSE 373: Data Structures and Algorithms
Weighted Graphs & Shortest Paths
Chapter 16 1 – Graphs Graph Categories Strong Components
Minimum spanning trees
CSE 417: Algorithms and Computational Complexity
Bridges and Articulation Points
Minimum Spanning Trees (MSTs)
CSE 373: Data Structures and Algorithms
Lecture 12 Algorithm Analysis
Chapter 14 Graphs © 2011 Pearson Addison-Wesley. All rights reserved.
CSE 373: Data Structures and Algorithms
Lecture 23: Minimum Spanning Trees
INTRODUCTION A graph G=(V,E) consists of a finite non empty set of vertices V , and a finite set of edges E which connect pairs of vertices .
Minimum Spanning Trees
Presentation transcript:

Graph Search Applications, Minimum Spanning Tree

Classifying Back Edges Run DFS, but also keep a third state: Unvisited (never started visiting) Exploring (began processing neighbors, but not done) Visited (visited and explored all neighbors) A “Back Edge” goes from current node to an Exploring node (or a Visited node, if a directed graph) Can be used to find cycles (back edges that aren’t a single undirected edge)

Articulation Points and Bridges Find a vertex or an edge that when removed will disconnect the graph Option 1: naïve approach Calculate the number of connected components Try, one-by-one, removing each edge/vertex Recalculate number of CCs If more CCs, then it’s an articulation point or bridge.

Articulation Points and Bridges Find a vertex or an edge that when removed will disconnect the graph Option 2: specialized algorithm Compute DFS, but also store two values per node: Num: the order in which the node was reached during DFS Low: lowest Num reachable from current subtree Update Low when you have a back edge If a neighbor vertex has a Low value greater or equal to your own Num, then you’re at an articulation point If Low(u) > Num (v), then u-v is a bridge Likewise, if Low(v) > Num (u), then u-v is a bridge

Strongly Connected Components (Directed) Notice: can replace a SCC by a single node, and result is a directed acyclic graph. Perform DFS like before. SCCs are identified when a back edge creates a cycle (and therefore connects everything in that subtree. Update Low only for Visited (not Exploring) vertices. Add each node to a stack When you finish a node where Num == Low, it marks the root of a SCC Pop nodes off the stack until you get that node off; those nodes are a SCC

Minimum Spanning Tree Weight on edge; find set of edges that minimize connecting everything Kruskal’s algorithm: Sort edges from lowest weight to highest Add edges by doing a union-find set combination each Done when you have just one set (i.e. have added n-1 edges, thus joining all n vertices)

Minimum Spanning Tree Weight on edge; find set of edges that minimize connecting everything Prim’s algorithm: For each node, mark as “in” or “out”. Start with any node as the only one “in” Priority queue of edges, based on weight. Add the edges for the “in” node Repeatedly get next edge from queue. If one of the nodes is “out”, then: Mark that node “in” Add its edges to the priority queue.

MST variants Maximum spanning tree Minimum subgraph Use Kruskal’s with edges sorted greatest to smallest Minimum subgraph Run Kruskal’s but with some stuff already merged Minimum forest (can have up to x components) Run Kruskal’s until just x sets Second-best tree Get MST, then try removing a link, and find first link to connect Repeat for all links Minimax – minimum of maximum edge weights along a path i to j Just a subset of the MST – path from i to j in the MST.