310 likes | 484 Views
Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier. Camil Demetrescu University of Rome “La Sapienza” Giuseppe F. Italiano University of Rome “Tor Vergata”. Fully Dynamic Transitive Closure.
E N D
Fully Dynamic Transitive Closure:Breaking Through the O(n2) Barrier Camil Demetrescu University of Rome “La Sapienza” Giuseppe F. Italiano University of Rome “Tor Vergata”
Fully Dynamic Transitive Closure Given a directedgraph G=(V,E),perform any intermixed sequence of the following operations: Insert(x,y): insert edge from x to y in G Delete(x,y): delete edge from x to y in G Query(x,y): is y reachable from x in G?
Outline of the Talk • State of the art on transitive closure • Our results • New deterministic algorithm • New subquadratic algorithm • Directions for further research
E = (A+BD*C)* B F = EBD* A V1 V2 D G = D*CE C H = D*+D*CEBD* Static Transitive Closure [Munro 1971] V1 V2 V1 V2 A B E F V1 V1 X = X* = C D G H V2 V2
Static Transitive Closure [Munro 1971] T(n) ≤ 2 T(n/2) + O(n) T(n) = O(n) = exponent for matrix multiplication Best = 2.38[Coppersmith/Winograd 1990]
O(n3) on any sequence Ibaraki Katoh O(1) IPL ’83 O(n) O(1) Insert only Italiano TCS ’86 Ibaraki Katoh O(n2) O(1) IPL ’83 La Poutré van Leeuwen La Poutré van Leeuwen O(m) O(n) O(1) O(1) WG ’88 WG ’88 Delete only O(1) IPL ’88 O(n) dags Italiano Henzinger King O(nlog2n) O(n/logn) FOCS ’95 Partially Dynamic: Previous Work Who When Algorithm Update Query
Rebuild from scratch transitive closure after each update. O(n2.38) O(1) 1 Do nothing after each update. Perform visit to answer queries. O(n2) 2 O(1) Fully Dynamic: Simple-minded Methods Algorithm Insert/Delete Query
Randomized one-side error Henzinger King FOCS 1995 O(n2.16 log2 n) O(n/logn) Deterministic + lookahead (n0.18) upd. Khanna Motwani Wilson SODA 1996 O(1) O(n2.18) Randomized one-side error STOC 1999 King Sagert O(n2.28) O(1) FOCS 1999 Deterministic O(n2 logn) O(1) King Fully Dynamic: Previous Work Who When Algorithm Insert/Delete Query
SM = Simple-minded = King/Sagert KS99 HK95 = Henzinger/King K99 = King SM HK95 K99 KS99 SM ? ? State of the Art Query O(n2) O(n) O(1) Update O(1) O(n2) O(n2.38)
O(n) O(n) Breaking Through the O(n2) Barrier Give up unit-cost queries ...
Deterministic General Digraphs O(n2) O(1) 1 Randomized (one-side error) Acyclic Digraphs O(n) O(n2-0.62+n1+) 2 0 ≤ ≤ 1 Deterministic deletion only General Digraphs 3 O(n) O(1) Our Results We answer positively both questions: Algorithm Insert/Delete Query
Main Ingredients • Introduce a general framework for maintaining dynamic matrices • Cast dynamic transitive closure into this framework
Surprisingly, not exploited before in the dynamic setting. Fast matrix multiplication used before only as subroutine. Deterministic Algorithm: Idea Exploit equivalence: Transitive closure Matrix multiplication
Deterministic: Supported Operations i i Insert i Delete
? A B D* C * E = (A+BD*C)*= Insert in V1: Update E V1 V2 V1 V2 A B E F V1 V1 X = X* = C D G H V2 V2 E = (A+BD*C)* F = EBD* G = D*CE H = D*+D*CEBD*
? A B D* C * E = (A+BD*C)*= Insert in V2: Update E V1 V2 V1 V2 A B E F V1 V1 X = X* = G H V2 V2 C D E = (A+BD*C)* F = EBD* G = D*CE H = D*+D*CEBD*
V1 V2 V1 V2 A B A B V1 V1 X = X = C D C D V2 V2 Insert in V1 Insert in V2 E = (A+BD*C)* H = (D+CA*B)* F = EBD* G = HCA* G = D*CE F = A*BH H = D*+D*CEBD* E = A*+A*BHCA* Idea: Work with Two Sets of Relations
? * E = = Problem: How can we update F, G and H? Insert in V1: Update F, G and H V1 V2 V1 V2 A B E F V1 V1 X = X* = C D G H V2 V2 E = (A+BD*C)* F = EBD* G = D*CE H = D*+D*CEBD*
CE EB D*C E EBD* H Idea: Exploit Associativity + E=E2 i V2 V2 V1 V1 V1 V2 V2 = + D* D* C E E B D* H
Our Data Structure for X* V1 V2 V1 V2 A B E F V1 V1 X = X* = C D G H V2 V2 P = D* E1 = (A+BP2C)* E2 = E1BH22CE1 E = E1+E2 F1 = E12BP F2 = E1BH22 F = F1+F2 G1 = PCE12 G2 = H22CE1 G = G1+G2 H1 = PCE12BP H2 = (D+CE12B)* H = H1+H2
V1 V2 V1 V2 E1 F1 E2 F2 V1 V1 X1 = X2 = G1 H1 G2 H2 V2 V2 Full update of X1 (resp. X2) Insert on V1 (resp. V2) Lazy update of X2 (resp. X1) Neither X1 nor X2 encode complete information about X*, but their sum does. Our Data Structure for X* We represent X* as the sum of two Boolean matrices:
Running Times • Fully dynamic algorithm for maintaining the transitive closure of a directed graph under insertions of a set of edges with a common endpoint, deletions of any subset of edges, and queries in O(n2) amortized time per update and O(1) time per query. • Deletions-only algorithm with O(n) amortized time per deletion and O(1) time per query.
Update: O(n2-0.62+n1+) for any 0 ≤ ≤ 1 Query: O(n) Update: O(n1.62) for =0.62 Query: O(n0.62) Breaking Through the O(n2) Barrier Our results: Randomized algorithm (one-side error) on acyclic digraphs
u x y v Starting Point: King/Sagert [STOC99] Keep a count of the number of distinct paths in acyclic digraphs C[u,v] C[y,v] C[u,x] u,v: C[u,v]C[u,v]+ C[u,x] · C[y,v] Problem: counters as large as 2n Solution: use arithmetic modulo a random prime
M M + J · I Update(J,I): + · Query(i,j): return M[i,j] Maintaining Dynamic Integer Matrices Given a matrix M of integers, perform any intermixed sequence of the following operations:
Our result: Update: O(n2-(3- )) for any 0 ≤ ≤ 1 = exp. mat. mult. Query: O(n) Maintaining Dynamic Integer Matrices Simple-minded method: Update: O(n2) Query: O(1)
Maintaining Dynamic Integer Matrices Our data structure: • Lazy approach: buffer at most n updates • Global reconstruction every n updates • Reconstructiondone via matrix multiplication
i3 I3 i2 m +j1· i1 +j2· i2 +j3· i3 I2 i1 I1 j3 j2 j1 m M J3 J2 J1 Maintaining Dynamic Integer Matrices
i3 I3 i2 I2 i1 I1 j3 j2 j1 J3 J2 J1 Maintaining Dynamic Integer Matrices Global reconstruction every n updates m +j1· i1 +j2· i2 +j3· i3 n n m · + M’ M O(n2-(2-))
Time Bounds for Transitive Closure Update: +n1+ O(n2-0.62 ) for any 0 ≤ ≤ 1 Query: O(n)
Subquadratic algorithm for general digraphs? Deterministic subquadratic algorithm? Fully Dynamic Shortest Paths? Directions for Further Research