an almost linear fully dynamic reachability algorithm

33
An almost An almost linear linear fully fully dynamic dynamic reachability reachability algorithm algorithm

Post on 20-Dec-2015

224 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: An almost linear fully dynamic reachability algorithm

An almost An almost linearlinear fully dynamic fully dynamic reachabilityreachability algorithm algorithm

Page 2: An almost linear fully dynamic reachability algorithm

Dynamic graph algorithmsDynamic graph algorithms

Maintain some information

Page 3: An almost linear fully dynamic reachability algorithm

Dynamic Algorithms – Formal DefinitionsDynamic Algorithms – Formal Definitions

In a fully dynamic algorithmfully dynamic algorithm the graph can be updated using the following operations:

•InsertInsert – Add edges to the graph.•DeleteDelete – Remove edges from the graph.

A partially dynamic algorithmpartially dynamic algorithm can be an incremental algorithm that supports only insertions or a decremental algorithm that supports only deletions.

A query can reach at any moment and we should be A query can reach at any moment and we should be ready to answer it correctly…ready to answer it correctly…

Page 4: An almost linear fully dynamic reachability algorithm

Dynamic graph algorithmsDynamic graph algorithms

Strong Connectivity

Page 5: An almost linear fully dynamic reachability algorithm

Reachability

Fully dynamic reachabilityFully dynamic reachability

1

3

2

4

5

1,4 ? 1,2 ?Yes YesNo

Page 6: An almost linear fully dynamic reachability algorithm

Our mission …

• Make the processing after each update faster than re-computing everything from scratch using a static algorithm.

• Answer queries as fast as we can.

Page 7: An almost linear fully dynamic reachability algorithm

Small Query Time:

Maintain explicitly the transitive closure matrix.

Query is done in O(1), each update may take (n2)

time.

Fully dynamic reachability

Page 8: An almost linear fully dynamic reachability algorithm

Small Query Time:

Maintain explicitly the transitive closure matrix.

Query is done in O(1), each update may take (n2)

time.

Fully dynamic reachability

Small Update Time: A data structure which may have a non-constant query time but with smaller update time.

Open problem:

Is it possible to break the (n2) update barrier ?

Yes: Updates in O(m+n log n) and queries in O(n)

Page 9: An almost linear fully dynamic reachability algorithm

Update Update timetime

Query Query timetime

n2

n

1 n

n n

n2 n

m n

n1.575

n0.575 n

m+n logn

General

graphs

mn t

DAG

m

t

Fully dynamic reachabilityFully dynamic reachability

Page 10: An almost linear fully dynamic reachability algorithm

An An overviewoverview of the of the algorithmalgorithmOur algorithm supports the following operations:

Insert(Ew) – Insert the edges Ew all touching w into the graph

Delete(E’ ) – Delete all edges of E’ from the graph

Query(u,v) – Check whether there is a directed path from u to v

G(V,E0)

Insert(Ev)

G(V,E0Ev)

Insert(Eu)

G(V,E0Ev Eu)

Page 11: An almost linear fully dynamic reachability algorithm

An An overviewoverview of the of the algorithmalgorithm

G(V,E0)

Insert(Ev)

G(V,E0Ev)

Insert(Eu)

G(V,E0Ev Eu)u

vx y

v

x

y

Insert( Insert( EEw w )) :: Create Create twotwo trees to capture new paths trees to capture new pathsQuery(u ,v ):Query(u ,v ): w, u w, u T Tinin(w) (w) v v T Toutout(w)(w)

Delete( E’ ): Delete( E’ ): Delete Delete E’E’ from all trees from all trees

Our algorithm works as follows:

Page 12: An almost linear fully dynamic reachability algorithm

Insert(Ev1)

v1

Insert(Ev2) Insert(Ev3

)

v2 v3 vl

Insert(Evl)

An An overviewoverview of the algorithm of the algorithm

The main problem is to delete edges efficiently from this forest.

In(vIn(v11))

Out(vOut(v11))

Page 13: An almost linear fully dynamic reachability algorithm

…v1 v2 v3 vl

A simple solution for DAGsA simple solution for DAGs

The total time required to maintain a decremental single source reachability (DSSR) tree in directed acyclic graph is only O(m) (Itliano ’88) Each edge is scanned only once in each tree

Insert( Insert( EEw w ))Query(u ,v)Query(u ,v)

Delete( E’ )Delete( E’ )

O (n )

O (1 )

O (m+n)

Page 14: An almost linear fully dynamic reachability algorithm

…v1 v2 v3 vl

The problem with general graphsThe problem with general graphs

There is not any obvious way to generalize Itliano’s algorithm to general graphs. The best algorithm for DSSR requires O(mn)

time.

Insert( Insert( EEw w ))Query(u ,v)Query(u ,v)

Delete( E’ )Delete( E’ )

O (n )

O (1 )

O (mn)O (n )

O (m+n log n)

O (m+n log n)

Page 15: An almost linear fully dynamic reachability algorithm

…v1 v2 v3 vl

Our SolutionOur Solution

Maintain the trees with respect to Maintain the trees with respect to Strongly Connected ComponentsStrongly Connected Components

Problem 1Problem 1: We may have n : We may have n trees each with different trees each with different components!components!

Problem 2Problem 2: When a component is : When a component is decomposed we have to update decomposed we have to update the edges such that an edge is the edges such that an edge is never examine twice!never examine twice!

Page 16: An almost linear fully dynamic reachability algorithm

We solve Problem 1 using fully dynamic strong connectivity algorithm with update time of O(m(m,n)).

v1

In(vIn(v11))

Out(vOut(v11))

v2

In(vIn(v22))

Out(vOut(v22))

v4

In(vIn(v44))

Out(vOut(v44))

v5

In(vIn(v55))

Out(vOut(v55))

v3

In(vIn(v33))

Out(vOut(v33))

Fully dynamic strong connectivity with “persistency”

Detect and report on decompositions

Updating edge lists

Updating edge lists

Page 17: An almost linear fully dynamic reachability algorithm

Supported operations:

G0=(V,E0)

Insert(E’)

Fully dynamic strong connectivity

G0=(V,E0) G1=(V,E0E’)G1=(V,E1)

Insert(E’’)

G1=(V,E1) G2=(V,E1E’’)G2=(V,E2)

Delete( E’ ) – Delete the set E’ from all versions.

Query(u,v,i) – Are u and v in the same component in Gi

Insert( E’ ) – Create a new version and add E’ to it.

Note that these operations create a graph sequence G0(V,E0), G1(V,E1), … , Gt(V,Et) where E0 E1 … Et .This containment is kept during all the update operations!

O (m(m,n))O (m(m,n))O (1

)

Page 18: An almost linear fully dynamic reachability algorithm

Fully dynamic strong connectivityThe components of all the graphs in the sequence are arranged in a hierarchy and can be represented as a forest of size O (n )

G0 G1 G2 G3

The components: The forest:G0 G1 G2 G3

1

1

1

2

3

u

v

Query(u,v,1) Version( LCA(u,v) ) 1Query(u,v,2) Version( LCA(u,v) ) 2

Version tag

Page 19: An almost linear fully dynamic reachability algorithm

Hi+1Hi

A new partitioning of the edges E1,…, Et

Definition 1: A partitioning of the graph sequence edges

Hi = { (u,v) Ei | Query(u,v,i) (Query(u,v,i-1)(u,v)Ei-1) }

Ht+1 = Et \ Hii=1

t

Gi-1=(V,Ei-1) Gi=(V,Ei) Gi+1=(V,Ei+1)

Hi Hj = ø,Et = Hii=1

t+1

Page 20: An almost linear fully dynamic reachability algorithm

G0 G1 G2 G3

FindScc(H1,1) FindScc(H2,2)Shift(H1,H2) Shift(H2,H3)

FindScc(H3,3)Shift(H3,H4)

Cost Analysis: Note that an edge enters and leave Hi just once Moving edges – Paid by the creation of the version they enter. FreeFixed edges – Paid by the current delete operation O(m)

Processing a deletion

Hi edges

Before…After !

Page 21: An almost linear fully dynamic reachability algorithm

G0 G1 G2 G3

The component forest

Page 22: An almost linear fully dynamic reachability algorithm

We solve Problem 1 using fully dynamic strong connectivity algorithm with update time of O(m(m,n)).

v1

In(vIn(v11))

Out(vOut(v11))

v2

In(vIn(v22))

Out(vOut(v22))

v4

In(vIn(v44))

Out(vOut(v44))

v5

In(vIn(v55))

Out(vOut(v55))

v3

In(vIn(v33))

Out(vOut(v33))

Fully dynamic strong connectivity with “persistency”

Detect and report on decompositions

Updating edge lists

Updating edge lists

Page 23: An almost linear fully dynamic reachability algorithm

•Every edge is examined only once! (If the graph is DAG)•Total complexity is O(m).•For general graphs use the graph components as vertices

Decremental reachability treeTin(v)

Tout(v)

v

v

Page 24: An almost linear fully dynamic reachability algorithm

Decremental reachability tree

When a decomposition is reported (by the strong connectivity algorithm), we need to:• Create edge list for the new components• Connect the new components to the tree

O(n log n)O(m)

Total time

Page 25: An almost linear fully dynamic reachability algorithm

• The list in[v] contains only uninspected incoming edges. • The list out[v] contains all the outgoing edge.• A vertex v is active if in[v] is not empty

Decremental reachability tree Data structures

Every component maintains a list of its active vertices

v

in[v]

component

Tree invariant: The first edge of the first vertex in the component active vertices list is the edge that connects the component to the tree. If the component is not connected then its active vertices list is empty

Page 26: An almost linear fully dynamic reachability algorithm

component

- An active vertex- An uninspected incoming edge- A tree edge

- A none active vertex

Deletions of non tree edges

- A deleted edge

Deletions of a tree edge – we search for an edge (u,v) such that the component that contains u satisfies the tree invariant

Decremental reachability tree Edge deletion

Page 27: An almost linear fully dynamic reachability algorithm

Decremental reachability tree Disconnecting a component

component

- An active vertex- An uninspected incoming edge- A tree edge

- A none active vertex- A deleted edge

Disconnecting a component.

How do we find the components vertices ?

Page 28: An almost linear fully dynamic reachability algorithm

G0 G1 G2 G3

The component forestcomponent

uOut[u]

Page 29: An almost linear fully dynamic reachability algorithm

We generalized the decremented reachability tree to general graphs by using the components of the graph.

Each edge in the connection process is still scanned only once.

We have to deal with decomposition.

We like to create active lists for new components in efficient way.

Decremental reachability tree

Page 30: An almost linear fully dynamic reachability algorithm

Decremental reachability tree Decomposition

component

Component2

Size = 5

Component1

Size =2

•The largest components among the new components inherits the list of the decomposed component.

•Using the component forest each vertex from a small component is removed from the list and added to its new component list.

The component decomposed to two new components one of size 5 and one of size 2.

Page 31: An almost linear fully dynamic reachability algorithm

Decremental reachability tree Analysis

Component2

Size = 5

Component1

Size =2

Scanning the component vertices can be done in time proportional to the component size. We only scan ‘small’ components.

Let’s analyze the total cost:

If a vertex is moved from one active list to another, the size of the component containing it must have decreased by a factor of at least 2.

Page 32: An almost linear fully dynamic reachability algorithm

Summing up

• The total connection cost is O(m)

• The total decomposition cost is O(n log n)

For each tree

Each update costs O(m + n log n)

Page 33: An almost linear fully dynamic reachability algorithm

Open problems

• Reduce the query time to m/n ?

• Reduce the update time to O(m+n) ?

• Design other fully dynamic algorithm for a graph sequence ?

• A single decremental reachability tree in general graph in o(mn) ?