Download - Analysis of Algorithms
![Page 1: Analysis of Algorithms](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/1.jpg)
Analysis of Algorithms
Uri ZwickMarch 2014
Dynamic All-Pairs Shortest-Paths
1
![Page 2: Analysis of Algorithms](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/2.jpg)
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](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/3.jpg)
Shortest Path Extensions
shortest path
L[] - Left SP extensions
R[] - Right SP extensions
![Page 4: Analysis of Algorithms](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/4.jpg)
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](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/5.jpg)
Combining two paths
![Page 6: Analysis of Algorithms](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/6.jpg)
(Static version)Demetrescu-Italiano (2004)
New shortest path
![Page 7: Analysis of Algorithms](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/7.jpg)
Static APSP algorithmDemetrescu-Italiano (2004)
Running time:
Uniqueness assumption:All shortest paths are unique
![Page 8: Analysis of Algorithms](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/8.jpg)
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](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/9.jpg)
Static APSP algorithm
![Page 10: Analysis of Algorithms](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/10.jpg)
![Page 11: Analysis of Algorithms](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/11.jpg)
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](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/12.jpg)
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](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/13.jpg)
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](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/14.jpg)
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](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/15.jpg)
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](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/16.jpg)
An empty vertex path
![Page 17: Analysis of Algorithms](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/17.jpg)
Converting an edge into a path
![Page 18: Analysis of Algorithms](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/18.jpg)
Combining two paths
![Page 19: Analysis of Algorithms](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/19.jpg)
Dynamic-APSP initialization
![Page 20: Analysis of Algorithms](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/20.jpg)
Insert and delete edges
![Page 21: Analysis of Algorithms](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/21.jpg)
Build-Paths
![Page 22: Analysis of Algorithms](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/22.jpg)
New-Shortest-Path
![Page 23: Analysis of Algorithms](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/23.jpg)
Examine a path
![Page 24: Analysis of Algorithms](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/24.jpg)
Removing a path
![Page 25: Analysis of Algorithms](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/25.jpg)
Update operations
![Page 26: Analysis of Algorithms](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/26.jpg)
A “full update” operation
![Page 27: Analysis of Algorithms](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/27.jpg)
Example: Many HPs and LSPs
n
Complete Complete Complete
n
n+1
2n
1
2
n
![Page 28: Analysis of Algorithms](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/28.jpg)
Phase 1: Decrease edge weights
n
Complete Complete Complete
n
n1
1
1
2
n
![Page 29: Analysis of Algorithms](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/29.jpg)
n
Complete Complete Complete
n
n1
1
n
n1
1
Phase 2: Increase edge weights
![Page 30: Analysis of Algorithms](https://reader034.vdocuments.us/reader034/viewer/2022051416/56812b92550346895d8fb00d/html5/thumbnails/30.jpg)
n
Complete Complete Complete
n
n1
1
n
2
1
n3 new LHPs created at each step