Strongly Connected Components. Andreas Klappenecker

Similar documents
CSE 101. Algorithm Design and Analysis Miles Jones and Russell Impagliazzo Miles Office 4208 CSE Building

CSE 101. Algorithm Design and Analysis Miles Jones Office 4208 CSE Building Lecture 5: SCC/BFS

Graph Algorithms. Andreas Klappenecker. [based on slides by Prof. Welch]

CS483 Design and Analysis of Algorithms

CS 361 Data Structures & Algs Lecture 15. Prof. Tom Hayes University of New Mexico

Graph Algorithms Using Depth First Search

Design and Analysis of Algorithms

22.3 Depth First Search

DFS & STRONGLY CONNECTED COMPONENTS

Proof: if not f[u] < d[v], then u still grey while v is being visited. DFS visit(v) will then terminate before DFS visit(u).

Design and Analysis of Algorithms

Elementary Graph Algorithms

Strongly Connected Components

Algorithm Design and Analysis

Topic 12: Elementary Graph Algorithms

Lecture 10 Graph algorithms: testing graph properties

1 Connected components in undirected graphs

CS 473: Algorithms. Chandra Chekuri 3228 Siebel Center. Fall University of Illinois, Urbana-Champaign

Depth First Search (DFS)

Lecture 3: Graphs and flows

Finding Strongly Connected Components

NP Completeness. Andreas Klappenecker [partially based on slides by Jennifer Welch]

Lecture 22 Tuesday, April 10

Graph Representations and Traversal

Graphs. A graph is a data structure consisting of nodes (or vertices) and edges. An edge is a connection between two nodes

Lecture 10. Finding strongly connected components

Graph Algorithms. Andreas Klappenecker

(Re)Introduction to Graphs and Some Algorithms

CS473-Algorithms I. Lecture 13-A. Graphs. Cevdet Aykanat - Bilkent University Computer Engineering Department

Algorithms and Data Structures

Algorithms and Data Structures

Fundamental Graph Algorithms Part Four

Digital Logic Design: a rigorous approach c

Info 2950, Lecture 16

1 Start with each vertex being its own component. 2 Merge two components into one by choosing the light edge

Lecture 10: Analysis of Algorithms (CS ) 1

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

CISC 320 Introduction to Algorithms Fall Lecture 15 Depth First Search

Graph Representation

Depth First Search (DFS)

Graph Algorithms. Chapter 22. CPTR 430 Algorithms Graph Algorithms 1

15-451/651: Design & Analysis of Algorithms October 5, 2017 Lecture #11: Depth First Search and Strong Components last changed: October 17, 2017

Practical Session No. 12 Graphs, BFS, DFS Topological Sort

Representations of Graphs

Maximum Flow. Flow Networks. Flow Networks Ford-Fulkerson Method Edmonds-Karp Algorithm Push-Relabel Algorithms. Example Flow Network

GRAPHS Lecture 19 CS2110 Spring 2013

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

Chapter 22. Elementary Graph Algorithms

Graphs. 04/01/03 Lecture 20 1

Graph. Vertex. edge. Directed Graph. Undirected Graph

Depth-first search in undirected graphs What parts of the graph are reachable from a given vertex?

(Refer Slide Time: 05:25)

Outline. Graphs. Divide and Conquer.

CS2 Algorithms and Data Structures Note 10. Depth-First Search and Topological Sorting

CSE 373 NOVEMBER 20 TH TOPOLOGICAL SORT

Taking Stock. IE170: Algorithms in Systems Engineering: Lecture 17. Depth-First Search. DFS (Initialize and Go) Last Time Depth-First Search

Cut vertices, Cut Edges and Biconnected components. MTL776 Graph algorithms

Directed Graphs (II) Hwansoo Han

Strongly connected: A directed graph is strongly connected if every pair of vertices are reachable from each other.

Algorithms (VII) Yijia Chen Shanghai Jiaotong University

Minimum Spanning Trees My T. UF

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

Homework Assignment #3 Graph

Algorithm Design and Analysis

Practical Session No. 12 Graphs, BFS, DFS, Topological sort

Chapter 22 Elementary Graph Algorithms

More Graph Algorithms

COL351: Analysis and Design of Algorithms (CSE, IITD, Semester-I ) Name: Entry number:

Algorithms (VII) Yijia Chen Shanghai Jiaotong University

Lecture 10: Strongly Connected Components, Biconnected Graphs

Strong Bridges and Strong Articulation Points of Directed Graphs

Directed Acyclic Graphs && Topological Sorting. by Tian Cilliers IOI Training Camp 2 (3-4 February 2018)

CSE 332: Data Abstractions Lecture 15: Topological Sort / Graph Traversals. Ruth Anderson Winter 2013

Fundamental Graph Algorithms Part Three

CS Elementary Graph Algorithms

CS Elementary Graph Algorithms

Lecture 16: Directed Graphs

Elementary Graph Algorithms CSE 6331

Link to starter code:

CHAPTER 23: ELEMENTARY GRAPH ALGORITHMS Representations of graphs

Part VI Graph algorithms. Chapter 22 Elementary Graph Algorithms Chapter 23 Minimum Spanning Trees Chapter 24 Single-source Shortest Paths

Graph representation

LECTURE NOTES OF ALGORITHMS: DESIGN TECHNIQUES AND ANALYSIS

Advanced Data Management

Introduction to Algorithms

CS 341: Algorithms. Douglas R. Stinson. David R. Cheriton School of Computer Science University of Waterloo. February 26, 2019

Chapter 3. Graphs CLRS Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Graph Algorithms (part 3 of CSC 282),

Question Points Score TOTAL 50

ECE250: Algorithms and Data Structures Single Source Shortest Paths Bellman-Ford Algorithm

CS 220: Discrete Structures and their Applications. graphs zybooks chapter 10

Data Structures and Algorithms. Chapter 7. Graphs

CS4800: Algorithms & Data Jonathan Ullman

W4231: Analysis of Algorithms

CS170 Discussion Section 4: 9/18

Lecture 10. Elementary Graph Algorithm Minimum Spanning Trees

3.1 Basic Definitions and Applications

Exercise 1. D-ary Tree

CSE101: Design and Analysis of Algorithms. Ragesh Jaiswal, CSE, UCSD

Algorithm Design and Analysis

Transcription:

Strongly Connected Components Andreas Klappenecker

Undirected Graphs An undirected graph that is not connected decomposes into several connected components. Finding the connected components is easily solved using DFS. Each restart finds a new component - done!

Directed Graphs In a directed graph G=(V,E), two nodes u and v are strongly connected if and only if there is a path from u to v and a path from v to u. The strongly connected relation is an equivalence relation. Its equivalence classes are the strongly connected components.

Directed Graphs In a directed graph G=(V,E), two nodes u and v are strongly connected if and only if there is a path from u to v and a path from v to u. The strongly connected relation is an equivalence relation. Its equivalence classes are the strongly connected components. Every node is in precisely one strongly connected component, since the equivalence classes partition the set of nodes.

Component Graph Take a directed graph G=(V,E) and let be the strongly connected relation. Then we can define a graph G scc = (V/, E ), where the nodes are the strongly connected components of G and there is an edge from component C to component D iff there is an edge in G from a vertex in C to a vertex in D.

Component Graph Take a directed graph G=(V,E) and let be the strongly connected relation. Then we can define a graph G scc = (V/, E ), where the nodes are the strongly connected components of G and there is an edge from component C to component D iff there is an edge in G from a vertex in C to a vertex in D.

Directed Graphs Let G be a directed graph. Then G scc is a directed acyclic graph. [Indeed, the components in a cycle would have been merged into single equivalence class.] Interesting decomposition of G: G scc is a directed acyclic graph, and each node is a strongly connected component of G.

Terminology In a directed acyclic graph, a node of in-degree 0 is called a source node and a node of out-degree 0 is called a sink node. Each directed acyclic graph has at least one source node and at least one sink node.

Property 1 If depth-first search of a graph is started at node u, then it will get stuck and restarted precisely when all nodes that are reachable from u are visited. In particular, if we start depth-first search at a node v in G that is in a component C that happens to be a sink in G scc, then it will get stuck precisely after visiting all the nodes of C. Thus, we have a way of enumerating a strongly connected component given that it is a sink component.

Property 2 The node v in G with the highest final[v] timestamp in depth-first search belongs to a start component in G scc.

Property 2 The node v in G with the highest final[v] timestamp in depth-first search belongs to a start component in G scc. We wanted to find a sink component, but we merely found a way to find a node in a start component.

Reversed Graph Trick Given the graph G=(V,E) consider its reversed graph G R =(V,E R ) with E R = { (u,v) (v,u) in E }, so all edges are reversed. Then G R has the same strongly connected components as G. If we apply depth first search to G R, then the node v with the largest finishing time belongs to a component that is a sink in G scc.

Property 3 Let C and D be strongly connected components of a graph. Suppose that there is an edge from a node in C to a node in D. Then the vertex in C that is visited first by depth first search has larger final[v] than any vertex in D. C D

Corollary Arranging the strongly connected components of a directed graph in decreasing order of the highest finish time in each component topologically sorts the strongest connected components of the graph. [Well, this is just topological sorting applied to the directed acyclic graph G scc.]

SCC Algorithm 1) Perform depth first search on G R. 2) Perform depth first search on G in decreasing order of the final times computer in step 1). Complexity: O(V+E)

Example G a c d b e G R 1/6 a c 2/5 d 7/10 3/4 b e 8/9 Order by decreasing finishing time: d, e, a, c, b.

Example Order by decreasing finishing time: d, e, a, c, b. G a c d b e Run DFS on G (use above order from G R ): {d, e}, {a, b, c}.

Example Order by decreasing finishing time: d, e, a, c, b. G a c d b e Run DFS on G (use above order from G R ): {d, e}, {a, b, c}.

References I followed lecture notes by Umesh Vazirani in the preparation of these slides.