1 all-pairs shortest paths in undirected graphs Liam Roditty Uri Zwick Tel Aviv University...
-
Upload
kalyn-senter -
Category
Documents
-
view
219 -
download
1
Transcript of 1 all-pairs shortest paths in undirected graphs Liam Roditty Uri Zwick Tel Aviv University...
1
all-pairs shortest paths in undirected graphs
Liam Roditty Uri Zwick
Tel Aviv University
approximateDynamic
2
A graph
Dynamic Graph Problems
Initialize
InsertDelete
Query
n - number of verticesm - number of edges
3
Shortest Paths Problems
Single-Source Shortest Paths (SSSP)
All-Pairs Shortest Paths (APSP)
“Distance Oracles”
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
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
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)
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.
8
Decremental SSSP [Even-Shiloach ’81]
Every edge is only examined once
per level!
Total complexityis O(dm).
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
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
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.
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
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)
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+
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).
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
17
Approximate Distance Oracles [TZ’01]A hierarchy of centers
A0V ; Ak ; Ai sample(Ai-1,n-1/k) ;
18
Clusters A0=A1=A2=
1 1( ) { | ( , ) ( , )} ,i i iC w v V w v A v w A A
w
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
20
Bunches
1 1( ) { | ( , ) ( , )}i i ii
B v w A A w v A v
A0=A1=A2=
v
p1(v)
p2(v)
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).
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.
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)
24
Query answering algorithm
u v
w1=p1(v)A
1
w2=p2(u)A
2
w3=p3(v)A3
25
u v
wi-1=pi-1(v)Ai-1
wi=pi(u)Ai
Analysis
(i-1)ii
(i+1)
26
Open problems
• Faster dynamic SSSP algorithm?
• Exact dynamic APSP algorithm?
• Weighted graphs?
• Directed graphs?