Strongly Connected Components
|
|
- Malcolm Pierce
- 6 years ago
- Views:
Transcription
1 Strongly Connected Components Let G = (V, E) be a directed graph Write if there is a path from to in G Write if and is an equivalence relation: implies and implies s equivalence classes are called the strongly connected components (SCC s) of G For V, C( ) := s SCC 1
2 The component graph Idea: collapse each SCC s into a single node Formally: component graph G scc = (V scc, E scc ) V scc = the SCC s C 1,..., C k of G E scc = {(C, C j ) : = j, (, ) E for some C, C j } G : G scc : a b c d a b c d e f g h e f g h 2
3 Lemma 1. in G C( ) C( ) in G scc 3
4 Lemma 2. G scc is acyclic. Suppose there is a cycle. By definition, no self loops in G scc, so the cycle must contain two distinct nodes, say C( ) and C( ) Then we have C( ) C( ) and C( ) C( ) in G scc By Lemma 1, and in G Thus, C( ) = C( ) QED 4
5 An application Scheduling with constraints: We want to schedule a set of tasks Each task is represented by a node in a directed graph G Edges in G represent scheduling constraints: if and are distinct tasks, there is a path from to in G, and both and are performed, then must be performed before Each task has a profit associated with it: we want to schedule tasks to maximize profit 5
6 A solution: 1. Compute component graph, topologically sorted 2. For each SCC, select the task with maximum profit 3. Output the tasks from Step 2 in topological order G : G scc : a b c d a b c d e f g h e f g h Profits: = 1, b = 2, c = 3, etc. Optimal schedule: e, d, g, h 6
7 Special case: G is undirected (, ) E (, ) E SCC s are just called connected components The component graph consists of isolated nodes no edges between components Easy to compute: the trees in the DFS forest are the connected components 7
8 Computing SCC s: the Kosaraju/Sharir Algorithm For a graph G, let G T denote its transpose or reverse same as G but with all edges reversed G and G T have the same SCC s in fact, (G T ) scc = (G scc ) T Algorithm SCC(G): 1. call DFS(G), and order the nodes 1,..., n in order of decreasing finishing time (as in DFSTopSort) 2. compute G T 3. call DFS(G T ) but in the top-level loop, process in the order 1,..., n the trees in the DFS forest are the SCC s of G Running time: O( V + E ) 8
9 Example: G : 13/14 11/16 1/10 8/9 12/15 3/4 2/7 5/6 G T : 13/14 11/16 1/10 8/9 12/15 3/4 2/7 5/6 G T : 13/14 11/16 1/10 8/9 12/15 3/4 2/7 5/6 G T : 13/14 11/16 1/10 8/9 12/15 3/4 2/7 5/6 G T : 13/14 11/16 1/10 8/9 G T : 13/14 11/16 1/10 8/9 12/15 3/4 2/7 5/6 12/15 3/4 2/7 5/6 G scc : 13/14 11/16 1/10 8/9 12/15 3/4 2/7 5/6 9
10 Notation: let ƒ [ ] be the finish time in the first DFS, and let ƒ (U) := m x{ƒ [ ] : U} Lemma 3. Suppose (C, C ) E scc. Then ƒ (C) > ƒ (C ) Proof. In the first DFS, let be the first node discovered in C C Case 1: C C C By the White Path Theorem, all nodes in C C are descendents of in the DFS forest By the Parenthesis Theorem, ƒ [ ] = ƒ (C) > ƒ (C ) 10
11 Case 2: C C C By the White Path Theorem, all nodes in C are descendents of in the DFS forest By Lemma 2, there is no path from C to C in G scc, and so no node in C is reachable from so at time ƒ [ ], all nodes in C are still white ƒ (C) > ƒ [ ] = ƒ (C ). QED 11
12 Theorem. Algorithm SCC is correct. Proof. Let T 1,..., T l be the trees of the DFS forest created in step 3 Let C 1,..., C k be the SCC s, with ƒ (C ) > ƒ (C +1 ) G scc : C 1 C 2 C3 C 4 (G scc ) T : C 1 C 2 C3 C 4 12
13 (G scc ) T : C 1 C 2 C3 C 4 At step 3, we start with a vertex 1 in C 1 By White Path Theorem, all nodes in C 1 will be in T 1 By Lemma 3, in G T, there are no edges leaving C 1 the nodes of C 1 are exactly the nodes of T 1 13
14 (G scc ) T : C 1 C 2 C3 C 4 Next, we pick a node in C 2, and at this time, all nodes in C 1 are black, and all nodes in C 2,..., C k are white By White Path Theorem, T 2 contains all nodes in C 2, and by Lemma 3, T 2 contains no other nodes the nodes of C 2 are exactly the nodes of T 2 Proceeding by induction, we get T = C for = 1,..., l, and so k = l. QED 14
15 Representation of G scc Let C 1,..., C k be the SCC s Number the nodes 1.. k Standard adjacency list representation of G scc Also: An array mapping V to j {1,..., k}, where C j An array mapping j {1..., k} to a list representation of C j This can all be done in time O( V + E ), and we may assume that C 1,..., C k are already in topological order in fact Algorithm SCC outputs C 1,..., C k in topological order 15
16 Another application Problem: A graph G = (V, E) is called semi-connected if for all, V, or. Show how to test if G is semi-connected in time O( V + E ) 16
17 First consider the problem for DAG s Let 1,..., n be a topological sort of G Claim: G is semi-connected there is an edge +1 for each = 1.. n
18 Now consider a general graph Claim: G is semi-connected G scc is semi-connected (follows directly from Lemma 1) Algorithm: 1. Run algorithm SCC to get G scc (which is a DAG) 2. Test if G scc is semi-connected (as above) General principle: Try to reduce questions about graphs to questions about DAG s. 18
19 Another application Consider the gathering coins problem for a general directed graph Given a directed graph G = (V, E) On each node there are N[ ] coins Goal: find the max number of coins that can be gathered on any one path through G The path need not be simple, but once you pick up the coins on a node, they are gone 19
20 We already know how to solve this for a DAG For a general graph, we start by computing G scc For each SCC C, we assign to it C N[ ] coins Now run the DAG algorithm on G scc 20
Design and Analysis of Algorithms
Design and Analysis of Algorithms CS 5311 Lecture 19 Topological Sort Junzhou Huang, Ph.D. Department of Computer Science and ngineering CS5311 Design and Analysis of Algorithms 1 Topological Sort Want
More informationProof: 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).
Parenthesis property of DFS discovery and finishing times (Thm 23.6 of CLR): For any two nodes u,v of a directed graph, if d[u] < d[v] (i.e. u discovered before v), either f[v] < f[u] (i.e. visit time
More informationInf 2B: Graphs II - Applications of DFS
Inf 2B: Graphs II - Applications of DFS Kyriakos Kalorkoti School of Informatics University of Edinburgh Reminder: Recursive DFS Algorithm dfs(g) 1. Initialise Boolean array visited by setting all entries
More informationGraph Representation
Graph Representation Adjacency list representation of G = (V, E) An array of V lists, one for each vertex in V Each list Adj[u] contains all the vertices v such that there is an edge between u and v Adj[u]
More informationComputer Science & Engineering 423/823 Design and Analysis of Algorithms
s of s Computer Science & Engineering 423/823 Design and Analysis of Lecture 03 (Chapter 22) Stephen Scott (Adapted from Vinodchandran N. Variyam) 1 / 29 s of s s are abstract data types that are applicable
More informationComputer Science & Engineering 423/823 Design and Analysis of Algorithms
Computer Science & Engineering 423/823 Design and Analysis of Algorithms Lecture 04 Elementary Graph Algorithms (Chapter 22) Stephen Scott (Adapted from Vinodchandran N. Variyam) sscott@cse.unl.edu Introduction
More informationAlgorithm Design and Analysis
Algorithm Design and Analysis LECTURE 5 Graphs Applications of DFS Topological sort Strongly connected components Sofya Raskhodnikova S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith,
More informationFinding Strongly Connected Components
Yufei Tao ITEE University of Queensland We just can t get enough of the beautiful algorithm of DFS! In this lecture, we will use it to solve a problem finding strongly connected components that seems to
More informationDFS & STRONGLY CONNECTED COMPONENTS
DFS & STRONGLY CONNECTED COMPONENTS CS 4407 Search Tree Breadth-First Search (BFS) Depth-First Search (DFS) Depth-First Search (DFS) u d[u]: when u is discovered f[u]: when searching adj of u is finished
More informationBasic Graph Algorithms
Basic Graph Algorithms 1 Representations of Graphs There are two standard ways to represent a graph G(V, E) where V is the set of vertices and E is the set of edges. adjacency list representation adjacency
More information22.3 Depth First Search
22.3 Depth First Search Depth-First Search(DFS) always visits a neighbour of the most recently visited vertex with an unvisited neighbour. This means the search moves forward when possible, and only backtracks
More informationGraph representation
Graph Algorithms 1 Graph representation Given graph G = (V, E). May be either directed or undirected. Two common ways to represent for algorithms: 1. Adjacency lists. 2. Adjacency matrix. When expressing
More informationStrongly connected: A directed graph is strongly connected if every pair of vertices are reachable from each other.
Directed Graph In a directed graph, each edge (u, v) has a direction u v. Thus (u, v) (v, u). Directed graph is useful to model many practical problems (such as one-way road in traffic network, and asymmetric
More informationGraph Algorithms. Chapter 22. CPTR 430 Algorithms Graph Algorithms 1
Graph Algorithms Chapter 22 CPTR 430 Algorithms Graph Algorithms Why Study Graph Algorithms? Mathematical graphs seem to be relatively specialized and abstract Why spend so much time and effort on algorithms
More informationElementary Graph Algorithms
Elementary Graph Algorithms Representations Breadth-First Search Depth-First Search Topological Sort Strongly Connected Components CS 5633 Analysis of Algorithms Chapter 22: Slide 1 Graph Representations
More informationCISC 320 Introduction to Algorithms Fall Lecture 15 Depth First Search
IS 320 Introduction to lgorithms all 2014 Lecture 15 epth irst Search 1 Traversing raphs Systematic search of every edge and vertex of graph (directed or undirected) fficiency: each edge is visited no
More informationGraph Algorithms. Andreas Klappenecker. [based on slides by Prof. Welch]
Graph Algorithms Andreas Klappenecker [based on slides by Prof. Welch] 1 Directed Graphs Let V be a finite set and E a binary relation on V, that is, E VxV. Then the pair G=(V,E) is called a directed graph.
More information1 Connected components in undirected graphs
Lecture 10 Connected components of undirected and directed graphs Scribe: Luke Johnston (2016) and Mary Wootters (2017) Date: October 25, 2017 Much of the following notes were taken from Tim Roughgarden
More informationLecture 10: Strongly Connected Components, Biconnected Graphs
15-750: Graduate Algorithms February 8, 2016 Lecture 10: Strongly Connected Components, Biconnected Graphs Lecturer: David Witmer Scribe: Zhong Zhou 1 DFS Continued We have introduced Depth-First Search
More informationData Structures. Elementary Graph Algorithms BFS, DFS & Topological Sort
Data Structures Elementary Graph Algorithms BFS, DFS & Topological Sort 1 Graphs A graph, G = (V, E), consists of two sets: V is a finite non-empty set of vertices. E is a set of pairs of vertices, called
More informationAnnouncements. HW3 is graded. Average is 81%
CSC263 Week 9 Announcements HW3 is graded. Average is 81% Announcements Problem Set 4 is due this Tuesday! Due Tuesday (Nov 17) Recap The Graph ADT definition and data structures BFS gives us single-source
More informationDepth First Search (DFS)
Algorithms & Models of Computation CS/ECE 374, Fall 2017 Depth First Search (DFS) Lecture 16 Thursday, October 26, 2017 Sariel Har-Peled (UIUC) CS374 1 Fall 2017 1 / 60 Today Two topics: Structure of directed
More informationTaking Stock. IE170: Algorithms in Systems Engineering: Lecture 17. Depth-First Search. DFS (Initialize and Go) Last Time Depth-First Search
Taking Stock IE170: Algorithms in Systems Engineering: Lecture 17 Jeff Linderoth Department of Industrial and Systems Engineering Lehigh University March 2, 2007 Last Time Depth-First Search This Time:
More informationCS2 Algorithms and Data Structures Note 10. Depth-First Search and Topological Sorting
CS2 Algorithms and Data Structures Note 10 Depth-First Search and Topological Sorting In this lecture, we will analyse the running time of DFS and discuss a few applications. 10.1 A recursive implementation
More informationCSE 331: Introduction to Algorithm Analysis and Design Graphs
CSE 331: Introduction to Algorithm Analysis and Design Graphs 1 Graph Definitions Graph: A graph consists of a set of verticies V and a set of edges E such that: G = (V, E) V = {v 0, v 1,..., v n 1 } E
More informationGraph Algorithms Using Depth First Search
Graph Algorithms Using Depth First Search Analysis of Algorithms Week 8, Lecture 1 Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Graph Algorithms Using Depth
More informationCS 341: Algorithms. Douglas R. Stinson. David R. Cheriton School of Computer Science University of Waterloo. February 26, 2019
CS 341: Algorithms Douglas R. Stinson David R. Cheriton School of Computer Science University of Waterloo February 26, 2019 D.R. Stinson (SCS) CS 341 February 26, 2019 1 / 296 1 Course Information 2 Introduction
More informationChapter 22. Elementary Graph Algorithms
Graph Algorithms - Spring 2011 Set 7. Lecturer: Huilan Chang Reference: (1) Cormen, Leiserson, Rivest, and Stein, Introduction to Algorithms, 2nd Edition, The MIT Press. (2) Lecture notes from C. Y. Chen
More informationPart VI Graph algorithms. Chapter 22 Elementary Graph Algorithms Chapter 23 Minimum Spanning Trees Chapter 24 Single-source Shortest Paths
Part VI Graph algorithms Chapter 22 Elementary Graph Algorithms Chapter 23 Minimum Spanning Trees Chapter 24 Single-source Shortest Paths 1 Chapter 22 Elementary Graph Algorithms Representations of graphs
More informationRepresentations of Graphs
ELEMENTARY GRAPH ALGORITHMS -- CS-5321 Presentation -- I am Nishit Kapadia Representations of Graphs There are two standard ways: A collection of adjacency lists - they provide a compact way to represent
More informationLecture 22 Tuesday, April 10
CIS 160 - Spring 2018 (instructor Val Tannen) Lecture 22 Tuesday, April 10 GRAPH THEORY Directed Graphs Directed graphs (a.k.a. digraphs) are an important mathematical modeling tool in Computer Science,
More informationComputer Science & Engineering 423/823 Design and Analysis of Algorithms
s of s Computer Science & Engineering 423/823 Design and Analysis of Lecture 03 (Chapter 22) Stephen Scott (Adapted from Vinodchandran N. Variyam) 1 / 29 Spring 2010 s of s s are abstract data types that
More informationCS483 Design and Analysis of Algorithms
CS483 Design and Analysis of Algorithms Lecture 9 Decompositions of Graphs Instructor: Fei Li lifei@cs.gmu.edu with subject: CS483 Office hours: STII, Room 443, Friday 4:00pm - 6:00pm or by appointments
More informationCS 473: Algorithms. Chandra Chekuri 3228 Siebel Center. Fall University of Illinois, Urbana-Champaign
CS 473: Algorithms Chandra chekuri@cs.illinois.edu 3228 Siebel Center University of Illinois, Urbana-Champaign Fall 2010 Depth First Search Directed Graphs Searching ted Graphs Strong Connected Components
More informationCS473-Algorithms I. Lecture 13-A. Graphs. Cevdet Aykanat - Bilkent University Computer Engineering Department
CS473-Algorithms I Lecture 3-A Graphs Graphs A directed graph (or digraph) G is a pair (V, E), where V is a finite set, and E is a binary relation on V The set V: Vertex set of G The set E: Edge set of
More informationCSCE 750, Fall 2002 Notes 6 Page Graph Problems ffl explore all nodes (breadth first and depth first) ffl find the shortest path from a given s
CSCE 750, Fall 2002 Notes 6 Page 1 10 Graph Algorithms (These notes follow the development in Cormen, Leiserson, and Rivest.) 10.1 Definitions ffl graph, directed graph (digraph), nodes, edges, subgraph
More informationElementary Graph Algorithms. Ref: Chapter 22 of the text by Cormen et al. Representing a graph:
Elementary Graph Algorithms Ref: Chapter 22 of the text by Cormen et al. Representing a graph: Graph G(V, E): V set of nodes (vertices); E set of edges. Notation: n = V and m = E. (Vertices are numbered
More informationCS 161 Lecture 11 BFS, Dijkstra s algorithm Jessica Su (some parts copied from CLRS) 1 Review
1 Review 1 Something I did not emphasize enough last time is that during the execution of depth-firstsearch, we construct depth-first-search trees. One graph may have multiple depth-firstsearch trees,
More informationGraph Representations and Traversal
COMPSCI 330: Design and Analysis of Algorithms 02/08/2017-02/20/2017 Graph Representations and Traversal Lecturer: Debmalya Panigrahi Scribe: Tianqi Song, Fred Zhang, Tianyu Wang 1 Overview This lecture
More informationChapter 22 Elementary Graph Algorithms
Chapter 22 Elementary Graph Algorithms Graph Representations Graph G = (V,E) Directed Undirected Adjacency Lists Adjacency Matrix Graph Representations Adjacency List: Undirected Memory: Adjacency: Graph
More information1 Start with each vertex being its own component. 2 Merge two components into one by choosing the light edge
Taking Stock IE170: in Systems Engineering: Lecture 19 Jeff Linderoth Department of Industrial and Systems Engineering Lehigh University March 16, 2007 Last Time Minimum This Time More Strongly Connected
More informationW4231: Analysis of Algorithms
W4231: Analysis of Algorithms 10/21/1999 Definitions for graphs Breadth First Search and Depth First Search Topological Sort. Graphs AgraphG is given by a set of vertices V and a set of edges E. Normally
More informationCut vertices, Cut Edges and Biconnected components. MTL776 Graph algorithms
Cut vertices, Cut Edges and Biconnected components MTL776 Graph algorithms Articulation points, Bridges, Biconnected Components Let G = (V;E) be a connected, undirected graph. An articulation point of
More informationCOL351: Analysis and Design of Algorithms (CSE, IITD, Semester-I ) Name: Entry number:
Name: Entry number: There are 6 questions for a total of 75 points. 1. Consider functions f(n) = 10n2 n + 3 n and g(n) = n3 n. Answer the following: (a) ( 1 / 2 point) State true or false: f(n) is O(g(n)).
More informationCSE 101. Algorithm Design and Analysis Miles Jones and Russell Impagliazzo Miles Office 4208 CSE Building
CSE 101 Algorithm Design and Analysis Miles Jones and Russell Impagliazzo mej016@eng.ucsd.edu russell@cs.ucsd.edu Miles Office 4208 CSE Building Russell s Office: 4248 CSE Building procedure DFS(G) cc
More informationGraph Algorithms. Definition
Graph Algorithms Many problems in CS can be modeled as graph problems. Algorithms for solving graph problems are fundamental to the field of algorithm design. Definition A graph G = (V, E) consists of
More informationFundamental Graph Algorithms Part Four
Fundamental Graph Algorithms Part Four Announcements Problem Set One due right now. Due Friday at 2:15PM using one late period. Problem Set Two out, due next Friday, July 12 at 2:15PM. Play around with
More informationGraph Algorithms: Chapters Part 1: Introductory graph concepts
UMass Lowell Computer Science 91.503 Algorithms Dr. Haim Levkowitz Fall, 2007 Graph Algorithms: Chapters 22-25 Part 1: Introductory graph concepts 1 91.404 Graph Review Elementary Graph Algorithms Minimum
More informationCSI 604 Elementary Graph Algorithms
CSI 604 Elementary Graph Algorithms Ref: Chapter 22 of the text by Cormen et al. (Second edition) 1 / 25 Graphs: Basic Definitions Undirected Graph G(V, E): V is set of nodes (or vertices) and E is the
More informationCHAPTER 23: ELEMENTARY GRAPH ALGORITHMS Representations of graphs
CHAPTER 23: ELEMENTARY GRAPH ALGORITHMS This chapter presents methods for representing a graph and for searching a graph. Searching a graph means systematically following the edges of the graph so as to
More informationChapter 3. Graphs CLRS Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.
Chapter 3 Graphs CLRS 12-13 Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 25 3.4 Testing Bipartiteness Bipartite Graphs Def. An undirected graph G = (V, E) is bipartite
More informationAlgorithm Design and Analysis
Algorithm Design and Analysis LECTURE 4 Graphs Definitions Traversals Adam Smith 9/8/10 Exercise How can you simulate an array with two unbounded stacks and a small amount of memory? (Hint: think of a
More informationDepth-first search in undirected graphs What parts of the graph are reachable from a given vertex?
Why graphs? Chapter 3. Decompositions of graphs Awiderangeofproblemscanbeexpressedwithclarityandprecisionin the concise pictorial language of graphs. Graph coloring. Graph connectivity and reachability.
More informationUndirected Graphs. V = { 1, 2, 3, 4, 5, 6, 7, 8 } E = { 1-2, 1-3, 2-3, 2-4, 2-5, 3-5, 3-7, 3-8, 4-5, 5-6 } n = 8 m = 11
Chapter 3 - Graphs Undirected Graphs Undirected graph. G = (V, E) V = nodes. E = edges between pairs of nodes. Captures pairwise relationship between objects. Graph size parameters: n = V, m = E. V = {
More informationGraphs. Graph G = (V, E) Types of graphs E = O( V 2 ) V = set of vertices E = set of edges (V V)
Graph Algorithms Graphs Graph G = (V, E) V = set of vertices E = set of edges (V V) Types of graphs Undirected: edge (u, v) = (v, u); for all v, (v, v) E (No self loops.) Directed: (u, v) is edge from
More informationCopyright 2000, Kevin Wayne 1
Chapter 3 - Graphs Undirected Graphs Undirected graph. G = (V, E) V = nodes. E = edges between pairs of nodes. Captures pairwise relationship between objects. Graph size parameters: n = V, m = E. Directed
More informationDesign and Analysis of Algorithms
Design and Analysis of Algorithms CSE 5311 Lecture 18 Graph Algorithm Junzhou Huang, Ph.D. Department of Computer Science and Engineering CSE5311 Design and Analysis of Algorithms 1 Graphs Graph G = (V,
More informationLecture 10. Finding strongly connected components
Lecture 10 Finding strongly connected components Announcements HW4 due Friday Nothing assigned Friday because MIDTERM in class, Monday 10/30. Please show up. During class, 1:30-2:50 If your last name is
More informationLecture 10. Elementary Graph Algorithm Minimum Spanning Trees
Lecture 10. Elementary Graph Algorithm Minimum Spanning Trees T. H. Cormen, C. E. Leiserson and R. L. Rivest Introduction to Algorithms, 3rd Edition, MIT Press, 2009 Sungkyunkwan University Hyunseung Choo
More informationFundamental Graph Algorithms Part Three
Fundamental Graph Algorithms Part Three Outline for Today Topological Sorting, Part II How can we quickly compute a topological ordering on a DAG? Connected Components How do we find the pieces of an undirected
More informationGraph Traversal. 1 Breadth First Search. Correctness. find all nodes reachable from some source node s
1 Graph Traversal 1 Breadth First Search visit all nodes and edges in a graph systematically gathering global information find all nodes reachable from some source node s Prove this by giving a minimum
More informationCOT 6405 Introduction to Theory of Algorithms
COT 6405 Introduction to Theory of Algorithms Topic 14. Graph Algorithms 11/7/2016 1 Elementary Graph Algorithms How to represent a graph? Adjacency lists Adjacency matrix How to search a graph? Breadth-first
More informationStrongly Connected Components. Andreas Klappenecker
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
More informationCS4800: Algorithms & Data Jonathan Ullman
CS4800: Algorithms & Data Jonathan Ullman Lecture 12: Graph Search: BFS Applications, DFS Feb 20, 2018 BFS Review BFS Algorithm: Input: source node! " # =! " % = all neighbors of " # " & = all neighbors
More informationChapter 22: Elementary Graph Algorithms. Definitions:
Chapter 22: Elementary Graph Algorithms. Definitions: 1. G = (V, E), where V is a set of points and E is a set of edges connecting point-pairs from V. 2. We use V synonymously with V and E with E when
More information15-451/651: Design & Analysis of Algorithms October 5, 2017 Lecture #11: Depth First Search and Strong Components last changed: October 17, 2017
15-451/651: Design & Analysis of Algorithms October 5, 2017 Lecture #11: Depth First Search and Strong Components last changed: October 17, 2017 1 Introduction Depth first search is a very useful technique
More informationSlides credited from Hsueh-I Lu, Hsu-Chun Hsiao, & Michael Tsai
Slides credited from Hsueh-I Lu, Hsu-Chun Hsiao, & Michael Tsai Mini-HW 7 released Due on 11/30 (Thur) 17:20 Homework 3 released tonight Due on 12/14 (Thur) 17:20 (three weeks) Class change!! Start from
More informationLecture 2 - Graph Theory Fundamentals - Reachability and Exploration 1
CME 305: Discrete Mathematics and Algorithms Instructor: Professor Aaron Sidford (sidford@stanford.edu) January 11, 2018 Lecture 2 - Graph Theory Fundamentals - Reachability and Exploration 1 In this lecture
More informationAlgorithms Activity 6: Applications of BFS
Algorithms Activity 6: Applications of BFS Suppose we have a graph G = (V, E). A given graph could have zero edges, or it could have lots of edges, or anything in between. Let s think about the range of
More informationLecture 3: Graphs and flows
Chapter 3 Lecture 3: Graphs and flows Graphs: a useful combinatorial structure. Definitions: graph, directed and undirected graph, edge as ordered pair, path, cycle, connected graph, strongly connected
More informationCSE 101. Algorithm Design and Analysis Miles Jones Office 4208 CSE Building Lecture 5: SCC/BFS
CSE 101 Algorithm Design and Analysis Miles Jones mej016@eng.ucsd.edu Office 4208 CSE Building Lecture 5: SCC/BFS DECOMPOSITION There is a linear time algorithm that decomposes a directed graph into its
More informationGraphs. Part I: Basic algorithms. Laura Toma Algorithms (csci2200), Bowdoin College
Laura Toma Algorithms (csci2200), Bowdoin College Undirected graphs Concepts: connectivity, connected components paths (undirected) cycles Basic problems, given undirected graph G: is G connected how many
More informationAlgorithm Design and Analysis
Algorithm Design and Analysis LECTURE 7 Greedy Graph Algorithms Topological sort Shortest paths Adam Smith The (Algorithm) Design Process 1. Work out the answer for some examples. Look for a general principle
More informationGraphs. A graph is a data structure consisting of nodes (or vertices) and edges. An edge is a connection between two nodes
Graphs Graphs A graph is a data structure consisting of nodes (or vertices) and edges An edge is a connection between two nodes A D B E C Nodes: A, B, C, D, E Edges: (A, B), (A, D), (D, E), (E, C) Nodes
More informationDirected Graphs (II) Hwansoo Han
Directed Graphs (II) Hwansoo Han Traversals of Directed Graphs To solve many problems dealing with digraphs, we need to visit vertexes and arcs in a systematic way Depth-first search (DFS) A generalization
More informationGraph Search. Adnan Aziz
Graph Search Adnan Aziz Based on CLRS, Ch 22. Recall encountered graphs several weeks ago (CLRS B.4) restricted our attention to definitions, terminology, properties Now we ll see how to perform basic
More informationElementary Graph Algorithms
Elementary Graph Algorithms Graphs Graph G = (V, E)» V = set of vertices» E = set of edges (V V) Types of graphs» Undirected: edge (u, v) = (v, u); for all v, (v, v) E (No self loops.)» Directed: (u, v)
More informationLecture 4: Walks, Trails, Paths and Connectivity
Lecture 4: Walks, Trails, Paths and Connectivity Rosa Orellana Math 38 April 6, 2015 Graph Decompositions Def: A decomposition of a graph is a list of subgraphs such that each edge appears in exactly one
More informationTrees. 3. (Minimally Connected) G is connected and deleting any of its edges gives rise to a disconnected graph.
Trees 1 Introduction Trees are very special kind of (undirected) graphs. Formally speaking, a tree is a connected graph that is acyclic. 1 This definition has some drawbacks: given a graph it is not trivial
More informationGraph: representation and traversal
Graph: representation and traversal CISC4080, Computer Algorithms CIS, Fordham Univ. Instructor: X. Zhang! Acknowledgement The set of slides have use materials from the following resources Slides for textbook
More informationMinimum Spanning Trees Ch 23 Traversing graphs
Next: Graph Algorithms Graphs Ch 22 Graph representations adjacency list adjacency matrix Minimum Spanning Trees Ch 23 Traversing graphs Breadth-First Search Depth-First Search 11/30/17 CSE 3101 1 Graphs
More informationElementary Graph Algorithms CSE 6331
Elementary Graph Algorithms CSE 6331 Reading Assignment: Chapter 22 1 Basic Depth-First Search Algorithm procedure Search(G = (V, E)) // Assume V = {1, 2,..., n} // // global array visited[1..n] // visited[1..n]
More informationBasic Graph Algorithms (CLRS B.4-B.5, )
Basic Graph Algorithms (CLRS B.-B.,.-.) Basic Graph Definitions A graph G = (V,E) consists of a finite set of vertices V and a finite set of edges E. Directed graphs: E is a set of ordered pairs of vertices
More informationU.C. Berkeley CS170 : Algorithms, Fall 2013 Midterm 1 Professor: Satish Rao October 10, Midterm 1 Solutions
U.C. Berkeley CS170 : Algorithms, Fall 2013 Midterm 1 Professor: Satish Rao October 10, 2013 Midterm 1 Solutions 1 True/False 1. The Mayan base 20 system produces representations of size that is asymptotically
More informationFigure 1: A directed graph.
1 Graphs A graph is a data structure that expresses relationships between objects. The objects are called nodes and the relationships are called edges. For example, social networks can be represented as
More informationTrees. Arash Rafiey. 20 October, 2015
20 October, 2015 Definition Let G = (V, E) be a loop-free undirected graph. G is called a tree if G is connected and contains no cycle. Definition Let G = (V, E) be a loop-free undirected graph. G is called
More informationThese notes present some properties of chordal graphs, a set of undirected graphs that are important for undirected graphical models.
Undirected Graphical Models: Chordal Graphs, Decomposable Graphs, Junction Trees, and Factorizations Peter Bartlett. October 2003. These notes present some properties of chordal graphs, a set of undirected
More informationTopic 12: Elementary Graph Algorithms
Topic 12: Elementary Graph Algorithms Pierre Flener Lars-enrik Eriksson (version of 2013-02-10) Different kinds of graphs List Tree A B C A B C Directed Acyclic Graph (DAG) D A B C D E Directed Graph (Digraph)
More informationDepth First Search (DFS)
Algorithms & Models of Computation CS/ECE 374, Fall 2017 epth First Search (FS) Lecture 1 Thursday, October 2, 2017 Today Two topics: Structure of directed graphs FS and its properties One application
More information(Re)Introduction to Graphs and Some Algorithms
(Re)Introduction to Graphs and Some Algorithms Graph Terminology (I) A graph is defined by a set of vertices V and a set of edges E. The edge set must work over the defined vertices in the vertex set.
More informationLECTURE NOTES OF ALGORITHMS: DESIGN TECHNIQUES AND ANALYSIS
Department of Computer Science University of Babylon LECTURE NOTES OF ALGORITHMS: DESIGN TECHNIQUES AND ANALYSIS By Faculty of Science for Women( SCIW), University of Babylon, Iraq Samaher@uobabylon.edu.iq
More informationCSE 417: Algorithms and Computational Complexity. 3.1 Basic Definitions and Applications. Goals. Chapter 3. Winter 2012 Graphs and Graph Algorithms
Chapter 3 CSE 417: Algorithms and Computational Complexity Graphs Reading: 3.1-3.6 Winter 2012 Graphs and Graph Algorithms Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.
More informationDefinition Example Solution
Section 11.4 Spanning Trees Definition: Let G be a simple graph. A spanning tree of G is a subgraph of G that is a tree containing every vertex of G. Example: Find the spanning tree of this simple graph:
More informationPractical Session No. 12 Graphs, BFS, DFS, Topological sort
Practical Session No. 12 Graphs, BFS, DFS, Topological sort Graphs and BFS Graph G = (V, E) Graph Representations (V G ) v1 v n V(G) = V - Set of all vertices in G E(G) = E - Set of all edges (u,v) in
More informationCS 361 Data Structures & Algs Lecture 15. Prof. Tom Hayes University of New Mexico
CS 361 Data Structures & Algs Lecture 15 Prof. Tom Hayes University of New Mexico 10-12-2010 1 Last Time Identifying BFS vs. DFS trees Can they be the same? Problems 3.6, 3.9, 3.2 details left as homework.
More informationDirected Graphs. DSA - lecture 5 - T.U.Cluj-Napoca - M. Joldos 1
Directed Graphs Definitions. Representations. ADT s. Single Source Shortest Path Problem (Dijkstra, Bellman-Ford, Floyd-Warshall). Traversals for DGs. Parenthesis Lemma. DAGs. Strong Components. Topological
More informationSolutions to relevant spring 2000 exam problems
Problem 2, exam Here s Prim s algorithm, modified slightly to use C syntax. MSTPrim (G, w, r): Q = V[G]; for (each u Q) { key[u] = ; key[r] = 0; π[r] = 0; while (Q not empty) { u = ExtractMin (Q); for
More informationSolutions to Midterm 2 - Monday, July 11th, 2009
Solutions to Midterm - Monday, July 11th, 009 CPSC30, Summer009. Instructor: Dr. Lior Malka. (liorma@cs.ubc.ca) 1. Dynamic programming. Let A be a set of n integers A 1,..., A n such that 1 A i n for each
More informationGraph Algorithms (part 3 of CSC 282),
Graph Algorithms (part of CSC 8), http://www.cs.rochester.edu/~stefanko/teaching/11cs8 Homework problem sessions are in CSB 601, 6:1-7:1pm on Oct. (Wednesday), Oct. 1 (Wednesday), and on Oct. 19 (Wednesday);
More informationA Simplified Correctness Proof for a Well-Known Algorithm Computing Strongly Connected Components
A Simplified Correctness Proof for a Well-Known Algorithm Computing Strongly Connected Components Ingo Wegener FB Informatik, LS2, Univ. Dortmund, 44221 Dortmund, Germany wegener@ls2.cs.uni-dortmund.de
More information