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

Post on 11-Jan-2016

36 views 0 download

Tags:

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

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 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?

Outline of the Talk

• State of the art on transitive closure

• Our results

• New deterministic algorithm

• New subquadratic algorithm

• Directions for further research

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

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)

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)

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

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)

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

?

?

Breaking Through the O(n2) Barrier

O(n) O(n)

Give up unit-cost queries ...

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

Main Ingredients

• Introduce a general framework for

maintaining dynamic matrices

• Cast dynamic transitive closure into this

framework

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.

Deterministic: Supported Operations

Insert

Delete

i

i

i

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*

?

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

?

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

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 = =*

?

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 = +

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*

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.

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.

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:

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:

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]

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:

Maintaining Dynamic Integer Matrices

Our data structure:

– Lazy approach: buffer at most n updates

– Global reconstruction every n updates

– Reconstruction done via matrix multiplication

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

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-))

Time Bounds for Transitive Closure

O(n2-0.62 )

O(n)for any 0 ≤ ≤ 1

Query:Update: +n1+

Directions for Further Research

Subquadratic algorithm for general digraphs?

Deterministic subquadratic algorithm?

Fully Dynamic Shortest Paths?