all-pairs shortest paths in undirected graphs
description
Transcript of all-pairs shortest paths in undirected graphs
![Page 1: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/1.jpg)
1
all-pairs shortest paths in undirected graphs
Liam Roditty Uri Zwick
Tel Aviv University
approximateDynamic
![Page 2: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/2.jpg)
2
A graph
Dynamic Graph Problems
Initialize
InsertDelete
Query
n - number of verticesm - number of edges
![Page 3: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/3.jpg)
3
Shortest Paths Problems
Single-Source Shortest Paths (SSSP)
All-Pairs Shortest Paths (APSP)
“Distance Oracles”
![Page 4: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/4.jpg)
4
Compact datastructure
APSP
algorith
m
mn 1/k time
n 1+1/k space
Approximate Distance Oracles (TZ’01)
O(1) query time stretch 2k-1
Stretch-Space tradeoff is
essentially optimal!
n by ndistancematrix
![Page 5: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/5.jpg)
5
Dynamic Shortest Paths Algorithms
ProblemTotal
update timeAmortized*
update timeQuerytimeAuthors
Decremental SSSPO(mn)O(n)O(1)Even-Shiloach ’81
ProblemAmortizedupdate time
QuerytimeAuthors
Fully-dynamic APSPO*(n2)O(1)Demetrescu-Italiano ’03
(Thorup ’04)
Decremental (1+)-approximate
APSPO*(mn)O*(n)O(1)This talk
Fully-dynamic (1+)- approximate
APSPO*(m1/2n)O(m1/2)This talk
![Page 6: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/6.jpg)
6
Compact datastructure
mn1/k timen1+1/k space
Decremental Approximate Distance Oracles
O(1) query time stretch 2k-1
Static
mn timem+n1+1/k space
Decremental
dmn1/k timem+n1+1/k space
Decremental(up to distance d)
![Page 7: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/7.jpg)
7
Three ingredients
Random Sampling Let P be a set of vertices of size k.
Let S be a random subset of vertices of size (cn ln n)/k.Then with high probability PS .
Even-Shiloach ’81A decremental algorithm for maintaining a single-
source shortest path tree of depth d with a total running time of O(dm).
Thorup-Zwick ’01Static approximate distance oracles.
![Page 8: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/8.jpg)
8
Decremental SSSP [Even-Shiloach ’81]
Every edge is only examined once
per level!
Total complexityis O(dm).
![Page 9: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/9.jpg)
9
Random Sampling
Select each elementindependently with probability
n
k
The probability that agiven set of k elements
is not hit is
ln1(1 )
kk cc n
nk
p
lnc np
k
![Page 10: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/10.jpg)
10
A sequence of SamplesLet Si be a subset obtained by selecting each
vertex with probability (c ln n)/(2i)
If v is contained in a connected component with at least 2i vertices, then:
2i
pi(v)
Let pi(v) be the vertex of Si closest to v
δ(v,pi(v)) ≤ 2i
![Page 11: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/11.jpg)
11
Maintaining the closest centers
To compute pi(v) for every v:
1. Add a new source vertex si.
2. Connect it to all vertices of Si.
3. Maintain a SSSP tree from si.
![Page 12: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/12.jpg)
12
Maintaining distances from centers
From each center of Si maintain a SSSP tree of depth 2i+2
222
ii
n mnm
Complexity:
2i+2
![Page 13: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/13.jpg)
13
Answering a distance query
Suppose:12 ( , ) 2i iu v
( , ( )) ( ( ), )i iu p u p u v
( ( ), ) ( , )ip u u u v
Return:
≤
12 ( , ) (1 2 ) ( , )i u v u v
≤
u v
pi(u)
![Page 14: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/14.jpg)
14
Answering a distance query
( , ( )) ( ( ), )i iu p u p u v Return:
u v
pi(u)
where i is smallest such that v is in the tree of pi(u), i.e.,
2( ( ), ) 2iip u v
This value of i can be found using binary search.
Query time: O(log log n)Stretch: 1+
![Page 15: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/15.jpg)
15
Reporting long distances in O(1) time
u v
pr(u) pr(v)
Suppose: 1/ 2( , )u v n
Let: 12 logr n
Return: ( , ( )) ( ( ), ( )) ( ( ), )r r r ru p u p u p v p v v
Maintain a table of all Sr to Sr distances.
Size of table is O(n).
![Page 16: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/16.jpg)
16
Reporting short distances in O(1) time
Suppose: 1/ 2( , )u v n
Develop a decremental version of the static approximate distance oracles of TZ.
The 3-approximation can be refined into a (1+)-approximation in O(1) time.
dmn1/k timem+n1+1/k space
stretch 2k-1
For distancesup to d
Taked=n1/2
k=2
![Page 17: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/17.jpg)
17
Approximate Distance Oracles [TZ’01]A hierarchy of centers
A0V ; Ak ; Ai sample(Ai-1,n-1/k) ;
![Page 18: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/18.jpg)
18
Clusters A0=A1=A2=
1 1( ) { | ( , ) ( , )} ,i i iC w v V w v A v w A A
w
![Page 19: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/19.jpg)
19
Bunches (inverse clusters)
1
1
1
1
( ) { | ( , ) ( , )} ,
( ) { | ( , ) (
( ) (
, }
)
)i i
i
ii
i i
C w v V w v A v
if w
w
B v w A A w v A
B
A A
v v C w
v
![Page 20: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/20.jpg)
20
Bunches
1 1( ) { | ( , ) ( , )}i i ii
B v w A A w v A v
A0=A1=A2=
v
p1(v)
p2(v)
![Page 21: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/21.jpg)
21
Approximate Distance Oracles [TZ’01]
The data structure
For every vertex vV:
• The centers p1(v), p2(v),…, pk-1(v)
• A hash table holding B(v)
For every wV, we can check, in
constant time, whether wB(v), and if so,
what is (v,w).
![Page 22: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/22.jpg)
22
Lemma: E[|B(v)|] ≤ kn1/k
Proof: |B(v)Ai| is stochastically
dominated by a geometric random
variable with parameter p=n-1/k.
![Page 23: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/23.jpg)
23
Query answering algorithm Algorithm
distk(u,v)
wu , i0
while wB(v)
{ i i+1
(u,v) (v,u)
w pi(u) }
return (w,u)+
(w,v)
![Page 24: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/24.jpg)
24
Query answering algorithm
u v
w1=p1(v)A
1
w2=p2(u)A
2
w3=p3(v)A3
![Page 25: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/25.jpg)
25
u v
wi-1=pi-1(v)Ai-1
wi=pi(u)Ai
Analysis
(i-1)ii
(i+1)
![Page 26: all-pairs shortest paths in undirected graphs](https://reader036.fdocuments.in/reader036/viewer/2022062301/56815841550346895dc598a6/html5/thumbnails/26.jpg)
26
Open problems
• Faster dynamic SSSP algorithm?
• Exact dynamic APSP algorithm?
• Weighted graphs?
• Directed graphs?