Dynamic Graph � Algorithms Giuseppe F. (Pino) Italiano University of Rome Tor Vergata giuseppe.italiano@uniroma2.it http://people.uniroma2.it/giuseppe.italiano/
Main Goals Understand what’s going on in a rich area (35+ years, still very active) Master the main algorithmic ideas, tools and techniques introduced Get involved and contribute to solving some exciting open problems!
Prerequisites Basic data structures: • Binary search trees, linking and cutting trees, union-find, etc… Basic (graph) algorithms: • DFS, BFS, MST, shortest paths, etc… Analysis of algorithms: • worst-case, average, amortized, randomized, etc…
Outline Dynamic Graph Problems – Quick Intro Topic 1. (Undirected Graphs) Dynamic Connectivity & MST Topic 2. (Undirected/Directed Graphs) Dynamic Shortest Paths Topic 3. (Non-dynamic?) 2-Connectivity in Directed Graphs
Theory Theory is when you know something, but it doesn't work .
The real world out there… Practice is when something works, but you don't know why.
Combining Theory and Practice? Practice is when something works, but you don't know why. Theory is when you know something, but it doesn't work.
Combining Theory and Practice? Big challenge: combine theory Practice is when and practice… something works, but you don't know why. Theory is when you know something, but it …i.e., nothing doesn't work. works and you don't know why.
Outline Dynamic Graph Problems – Quick Intro Topic 1. (Undirected Graphs) Dynamic Connectivity & MST Topic 2. (Undirected/Directed Graphs) Dynamic Shortest Paths Topic 3. (Non-dynamic?) 2-Connectivity in Directed Graphs
Dynamic Graphs Graphs subject to update operations Insert(u,v) Typical updates: Delete(u,v) ChangeWeight(u,v,w)
Dynamic Graphs Initialize Insert Delete Query A graph
Dynamic Graph Algorithms The goal of a dynamic graph algorithm is to support query and update operations as fast as possible (usually much faster than recomputing from scratch). G = (V,E) n = |V| Notation: m = |E| We will use also amortized analysis: Total worst-case time over sequence of ops # operations
Dynamic Graphs Partially Dynamic Problems Graphs subject to insertions only ( incremental ), or deletions only ( decremental ), but not both. Fully Dynamic Problems Graphs subject to intermixed sequences of insertions and deletions. Usually much more difficult problems.
Dynamic Graph Problems Support queries about properties on a dynamic graph Dynamic Connectivity (undirected graph G) Connected(): Connected(x,y): Is G connected? Are x and y connected in G? Dynamic Minimum Spanning Tree (undirected graph G) Any property on a MST of G
Dynamic Graph Problems Dynamic Transitive Closure (directed graph G) Reachable(x,y): Is y reachable from x in G? Dynamic All Pairs Shortest Paths Distance(x,y): What is the distance from x to y in G? ShortestPath(x,y): What is the shortest path from x to y in G?
Dynamic Graph Problems Dynamic Min Cut MinCut(): Cut(x,y): Min cut? Are x and y on the same side of a min cut of G? Dynamic Planarity Testing planar(): Is G planar? Dynamic k-connectivity k-connected(): k-connected(x,y): Is G k-connected? Are x and y k-connected?
Dynamic Graph Problems Dynamic (Approximate) Maximum Matching Matching(): Maximum Matching? ApproximateMatching(): Approximate Maximum Matching? ValueofMatching(): Dynamic (Approximate) Minimum Vertex Cover VertexCover(): Approximate Minimum Vertex Cover?
Outline Dynamic Graph Problems – Quick Intro Topic 1. (Undirected Graphs) Dynamic Connectivity & MST Topic 2. (Undirected/Directed Graphs) Dynamic Shortest Paths Topic 3. (Non-dynamic?) 2-Connectivity in Directed Graphs
Fully Dynamic Graph Connectivity Maintain an undirected graph G under an intermixed sequence of operations of the following type: • insert(u,v) : Add a new edge (u,v) • delete(u,v) : Remove edge (u,v) from G (assumes (u,v) in G) • connected(u,v) : Return yes if there is a path between u and v; return no otherwise Subproblem (basic ingredient) in many other problems Minimum spanning trees, 2-connectivity, … Simple problem but lots of interesting ideas! 19
connected(v,w) 20
connected(v,w) 21
connected(v,w) 22
insert(v,w) 23
insert(v,w) 24
delete(v,w) 25
delete(v,w) 26
delete(v,w) 27
delete(v,w) 28
Observation Incremental connectivity: Without deletions, union-find data structures would be just enough 29
Incremental Connectivity Disjoint Set-Union: • makeset(x) : {x} • find(x): returns set containing x • union(x,y): replaces find(x) and find(y) by their union
Incremental Connectivity • insert(x,y) : if find(x) ≠ find(y) then union(x,y) • connected(x,y) : return ( find(x) == find(y) ) (true iff x and y are connected) Amortized cost per operation is O( α (m,n)) (inverse Ackermann)
Observation Incremental connectivity: Without deletions, union-find data structures would be just enough Incremental MST: Without deletions, linking and cutting trees [Sleator & Tarjan 1983] would be just enough. Why? 32
Back to Fully Dynamic Connectivity But simple case first: Graph is a forest 33
Operations we need to do on the forest link(v,w) : Join two trees in the forest by inserting edge (v,w) (assume v and w are in different trees) cut(v,w) : Split a tree by deleting edge (v,w) (assume v and w are adjacent in a tree) findtree(v) : Return the tree containing vertex v in the forest 34
Operations we need to do on the forest link(v,w) : Join two trees in the forest by inserting edge (v,w) (assume v and w are in different trees) cut(v,w) : Split a tree by deleting edge (v,w) (assume v and w are adjacent in a tree) findtree(v) : Return the tree containing vertex v in the forest Can do this in O(log n) per operation in the worst case with several data structures, e.g.: • Sleator & Tarjan dynamic trees [1983], • ET-trees (Euler Tour trees) [Tarjan & Vishkin 1984] We refer to those as dynamic tree data structures 35
ET-trees 36
ET-trees R A B C F G D E Euler tour of a tree 37
ET-trees Euler tour of a tree 38
ET-trees ET-tree is a balanced binary tree over the Euler tour of a tree. Can perform link, cut and findtree in O(log n) 39
Euler tour tree : h d A data structure for g dynamic trees c a b e f b-c-d-c-b-a- e-f-e-g-e-h-e -a-b How to transform a tree into a one dimensional data f structure ? c h c g a a b e e b b d e e
Euler tour tree : h d A data structure for g dynamic trees c a b e f b-c-d-c-b-a- e-f-e-g-e-h-e -a-b : minimum value of all f a nodes in the subtree. b c h c d c g a a e f g b e e b b d e e h
Euler tour tree : h d A data structure for g dynamic trees c a b e f b-c-d-c-b-a- e-f-e-g-e-h-e -a-b
Euler tour tree : h d A data structure for g dynamic trees c a b e f b-c-d-c-b-a- e-f-e-g-e-h-e -a-b
Euler tour tree : h d A data structure for g T2 dynamic trees T1 c a b e f b-c-d-c-b-a a-b T1 e-f-e-g-e-h-e
Euler tour tree : h d A data structure for g T2 dynamic trees T1 c a b e f b-c-d-c-b-a a-b T1 e-f-e-g-e-h-e T1
Euler tour tree : h d A data structure for g T2 dynamic trees T1 c a b e f b-c-d-c-b-a a-b T1 e-f-e-g-e-h-e T1
Euler tour tree : h d A data structure for g T2 dynamic trees T1 c a b e f b-c-d-c-b-a a-b T1 e-f-e-g-e-h-e T1
Euler tour tree : h d A data structure for g T2 dynamic trees T1 c a b e f T1 T2 • Split (T,(e,a)) e-f-e-g-e-h-e b-c-d-c-b-a-b • Merge (T 1 ,T 2 ,(u,v)) • Change-origin (T,x) : change the origin of Euler tour to vertex x. Each operation can be implemented in O(log n) T1 T2 worst-case time
Fully Dynamic Connectivity Get to the real thing: Graph is a graph 49
Reduce the problem to a problem on trees (i.e., maintain a certificate for the property) Maintain a spanning forest of the graph We will have to link trees, cut trees, and determine whether two vertices are in the same tree in this forest 50
But dynamic tree data structures are not enough: we still have a problem with deleting a tree edge 51
52
53
How do we find out whether there is a “replacement” edge for the forest or it really got disconnected ? For dynamic MSF it is not enough to find a repacement edge, we need to find the best replacement edge 54
Recap (so far) Tree Edge Non-Tree Edge Insert Link Easy Cut, Delete Easy Replacement? 55
Recommend
More recommend