30
Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest- Paths 1

Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

Embed Size (px)

Citation preview

Page 1: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

Analysis of Algorithms

Uri ZwickMarch 2014

Dynamic All-Pairs Shortest-Paths

1

Page 2: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

Demetrescu-Italiano (2004)Locally Shortest Paths (LSPs)

shortest path

shortest path

A LSP is not necessarily a SPs

is a LSP iff l[] and r[] are SP

Page 3: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

Shortest Path Extensions

shortest path

L[] - Left SP extensions

R[] - Right SP extensions

Page 4: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

Run Dijkstra “in parallel” from all vertices

Consider only LSPs

Keep left and right extensions of SPs found

Keep candidate SPs in a priority queue

(Static version)Demetrescu-Italiano (2004)

Page 5: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

Combining two paths

Page 6: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

(Static version)Demetrescu-Italiano (2004)

New shortest path

Page 7: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

Static APSP algorithmDemetrescu-Italiano (2004)

Running time:

Uniqueness assumption:All shortest paths are unique

Page 8: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

SP(u,v) denotes the shortest path from u to v(Not explicitly maintained)

p[u,v] – The second vertex on the shortest path from u to v found so far

q[u,v] – The penultimate vertex on the shortest path from u to v found so far

L[u,v] – A list of vertices w for whichwSP(u,v) is known to be a shortest path

R[u,v] – A list of vertices w for whichSP(u,v) w is known to be a shortest path

dist[u,v] – The length of the shortest path from u to v found so far

Page 9: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

Static APSP algorithm

Page 10: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this
Page 11: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

Dynamic algorithms

An incremental algorithm only allows insertions

An decremental algorithm only allows deletions

A fully-dynamic algorithm allows both insertion and deletions

Page 12: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

Example: Many LSPs

Every path is an LSP – n3 paths

Two complete layers

Can assign weights so that all SPs are unique

n

Page 13: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

Blue edges are significantly lighter than black edges

Example: Many LSP changes

When red edge inserted, all previous LSPs destroyed

When red edge deleted, all previous LSPs recreated

0

Page 14: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

A path is historic, if it was a shortest path at somepoint of time after the last update of one of its vertices

Historical Paths (HPs)

Let be a path at time t

Let t’ be the time of the last update, before t, on

A path is historic at time t if and only if there exists t’ t’’ t such that is a SP at time t’’

A path stops being historic only as a result of an update on it

Page 15: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

Demetrescu-Italiano (2004)Locally Historical Paths (LHPs)

historical path

historical path

l[] and r[] are not necessarily shortest at the same time

is a LHP iff l[] and r[] are HP

Page 16: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

An empty vertex path

Page 17: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

Converting an edge into a path

Page 18: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

Combining two paths

Page 19: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

Dynamic-APSP initialization

Page 20: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

Insert and delete edges

Page 21: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

Build-Paths

Page 22: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

New-Shortest-Path

Page 23: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

Examine a path

Page 24: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

Removing a path

Page 25: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

Update operations

Page 26: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

A “full update” operation

Page 27: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

Example: Many HPs and LSPs

n

Complete Complete Complete

n

n+1

2n

1

2

n

Page 28: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

Phase 1: Decrease edge weights

n

Complete Complete Complete

n

n1

1

1

2

n

Page 29: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

n

Complete Complete Complete

n

n1

1

n

n1

1

Phase 2: Increase edge weights

Page 30: Analysis of Algorithms Uri Zwick March 2014 Dynamic All-Pairs Shortest-Paths 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this

n

Complete Complete Complete

n

n1

1

n

2

1

n3 new LHPs created at each step