Maintaining dynamic integer matrices Global rebuilding every n ε updates m + j 1 · i 1 + j 2 · i 2 + j 3 · i 3 n ε n m j 3 j 2 j 1 i 3 I 3 · + i 2 I 2 i 1 I 1 J 3 J 2 J 1 M ’ M O(n ω ( 1 , ε , 1 ) )
Back to Dynamic Transitive Closure C[u,v] x y v u C[y,v] C[u,x] C[u,v] ← C[u,v] + C[u,x] · C[y,v] ∀ u,v: + ← ·
Query Time m + j 1 · i 1 + j 2 · i 2 + j 3 · i 3 n ε n m j 3 j 2 j 1 i 3 I 3 · + i 2 I 2 i 1 I 1 J 3 J 2 J 1 M ’ M O(n ε ) Total Query time
Update Time 1. Compute C[u,x] and C[y,v] for any u,v C[u,v] ← C[u,v] + C[u,x] · C[y,v] ∀ u,v: + ← · Carried out via O(n) queries Time: O(n 1 + ε )
Update Time 2. Global rebuild every n ε updates n ε n M ’ M m j 3 j 2 j 1 i 3 I 3 · + i 2 I 2 i 1 I 1 J 3 J 2 J 1 Carried out via (rectangular) matrix multipl. Amortized time: O( n ω ( 1 , ε ,1) / n ε )
Dynamic Transitive Closure [Demetrescu-I., J.ACM05] Update: +n 1+ ε O(n ω ( 1 , ε , 1 )- ε ) for any 0 < ε < 1 Query: O(n ε ) Find ε such that ω (1, ε ,1) = 1+2 ε Best bound for rectangular matrix multiplication [Huang/Pan98] ε < 0.575 Update: O(n 1.575 ) worst-case time Query: O(n 0.575 ) worst-case time
Main Ingredients Long paths property Output bounded Decremental BFS Path decompositions Locally shortest paths Counting Algebraic techniques
Dynamic shortest paths: roadmap Reduced costs NSSSP � SSSP � Ramalingam-Reps ’96 � Frigioni et al ’98 � Demetrescu ’01 Shortest path trees Decremental BFS Even-Shiloach ’81
Decremental BFS [Even-Shiloach, JACM ’ 81] Maintain BFS levels under deletion of edges Undirected graphs: non BFS-tree edges can be depth d either between two consecutive levels or at the same level
Decremental BFS [Even-Shiloach, JACM ’ 81]
Decremental BFS [Even-Shiloach, JACM ’ 81] This implies that during deletion of edges each non-tree edge can fall down at most 2d times overall… O(md) total time depth d over any sequence O(d) time per deletion (amortized over Ω (m) deletions)
Can we do better than O(mn)? Roditty and Zwick [2011] have shown two reductions: Boolean matrix (off-line) decremental multiplication undirected BFS Weighted (static) (off-line) decremental undirected APSP undirected SSSP
Matrix mult. Decremental BFS B A A and B Boolean matrices y Wish to compute C=A · B C[x,y]=1 iff there is z such that A[x,z]=1 and B[z,y]=1 C[x,y]=1 iff path of length 2 x between x on first layer and y on last layer Bipartite graph with Bipartite graph with an edge (x,y) for an edge (x,y) for each A[x,y]=1 each B[x,y]=1
Matrix mult. Decremental BFS C B A s x 1 0 1 0 0 x 0 1 0 0 0 x 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 First row: C[1,x]=1 iff dist(s,x)=3 n deletions and n 2 queries � Second row: C[2,x]=1 iff dist(s,x)=4 Decremental BFS in o(mn) total time would Third row: C[3,x]=1 iff dist(s,x)=5 imply Boolean matrix multiplication in o(mn) … …
More details in Decremental BFS: [Even-Shiloach’81] S. Even and Y. Shiloach, An On-line Edge Deletion Problem, J. Assoc. Comput. Mach, Vol. 28, pp. 1-4, 1981 Reductions to decremental BFS: [Roditty-Zwick’11] Liam Roditty, Uri Zwick, On dynamic shortest paths problems Algorithmica 61(2): 389-401 (2011).
Main Ingredients Long paths property Output bounded Decremental BFS Path decompositions Locally shortest paths Counting Algebraic techniques
Dynamic shortest paths: roadmap Reduced costs NSSSP � SSSP � Ramalingam-Reps ’96 � Frigioni et al ’98 � Demetrescu ’01 Shortest path trees Decremental BFS NAPSP � Even-Shiloach ’81 King ’99 Long paths � decomposition
Make decremental (ES) fully dynamic For each vertex v: IN(v) maintained as a decremental BFS tree x Building block: � d pair of IN/OUT trees � v keeps track of all paths of keeps track of all paths of � d length ≤ d passing through v length ≤ 4 passing through v y OUT(v) maintained as a decremental BFS tree
Make decremental (ES) fully dynamic Rebuild IN(v), OUT(v) Rebuild IN(v), OUT(v) IN(v) IN(v) v v OUT(v) OUT(v) deletions only for IN(v), OUT(v) sequence of ops insert(v) insert(v) Total cost for rebuilding IN, OUT trees + deleting edges in between: O(md) This is charged to insert(v)
Dynamic Transitive Closure [King, FOCS ’ 99] Ingredients: + Decremental BFS Doubling decomposition IN(v) maintained as a decremental BFS tree x Building block: � d=2 pair of IN/OUT trees � v keeps track of all paths of keeps track of all paths of � d=2 length ≤ 2 passing through v length ≤ 4 passing through v y OUT(v) maintained as a decremental BFS tree Total cost for building the two trees + deleting all edges: O(m)
Doubling Decomposition [folklore] Transitive closure can be computed with O(log n) products of Boolean matrices X = adjacency matrix + I X n-1 = transitive closure X X paths with ≤ 2 edges X 2 X 2 paths with ≤ 4 edges log n X 4 X 4 paths with ≤ 8 edges … X n-1
Dynamic Transitive Closure [King, FOCS ’ 99] G 0 = G (x,y) ∈ G 1 iff � x ∈ IN(v) and � G 1 y ∈ OUT(v) for � some v in G 0 (x,y) ∈ G 2 iff � IN/OUT trees in G 0 for each vertex x ∈ IN(v) and � Invariant: G 2 y ∈ OUT(v) for � If there is a path � some v in G 1 from x to y in G � IN/OUT trees in G 1 for each vertex of length ≤ k, then � G 3 there is an edge � (x,y) in G ⎡ log k ⎤ … … … … … … … Reachability G log n queries in G ⎡ log n ⎤
Dynamic Transitive Closure [King, FOCS ’ 99] Deletion of any subset of the edges of G G 0 = G G 1 Edge G 2 deletions (amortized G 3 against the … … … … … … … creation of trees) G log n
Dynamic Transitive Closure [King, FOCS ’ 99] Insertion of edges incident to a vertex v G 0 = G IN(v) and v v G 1 OUT(v) rebuilt from scratch on v v G 2 each level… v v Each level has G 3 O(n 2 ) edges … … … … … … … … O(n 2 log n) v v G log n total time
Dynamic Transitive Closure [King, FOCS ’ 99] Insertion of edges incident to a vertex v G 0 = G Correctness? v v G 1 Path a,b,c in G i-1 ⇒ (a,c) in G i ? v v G 2 a v v G 3 b … … … … … … … … c v v G log n
Dynamic Transitive Closure Update: amortized O(n 2 log n) Query: O(1) Update: amortized O(n 2 ) Query: O(1) via (Dynamic) Matrix Product: [Demetrescu-I., FOCS 00, Algorithmica 08] Update: worst-case O(n 2 ) Query: O(1) via (Dynamic) Matrix Inversion: [Sankowski, FOCS 04]
Main Ingredients Long paths property Output bounded Decremental BFS Path decompositions Locally shortest paths Counting Algebraic techniques
“Road”
Roads Highway Roads “Road”
A real-life problem “Road”
A real-life problem Roads Highway Roads
Are there roads and highways in graphs? Long Paths Property [Ullman-Yannakakis ‘ 91] Let P be a path of length at least k . Let S be a random subset of vertices of size ( c n ln n ) / k . Then with high probability P ∩ S ≠ ∅ . Probability ≥ 1 – (1 / n c ) ( depends on c )
Long Paths Property [Ullman-Yannakakis ‘ 91] n k c ln n Select each element p = independently with probability k k The probability that a c ln n k ⎛ ⎞ (1 p ) c − 1 n − = − < given set of k elements ⎜ ⎟ k ⎝ ⎠ is not hit is
Long Paths Property Can prove stronger property: Let P be a path of length at least k . Let S be a random subset of vertices of size ( c n ln n ) / k . Then with high probability there is no subpath of P of length k with no vertices in S ( P ∩ S ≠ ∅ ) . Probability ≥ 1 – (1 / n α c ) for some α > 0.
Exploit Long Paths Property Randomly pick a set S of vertices in the graph | S | = c n log n c, k > 0 k Then on any path in the graph every k vertices there is a vertex in S , with probability ≥ 1 – ( 1 / n α c ) <k <k <k <k <k <k <k Rome Warsaw vertices in S
Roads and Highways in Graphs Highway entry points = vertices in S Road = shortest path using at most k edges Highway = shortest path between two vertices in S Highway <k <k <k Rome Warsaw Road Road Road
Computing Shortest Paths 1/3 Compute roads 1 (shortest paths using at most k edges) k Rome Warsaw Even & Shiloach BFS trees may become handy…
Computing Shortest Paths 2/3 Compute highways 2 (by stitching together roads) Highway <k <k Road Road …essentially an all pairs shortest paths computation on a contracted graph with vertex set S , and edge set = roads
Computing Shortest Paths 3/3 Compute shortest paths (longer than k edges) 3 (by stitching together roads + highways + roads) Highway Rome Warsaw Road Road Used (for dynamic graphs) by King [FOCS ’ 99], Demetrescu-I. [JCSS ’ 06], Roditty-Zwick [FOCS ’ 04], …
Fully Dynamic APSP Given a weighted directed graph G=(V, E, w), � perform any intermixed sequence of the following operations: update weight of edge (u,v) to w Update(u,v,w): return distance from x to y Query(x,y): (or shortest path from x to y)
King ’ s algorithm [King ’ 99] Directed graphs with integer edge weights in [0,C] ~ ~ O(n 2.5 √ C) update time O(n 2.5 √ C) space O(1) query time Approach: 1. Maintain dynamically shortest paths up to length k = (nClogn) 0.5 using variant of decremental data structure by Even-Shiloach. Amortized cost per update is O(n 2 (nClogn) 0.5 ) (details in the paper) 2. Stitch together short paths from scratch to form long paths exploiting long paths decomposition <k <k <k <k <k <k <k Rome Vienna Warsaw
More details on stitching Always distances up to k=(Cnlogn) 1/2 (IN e OUT trees) Perform the following tasks at each update: 1. Build S deterministically, |S|=(Cnlogn) 1/2 : O(n 2 ) 2. Compute APSP in S: O(|S| 3 ) = O((Cnlogn) 3/2 ) 3. For each v in V, s in S, update distance by considering min s’ {D(v,s’)+D(s’,s)}: O(n|S| 2 ) = O(Cn 2 logn) 4. For each u,v in V, update distance by considering min s’ {D(u,s’)+D(s’,v)}: O(n 2 |S|) = O(n 5/2 (Clogn) 1/2 ) ~ ~ O(n 2.5 √ C) update time O(n 2.5 √ C) space O(1) query time <k <k <k <k <k <k <k Rome Vienna Warsaw
More details in Long paths decomposition: [Ullman-Yannakakis’91] J.D. Ullman and M. Yannakakis. High-probability parallel transitive-closure algorithms. SIAM Journal on Computing, 20(1), February 1991 King’s algorithm: [King’99] Valerie King Fully Dynamic Algorithms for Maintaining All-Pairs Shortest Paths and Transitive Closure in Digraphs. FOCS 1999: 81-91
Main Ingredients Long paths property Output bounded Decremental BFS Path decompositions Locally shortest paths Counting Algebraic techniques
Dynamic shortest paths: roadmap Reduced costs NSSSP � SSSP � Ramalingam-Reps ’96 � Frigioni et al ’98 � Demetrescu ’01 Shortest path trees Decremental BFS NAPSP � Even-Shiloach ’81 King ’99 Long paths � decomposition Locally-defined NAPSP/APSP path properties Demetrescu-Italiano ’04
Fully Dynamic APSP (Recall) Edge insertions (edge cost decreases) 10 x y 10 j i 10 10 For each pair x,y check whether D(x,i) + w(i,j) + D(j,y) < D(x,y) Quite easy: O(n 2 ) O(mn 2 ) = O(n 4 ) over a sequence Question 1 : Can we do better?
Fully Dynamic APSP (Recall) • Edge deletions (edge cost increases) Seem the hard operations. Intuition: G 0 G … … • When edge (shortest path) deleted: need info about second shortest path? (3rd, 4th, …) Question 2 : Can we keep this info?
Incremental Shortest Path Edge insertions only Show how to improve the O(n 4 ) bound over O(n 2 ) edge insertions (O(n 2 ) worst-case per insertion) Unweighted (directed) graphs: O(n 3 log n) over O(n 2 ) edge insertions (O(n log n) amortized per insertion) [Ausiello, I. , Marchetti-Spaccamela, Nanni J. Algs 1991]
Terminology SP(v) : Shortest path tree rooted at vertex v SP R (v) : Shortest path tree rooted at v in reverse graph 1 1 1 3 3 3 2 2 2 5 7 4 4 5 7 7 4 SP(1) SP R (1) 6 6
O(n 2 ) Update When edge (i,j) is inserted do the following: for each v in V, update SP(v) by considering SP(j) (basic update) 5 1 1 3 3 2 2 SP(5) 6 5 7 4 4 5 7 SP(1) 6 6 88
O(n 2 ) Update When edge (i,j) is inserted do the following: for each v in V, update SP(v) by considering SP(j) (basic update) 1 1 3 5 3 2 2 ✖ 5 7 4 4 5 7 6 ✖ SP(1) 6 6 89
First Idea When edge (i,j) is inserted do the following: for each v in SP R (i) , update SP(v) by considering SP(j) (basic update) 1 1 3 5 3 2 2 ✖ 5 7 4 4 5 7 6 ✖ SP(1) 6 6 90
First Idea j SP(j) i SP R (i) 91
First Idea j SP(j) i Still O(n 2 ) update SP R (i) 92
Second Idea j SP(j) i SP R (i) 93
Second Idea j SP(j) i ✖ SP R (i) 94
Second Idea j ✖ SP(j) i ✖ ✖ SP R (i) 95
Second Idea j ✖ SP(j) i ✖ ✖ ✖ ✖ SP R (i) 96
Second Idea j ✖ SP(j) i ✖ ✖ Can show O(n log n) ✖ amortized update (see paper for details) ✖ SP R (i) 97
What are we doing exactly? When edge (i,j) is inserted, avoid to look at all O(n 2 ) pairs (x,y) Look only at pairs (x,y) such that x that reaches i and y 1. reachable from j 2. Inserting edge (i,j) does NOT improve shortest path from x to v y y neighbor è of v x i j v Do we need to look at pair (x,y)? No, by subpath optimality
What are we doing exactly? 3. Inserting edge (i,j) DOES improve shortest path from x to v y y neighbor è of v x u i j v Do we need to look at all pairs (x,y)? Let u be the vertex immediately after x in the shortest path from x to v We need to look only at the pairs (x,y) such that shortest path from u to y was improved Again by subpath optimality: if inserting (i,j) did not improve the shortest path from u to y, then it cannot improve the shortest path from x to y
Locally Shortest Paths A path is locally shortest if all of its proper subpaths are shortest paths [Demetrescu-I., J.ACM’04] π xy x y Shortest path Shortest path Not a shortest path Shortest path π xy x y
Recommend
More recommend