Liam Roditty Reachability in Directed Graphs. Connectivity in undirected graphs Given two vertices decide whether they are in the same component. Reachability.

Slides:



Advertisements
Similar presentations
Lecture 15. Graph Algorithms
Advertisements

all-pairs shortest paths in undirected graphs
CSC 213 – Large Scale Programming. Today’s Goals  Examine new properties of DirectedGraph s  What reaching & reachable mean for a Graph  How humans.
CS 312 – Graph Algorithms1 Graph Algorithms Many problems are naturally represented as graphs – Networks, Maps, Possible paths, Resource Flow, etc. Ch.
1 Directed Graphs: Victoria Road Problem. 2 Update: Edge is deleted; Edge is inserted Edge weight is changed F A Directed graph problems.
Lectures on Network Flows
Graph Algorithms: Minimum Spanning Tree We are given a weighted, undirected graph G = (V, E), with weight function w:
1 Dynamic graph connectivity Holm, Lichtenberg, Thorup (98) (based on Henzinger & King (95))
Lists A list is a finite, ordered sequence of data items. Two Implementations –Arrays –Linked Lists.
1 On Dynamic Shortest Paths Problems Liam Roditty Uri Zwick Tel Aviv University ESA 2004.
DAST 2005 Tirgul 11 (and more) sample questions. DAST 2005 Q.Let G = (V,E) be an undirected, connected graph with an edge weight function w : E→R. Let.
© 2004 Goodrich, Tamassia Directed Graphs1 JFK BOS MIA ORD LAX DFW SFO.
An almost linear fully dynamic reachability algorithm.
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
Improved dynamic reachability algorithms for directed graphs Liam Roditty and Uri Zwick Tel Aviv University.
1 Directed Graphs CSC401 – Analysis of Algorithms Lecture Notes 15 Directed Graphs Objectives: Introduce directed graphs and weighted graphs Present algorithms.
CS344: Lecture 16 S. Muthu Muthukrishnan. Graph Navigation BFS: DFS: DFS numbering by start time or finish time. –tree, back, forward and cross edges.
Directed Graphs1 JFK BOS MIA ORD LAX DFW SFO. Directed Graphs2 Outline and Reading (§6.4) Reachability (§6.4.1) Directed DFS Strong connectivity Transitive.
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
Randomness in Computation and Communication Part 1: Randomized algorithms Lap Chi Lau CSE CUHK.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 11 Instructor: Paul Beame.
Tirgul 7 Review of graphs Graph algorithms: – BFS (next tirgul) – DFS – Properties of DFS – Topological sort.
1 An almost linear fully dynamic reachability algorithm Liam Roditty and Uri Zwick Tel Aviv University.
TDDB56 DALGOPT-D TDDB57 DALG-C – Lecture 11 – Graphs Graphs HT TDDB56 – DALGOPT-D Algorithms and optimization Lecture 11 Graphs.
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
Directed graphs Definition. A directed graph (or digraph) is a pair (V, E), where V is a finite non-empty set of vertices, and E is a set of ordered pairs.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
1 Quantum query complexity of some graph problems C. DürrUniv. Paris-Sud M. HeiligmanNational Security Agency P. HøyerUniv. of Calgary M. MhallaInstitut.
MST Many of the slides are from Prof. Plaisted’s resources at University of North Carolina at Chapel Hill.
Chapter 2 Graph Algorithms.
Spring 2015 Lecture 11: Minimum Spanning Trees
UNC Chapel Hill Lin/Foskey/Manocha Minimum Spanning Trees Problem: Connect a set of nodes by a network of minimal total length Some applications: –Communication.
Minimum Spanning Trees and Kruskal’s Algorithm CLRS 23.
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.
Data Structures & Algorithms Graphs
Introduction to Graphs. This Lecture In this part we will study some basic graph theory. Graph is a useful concept to model many problems in computer.
Graphs Part II Lecture 7. Lecture Objectives  Topological Sort  Spanning Tree  Minimum Spanning Tree  Shortest Path.
Connectivity. Graph Scanning Algorithm Input: A graph G and some vertex s. Output: The set R of vertices reachable from s and a set T ⊆ E(G) such that.
CSE 589 Applied Algorithms Spring 1999 Prim’s Algorithm for MST Load Balance Spanning Tree Hamiltonian Path.
Directed Graphs1 JFK BOS MIA ORD LAX DFW SFO. Directed Graphs2 Outline and Reading (§12.4) Reachability (§12.4.1) Directed DFS Strong connectivity Transitive.
CSC317 1 At the same time: Breadth-first search tree: If node v is discovered after u then edge uv is added to the tree. We say that u is a predecessor.
Breadth-First Search (BFS)
Directed Graphs Directed Graphs Shortest Path 12/7/2017 7:10 AM BOS
Directed Graphs 12/7/2017 7:15 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
Introduction to Algorithms
Minimum Spanning Trees
CSC317 Graph algorithms Why bother?
Lecture 12 Graph Algorithms
Lectures on Network Flows
Introduction to Graphs
Directed Graphs 9/20/2018 1:45 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
The Taxi Scheduling Problem
Directed Graphs 5/1/15 12:25:22 PM
Modeling and Simulation NETW 707
Algorithms (2IL15) – Lecture 5 SINGLE-SOURCE SHORTEST PATHS
Lectures on Graph Algorithms: searching, testing and sorting
Chapter 23 Minimum Spanning Tree
CS 583 Analysis of Algorithms
Improved dynamic reachability algorithms for directed graphs
Directed Graphs Directed Graphs Directed Graphs 2/23/ :12 AM BOS
Reachability in Directed Graphs
Lecture 14 Shortest Path (cont’d) Minimum Spanning Tree
EMIS 8374 Search Algorithms Updated 9 February 2004
CSE 417: Algorithms and Computational Complexity
Lecture 13 Shortest Path (cont’d) Minimum Spanning Tree
Lecture 11 Graph Algorithms
EMIS 8374 Search Algorithms Updated 12 February 2008
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:

Liam Roditty Reachability in Directed Graphs

Connectivity in undirected graphs Given two vertices decide whether they are in the same component. Reachability Is there a directed path from u to v Strong Connectivity Is there a directed path from u to v and from v to u G = (V,E) u v ṽ ũ u v ṽ ũ u v ṽ ũ

Dynamic graph algorithms Strong Connectivity

Reachability Fully dynamic reachability ,4 ? 1,2 ? Yes No

Totalupdatetime Querytime 1 mn I’ 88 m t m2m2 PvL87, FMNZ01 DI’ 00 BHS’ 00 HK’ 95 n3n3 mn 4/3 n/log n RZ’ 02 Just for DAGs Decremental Reachability

Small Query Time: Maintain explicitly the transitive closure matrix. Query is done in O(1), each update may take  (n 2 ) time. Fully dynamic reachability

Small Query Time: Maintain explicitly the transitive closure matrix. Query is done in O(1), each update may take  (n 2 ) time. Fully dynamic reachability Small Update Time: A data structure which may have a non-constant query time but with smaller update time. Open problem: Is it possible to break the  (n 2 ) update barrier ? Yes: Updates in O(m+n log n) and queries in O(n)

Updatetime Querytime n2n2 n 1 DI’ 00 R’ 03 S’04 n  nn  n2n2 n  RZ’ 03 mn  n n n m+n logn Today General graphs mn t DI’ 00 DAG m t Fully Dynamic Reachability

An overview of the algorithm Our algorithm supports the following operations: Insert( E w ) – Insert the edges E w all touching w into the graph Delete( E’ ) – Delete all edges of E’ from the graph Query( u,v ) – Check whether there is a directed path from u to v G(V,E 0 ) Insert(E v ) G(V,E 0  E v ) Insert(E u ) G(V,E 0  E v  E u )

An overview of the algorithm G(V,E 0 ) Insert(E v ) G(V,E 0  E v ) Insert(E u ) G(V,E 0  E v  E u ) u v xy v x y Insert( E w ) : Create two trees to capture new paths Query(u,v ):  w, u  T in (w)  v  T out (w) Delete( E’ ): Delete E’ from all trees Our algorithm works as follows:

… Insert(E v 1 ) v1v1 Insert(E v 2 )Insert(E v 3 ) v2v2 v3v3 vlvl Insert(E v l ) An overview of the algorithm The main problem is to delete edges efficiently from this forest. In(v 1 ) Out(v 1 )

… v1v1 v2v2 v3v3 vlvl A simple solution for DAGs The total time required to maintain a decremental single source reachability (DSSR) tree in directed acyclic graph is only O(m) (Itliano ’88)  Each edge is scanned only once in each tree Insert( E w ) Query(u,v) Delete( E’ ) O ( n ) O ( 1 ) O ( m+n )

Every edge is examined only once! (If the graph is DAG) Total complexity is O(m). Decremental reachability tree T in(v ) T out(v) v v

… v1v1 v2v2 v3v3 vlvl The problem with general graphs There is not any obvious way to generalize Itliano’s algorithm to general graphs. The best algorithm for DSSR requires O(mn) time. Insert( E w ) Query(u,v) Delete( E’ ) O ( n ) O ( 1 ) O ( mn ) O ( n ) O ( m+n log n )

… v1v1 v2v2 v3v3 vlvl Our Solution Our Solution Maintain the trees with respect to Strongly Connected Components Problem 1: We may have n trees each with different components! Problem 2: When a component is decomposed we have to update the edges such that an edge is never examine twice!

We solve Problem 1 using fully dynamic strong connectivity algorithm with update time of O(m  (m,n)). v1v1 In(v 1 ) Out(v 1 ) v2v2 In(v 2 ) Out(v 2 ) v4v4 In(v 4 ) Out(v 4 ) v5v5 In(v 5 ) Out(v 5 ) v3v3 In(v 3 ) Out(v 3 ) Fully dynamic strong connectivity with “persistency” Detect and report on decompositions Updating edge lists Updating edge lists

Supported operations: G 0 =(V,E 0 ) Insert(E’) Fully dynamic strong connectivity G 0 =(V,E 0 ) G 1 =(V,E 0 U E’) G 1 =(V,E 1 ) Insert(E’’) G 1 =(V,E 1 ) G 2 =(V,E 1 U E’’) G 2 =(V,E 2 ) Delete( E’ ) – Delete the set E’ from all versions. Query( u,v,i ) – Are u and v in the same component in G i Insert( E’ ) – Create a new version and add E’ to it. Note that these operations create a graph sequence G 0 (V,E 0 ), G 1 (V,E 1 ), …, G t (V,E t ) where E 0  E 1 …  E t. This containment is kept during all the update operations! O ( m  ( m,n )) O ( 1 )

Fully dynamic strong connectivity The components of all the graphs in the sequence are arranged in a hierarchy and can be represented as a forest of size O ( n ) G0G0 G1G1 G2G2 G3G3 The components:The forest: G0G0 G1G1 G2G2 G3G u v Query(u,v,1)  Version( LCA(u,v) )  1 Query(u,v,2)  Version( LCA(u,v) )  2 Version tag

H i+1 HiHi A new partitioning of the edges E 1,…, E t Definition 1: A partitioning of the graph sequence edges H i = { (u,v)  E i | Query(u,v,i)  (  Query(u,v,i-1)  (u,v)  E i-1 ) } H t+1 = E t \ U H i i=1 t G i-1 =(V,E i-1 ) G i =(V,E i ) G i+1 =(V,E i+1 ) H i H j = ø, E t = U H i i=1 t+1 U

G0G0 G1G1 G2G2 G3G3 FindScc(H 1,1)FindScc(H 2,2) Shift(H 1,H 2 ) Shift(H 2,H 3 ) FindScc(H 3,3) Shift(H 3,H 4 ) Cost Analysis: Note that an edge enters and leave H i just once Moving edges – Paid by the creation of the version they enter. Free Fixed edges – Paid by the current delete operation O(m) Processing a deletion H i edges Before…After !

G0G0 G1G1 G2G2 G3G3 FindScc(H 1,1)FindScc(H 2,2) Shift(H 1,H 2 ) Shift(H 2,H 3 ) FindScc(H 3,3) Shift(H 3,H 4 ) Cost Analysis: Note that an edge enters and leave H i just once Moving edges – Paid by the creation of the version they enter. Free Fixed edges – Paid by the current delete operation O(m) Processing a deletion H i edges Before…After !

G0G0 G1G1 G2G2 G3G3 The component forest

We solve Problem 1 using fully dynamic strong connectivity algorithm with update time of O(m  (m,n)). v1v1 In(v 1 ) Out(v 1 ) v2v2 In(v 2 ) Out(v 2 ) v4v4 In(v 4 ) Out(v 4 ) v5v5 In(v 5 ) Out(v 5 ) v3v3 In(v 3 ) Out(v 3 ) Fully dynamic strong connectivity with “persistency” Detect and report on decompositions Updating edge lists Updating edge lists

Decremental reachability tree When a decomposition is reported (by the strong connectivity algorithm), we need to: Build the data for the new components Connect the new components to the tree O(n log n) O(m)

The list in[v] contains only uninspected incoming edges. The list out[v] contains all the outgoing edge. A vertex v is active if in[v] is not empty Decremental reachability tree Data structures Every component maintains a list of its active vertices v in[v] component Tree invariant: The first edge of the first vertex in the component active vertices list is the edge that connects the component to the tree. If the component is not connected then its active vertices list is empty

component - An active vertex- An uninspected incoming edge - A tree edge - A none active vertex Deletions of non tree edges - A deleted edge Deletions of a tree edge – we search for an edge (u,v) such that the component that contains u satisfies the tree invariant Decremental reachability tree Edge deletion

Decremental reachability tree Disconnecting a component component - An active vertex- An uninspected incoming edge - A tree edge - A none active vertex - A deleted edge Disconnecting a component. How do we find the components vertices ?

G0G0 G1G1 G2G2 G3G3 The component forest component u Out[u]

We generalized the decremented reachability tree to general graphs by using the components of the graph. Each edge in the connection process is still scanned only once. We have to deal with decomposition. We like to create active lists for new components in efficient way. Decremental reachability tree

Decremental reachability tree Decomposition component Component 2 Size = 5 Component 1 Size =2 The largest components among the new components inherits the list of the decomposed component. Using the component forest each vertex from a small component is removed from the list and added to its new component list. The component decomposed to two new components one of size 5 and one of size 2.

Decremental reachability tree Analysis Component 2 Size = 5 Component 1 Size =2 Scanning the component vertices can be done in time proportional to the component size. We only scan ‘small’ components. Let’s analyze the total cost: If a vertex is moved from one active list to another, the size of the component containing it must have decreased by a factor of at least 2.

Summing up The total connection cost is O(m) The total decomposition cost is O(n log n) For each tree Each update costs O(m + n log n)

Open problems Reduce the query time to m/n ? Reduce the update time to O(m+n) ? Design other fully dynamic algorithm for a graph sequence ? A single decremental reachability tree in general graph in o(mn) ?