Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

31
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”

description

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. - PowerPoint PPT Presentation

Transcript of Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Page 1: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

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”

Page 2: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Fully Dynamic Transitive Closure

Given a directed graph 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?

Page 3: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Outline of the Talk

• State of the art on transitive closure

• Our results

• New deterministic algorithm

• New subquadratic algorithm

• Directions for further research

Page 4: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Static Transitive Closure [Munro 1971]

X = X* =A B

C D

E F

G H

E = (A+BD*C)*

F = EBD*

G = D*CE

H = D*+D*CEBD*

B

C

DA V1 V2

V1 V2 V1 V2

V1

V2

V1

V2

Page 5: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Static Transitive Closure [Munro 1971]

= exponent for matrix multiplication

Best = 2.38 [Coppersmith/Winograd 1990]

T(n) ≤ 2 T(n/2) + O(n)

T(n) = O(n)

Page 6: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Partially Dynamic: Previous Work

Who When Update QueryAlgorithm

Delete onlyLa Poutré

van Leeuwen WG ’88 O(m) O(1)

HenzingerKing FOCS ’95 O(n log2n) O(n/log n)

IbarakiKatoh

IPL ’83 O(n2) O(1)

Italiano IPL ’88 O(n) dags O(1)

Insert only

IbarakiKatoh IPL ’83 O(n3)

on any sequence O(1)

Italiano TCS ’86 O(n) O(1)La Poutré

van Leeuwen WG ’88 O(n) O(1)

Page 7: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Fully Dynamic: Simple-minded Methods

Insert/Delete QueryAlgorithm

O(n2.38) O(1)Rebuild from scratch transitive

closure after each update.1

O(1) O(n2)Do nothing after each update.

Perform visit to answer queries.2

Page 8: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Fully Dynamic: Previous Work

Who When Insert/Delete QueryAlgorithm

HenzingerKing

FOCS1995 O(n2.16 log2 n) O(n/log n)

Randomizedone-side error

KingSagert

STOC1999

Randomizedone-side error O(n2.28) O(1)

King FOCS1999

Deterministic O(n2 log n) O(1)

KhannaMotwaniWilson

SODA1996

Deterministic+ lookahead (n0.18) upd.

O(n2.18) O(1)

Page 9: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

State of the Art

O(n2)

O(n2.38)

O(1)

O(n)

Query

Update

O(1) O(n2)

SM

SM

SM = Simple-minded

KS99

KS99 = King/Sagert

HK95

HK95 = Henzinger/King

K99

K99 = King

?

?

Page 10: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Breaking Through the O(n2) Barrier

O(n) O(n)

Give up unit-cost queries ...

Page 11: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Our Results

Insert/Delete QueryAlgorithm

O(n2) O(1)Deterministic

General Digraphs1

O(n2-0.62+n1+) O(n)Randomized (one-side error)

Acyclic Digraphs2

0 ≤ ≤ 1

We answer positively both questions:

O(n) O(1)Deterministic deletion only

General Digraphs3

Page 12: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Main Ingredients

• Introduce a general framework for

maintaining dynamic matrices

• Cast dynamic transitive closure into this

framework

Page 13: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Deterministic Algorithm: Idea

Exploit equivalence:

Transitive closure Matrix multiplication

Surprisingly, not exploited before in the dynamic setting.

Fast matrix multiplication used before only as subroutine.

Page 14: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Deterministic: Supported Operations

Insert

Delete

i

i

i

Page 15: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Insert in V1: Update E

X = X* =

A B

C D

E F

G H

E = (A+BD*C)*

F = EBD*

G = D*CE

H = D*+D*CEBD*

V1 V2 V1 V2

V1

V2

V1

V2

A B C

*E = (A+BD*C)*=

D*

?

Page 16: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Insert in V2: Update E

X = X* =A B

C D

E F

G H

E = (A+BD*C)*

F = EBD*

G = D*CE

H = D*+D*CEBD*

V1 V2 V1 V2

V1

V2

V1

V2

B CD*

*E = (A+BD*C)*=

A

?

Page 17: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Idea: Work with Two Sets of Relations

X =A B

C D

V1 V2

V1

V2

E = (A+BD*C)*

F = EBD*

G = D*CE

H = D*+D*CEBD*

Insert in V1

H = (D+CA*B)*

G = HCA*

F = A*BH

E = A*+A*BHCA*

Insert in V2X =

AB

CD

V1V2

V1

V2

Page 18: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Insert in V1: Update F, G and H

X = X* =

A B

C D

E F

G H

E = (A+BD*C)*

F = EBD*

G = D*CE

H = D*+D*CEBD*

V1 V2 V1 V2

V1

V2

V1

V2

How can we updateF, G and H?

Problem:

E = =*

?

Page 19: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Idea: Exploit Associativity + E=E2

V2 V2 V1 V1 V2 V2V1

i

D* C B D*E E

EBCE

EBD*D*C E

H

D*H = +

Page 20: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Our Data Structure for X*

X = X* =A B

C D

E F

G H

V1 V2 V1 V2

V1

V2

V1

V2

E1 = (A+BP2C)*

F1 = E12BP

G1 = PCE12

H1 = PCE12BP

E2 = E1BH22CE1

F2 = E1BH22

G2 = H22CE1

H2 = (D+CE12B)*

E = E1+E2

G = G1+G2

H = H1+H2

F = F1+F2

P = D*

Page 21: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Our Data Structure for X*

We represent X* as the sum of two Boolean matrices:

X1 =E1

V1 V2

V1

V2

F1

G1 H1

X2 =E2

V1 V2

V1

V2

F2

G2 H2

Insert on V1 (resp. V2)Full update of X1 (resp. X2)

Lazy update of X2 (resp. X1)

Neither X1 nor X2 encode complete information about X*, but their sum does.

Page 22: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

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.

Page 23: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Breaking Through the O(n2) Barrier

Randomized algorithm (one-side error)on acyclic digraphs

O(n2-0.62+n1+)

O(n)for any 0 ≤ ≤ 1

Query:Update:

for =0.62O(n1.62)

O(n0.62)Query:Update:

Our results:

Page 24: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Starting Point: King/Sagert [STOC99]

C[u,x] C[y,v]

C[u,v] C[u,v] + C[u,x] · C[y,v]

C[u,v]

u x y v

Keep a count of the number of distinct paths in acyclic digraphs

Problem: counters as large as 2n

Solution: use arithmetic modulo a random prime

u,v:

Page 25: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Maintaining Dynamic Integer Matrices

Given a matrix M of integers, perform any intermixed sequence of the following operations:

+ ·

Update(J,I): M M + J · I

Query(i,j): return M[i,j]

Page 26: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Maintaining Dynamic Integer Matrices

Simple-minded method:

O(n2)

O(1)Query:Update:

O(n2-(3- ))

O(n)for any 0 ≤ ≤ 1

Query:Update:

= exp. mat. mult.

Our result:

Page 27: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Maintaining Dynamic Integer Matrices

Our data structure:

– Lazy approach: buffer at most n updates

– Global reconstruction every n updates

– Reconstruction done via matrix multiplication

Page 28: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Maintaining Dynamic Integer Matrices

m

M

m

i1 I1

j1

J1

+ j1· i1 i2 I2

j2

J2

+ j2· i2

i3 I3

j3

J3

+ j3· i3

Page 29: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Maintaining Dynamic Integer Matrices

i1 I1

j1

J1

+ j1· i1

i2 I2

j2

J2

+ j2· i2

i3 I3

j3

J3

+ j3· i3

m

M

m

·

M’

+

n

n

Global reconstruction every n updates

O(n2-(2-))

Page 30: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Time Bounds for Transitive Closure

O(n2-0.62 )

O(n)for any 0 ≤ ≤ 1

Query:Update: +n1+

Page 31: Fully Dynamic Transitive Closure: Breaking Through the O(n 2 ) Barrier

Directions for Further Research

Subquadratic algorithm for general digraphs?

Deterministic subquadratic algorithm?

Fully Dynamic Shortest Paths?