analysis of algorithms

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

Upload: baldasarre-keenan

Post on 30-Dec-2015

23 views

Category:

Documents


0 download

DESCRIPTION

Analysis of Algorithms. Dynamic All-Pairs Shortest-Paths. Uri Zwick March 2014. TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A A A A. Locally Shortest Paths (LSPs). Demetrescu-Italiano (2004). shortest path. shortest path. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Analysis of Algorithms

Analysis of Algorithms

Uri ZwickMarch 2014

Dynamic All-Pairs Shortest-Paths

1

Page 2: Analysis of Algorithms

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

Shortest Path Extensions

shortest path

L[] - Left SP extensions

R[] - Right SP extensions

Page 4: Analysis of Algorithms

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

Combining two paths

Page 6: Analysis of Algorithms

(Static version)Demetrescu-Italiano (2004)

New shortest path

Page 7: Analysis of Algorithms

Static APSP algorithmDemetrescu-Italiano (2004)

Running time:

Uniqueness assumption:All shortest paths are unique

Page 8: Analysis of Algorithms

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

Static APSP algorithm

Page 10: Analysis of Algorithms
Page 11: Analysis of Algorithms

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

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

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

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

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

An empty vertex path

Page 17: Analysis of Algorithms

Converting an edge into a path

Page 18: Analysis of Algorithms

Combining two paths

Page 19: Analysis of Algorithms

Dynamic-APSP initialization

Page 20: Analysis of Algorithms

Insert and delete edges

Page 21: Analysis of Algorithms

Build-Paths

Page 22: Analysis of Algorithms

New-Shortest-Path

Page 23: Analysis of Algorithms

Examine a path

Page 24: Analysis of Algorithms

Removing a path

Page 25: Analysis of Algorithms

Update operations

Page 26: Analysis of Algorithms

A “full update” operation

Page 27: Analysis of Algorithms

Example: Many HPs and LSPs

n

Complete Complete Complete

n

n+1

2n

1

2

n

Page 28: Analysis of Algorithms

Phase 1: Decrease edge weights

n

Complete Complete Complete

n

n1

1

1

2

n

Page 29: Analysis of Algorithms

n

Complete Complete Complete

n

n1

1

n

n1

1

Phase 2: Increase edge weights

Page 30: Analysis of Algorithms

n

Complete Complete Complete

n

n1

1

n

2

1

n3 new LHPs created at each step