Shortest Paths
Approximate distance oracle
R. Inkulu
http://www.iitg.ac.in/rinkulu/
(Distance oracles)
1 / 11
Objective
Compute an approximate distance oracle (ADO) for undirected positive edge
weighted graphs with the objective of answering approximate distance queries
in o(m + n lg n) time using o(n2 ) space.
(Distance oracles)
2 / 11
Objective
e 1.5 ) space.
Compute a 3-approximate distance oracle that uses O(n
the approximation factor is with high probability (w.h.p.)
(Distance oracles)
3 / 11
Hitting set w.h.p. (review)
There exists a randomized algorithm that runs in time O(n) time and finds a
set S ⊆ X with |S| = O( Rn lg n) and for any {S1 , . . . , Sn } with
∀i Si ⊆ X, ∀i |Si | ≥ R such that S ∩ Si 6= φ holds w.h.p.
(Distance oracles)
4 / 11
Algorithm
preprocess:
(1) A be a random subset of V whose size is O( √nn lg n)
for the following sets)
(2) ∀u∈V , let B(u) be the ball comprising of closest
√
(which acts as a hitting set
n nodes to u in G
(3) ∀u∈V , C(u) = B(u) ∪ A
(4) ∀u∈V , ∀u0 ∈C(u) store d(u, u0 ) in a hash table Tu
∀u∈V , store the closest vertex of u in A with u and denote it as A(u)
(Distance oracles)
5 / 11
Algorithm
preprocess:
(1) A be a random subset of V whose size is O( √nn lg n)
for the following sets)
(2) ∀u∈V , let B(u) be the ball comprising of closest
√
(which acts as a hitting set
n nodes to u in G
(3) ∀u∈V , C(u) = B(u) ∪ A
(4) ∀u∈V , ∀u0 ∈C(u) store d(u, u0 ) in a hash table Tu
∀u∈V , store the closest vertex of u in A with u and denote it as A(u)
query(u,v):
(1) if v ∈ C(u) then return d(u, v) saved in Tu
(2) otherwise, return d(u, A(u)) + d(v, A(u)) (respectively obtained from Tu
and Tv )
(Distance oracles)
5 / 11
Analysis: case (i)
v3
v2
u
v1
if v ∈ C(u), query(u, v) = dG (u, v)
(Distance oracles)
6 / 11
Analysis: case (ii)
A(v)
A(u)
v
u
say min(d(u, A(u)) + d(v, A(u)), d(v, A(v)) + d(u, A(v))) is returned
query(u, v)
= d(u, A(u)) + d(u, A(u))
≤ d(u, A(u)) + d(u, A(u)) + d(u, v)
= 2d(u, A(u)) + d(u, v)
(Distance oracles)
7 / 11
Analysis: case (ii)
A(v)
A(u)
v
u
say min(d(u, A(u)) + d(v, A(u)), d(v, A(v)) + d(u, A(v))) is returned
query(u, v)
= d(u, A(u)) + d(u, A(u))
≤ d(u, A(u)) + d(u, A(u)) + d(u, v)
= 2d(u, A(u)) + d(u, v)
since v ∈
/ C(u), if A(u) ∈ B(u) then d(u, A(u)) ≤ d(u, v);
indeed, d(u, A(u)) ≤ d(u, v) w.h.p., as A ∩ B(u) 6= φ w.h.p.
2d(u, A(u)) + d(u, v)
≤ 3d(u, v) w.h.p.
(Distance oracles)
7 / 11
Analysis: case (iii)
A(v)
A(u)
v
u
error is not bounded
however, the probability of occurence is polynomially small
(Distance oracles)
8 / 11
Analysis (cont)
The size of all hash tables is O(n1.5 lg n).
√
size of A is O( n lg n)
√
for any v ∈ V, size of B(v) is O( n)
√
for any v ∈ V, size of C(v) is O( n lg n)
and, there are n hashtables, one corresponding to each node of G
(Distance oracles)
9 / 11
Thorup and Zwick ’01 result
1
e 1+ k ) space,
For all integers k ≥ 1, there exists a (2k − 1)-ADO using O(kn
1
e
k ) time for preprocessing, and can answer queries in O(k) time.
O(mn
— not explained further in class
The above algorithm is for k = 2.
(Distance oracles)
10 / 11
Lower bound on space used by ADO
Let f (k, n) be a lower bound on the number of edges in a graph G with girth
≥ 2k + 2. Then any t-approximate distance oracle for t < 2k + 1 must use at
least f (k, n) bits of space.
* consider any two distinct subgraphs G0 and G00 of G such that edge (u, v) ∈ G0 and (u, v) ∈
/ G0 ;
then dG (u, v) = 1 ≤ ADOG0 (u, v) ≤ t < 2k + 1 ≤ ADOG00 (u, v)
since ADOG0 (u, v) 6= ADOG00 (u, v) and since both the ADOs use the same (preprocessing and/or
query) algorithm, it must be using difference storage space sizes for G0 and G00
* since there are 2f (k,n) subgraphs of G, ADO must be using at least lg 2f (k,n) distinct sized storage
spaces, one corresponding to each such subgraph; hence, the preprocessed data structures of ADO
occupy at least f (k, n) bits.
(Distance oracles)
11 / 11
© Copyright 2026 Paperzz