scispace - formally typeset
Open AccessBook ChapterDOI

All-pairs nearly 2-approximate shortest-paths in O ( n 2 polylog n ) time

TLDR
The first expected O(n2) time algorithm to compute all-pairs 3-approximate distances is presented, and it is shown that for any u,v ∈ V reports distance no greater than 2δ(u,v) + 1, the longest path/distance reported by the algorithm is not longer/greater than t · δ(U,v).
Abstract
Let G(V,E) be an unweighted undirected graph on |V | = n vertices. Let δ(u,v) denote the shortest distance between vertices u,v ∈ V. An algorithm is said to compute all-pairs t-approximate shortest-paths/distances, for some t ≥ 1, if for each pair of vertices u,v ∈ V, the path/distance reported by the algorithm is not longer/greater than t · δ(u,v). This paper presents two randomized algorithms for computing all-pairs nearly 2-approximate distances. The first algorithm takes expected O(m2/3n log n + n2) time, and for any u,v ∈ V reports distance no greater than 2δ(u,v) + 1. Our second algorithm requires expected O(n2 log3/2) time, and for any u,v ∈ V reports distance bounded by 2δ(u,v)+3. This paper also presents the first expected O(n2) time algorithm to compute all-pairs 3-approximate distances.

read more

Content maybe subject to copyright    Report

All-Pairs Nearly 2-Approximate Shortest-Paths
in O(n
2
polylog n) Time
Surender Baswana
1
, Vishrut Goyal
2
, and Sandeep Sen
3
1
Max-Planck-Institut ur Informatik, Saarbr¨ucken, Germany.
sbaswana@mpi-sb.mpg.de
2
Persistent Systems Private Limited, Pune, India.
vishrut
goyal@persistent.co.in
3
Department of Computer Science and Engineering, I.I.T. Kharagpur, India.
ssen@cse.iitkgp.ernet.in
Abstract. Let G(V, E) be an unweighted undirected graph on |V | = n
vertices. Let δ(u, v) denote the shortest distance between vertices u, v
V . An algorithm is said to compute all-pairs t-approximate shortest-
paths/distances, for some t 1, if for each pair of vertices u, v V ,
the path/distance reported by the algorithm is not longer/greater than
t · δ(u, v).
This paper presents two randomized algorithms for computing all-
pairs nearly 2-approximate distances. The first algorithm takes expected
O(m
2/3
n log n+n
2
) time, and for any u, v V reports distance no greater
than 2δ(u, v) + 1. Our second algorithm requires expected O(n
2
log
3/2
)
time, and for any u, v V reports distance bounded by 2δ(u, v) + 3.
This paper also presents the first expected O(n
2
) time algorithm to
compute all-pairs 3-approximate distances.
1 Introduction
All-pairs shortest path problem is undoubtedly one of the most fundamental
algorithmic graph problem. Given a graph G(V, E) on n(= |V |) vertices and
m(= |E|) edges, the problem requires computation of shortest-paths/distances
between each pair of vertices. There are various versions of this problem de-
pending on whether the graph is directed or undirected, edges are weighted or
unweighted, weights are positive or negative. In its most generic version, that is,
for directed graph with real edge-weights, the best known algorithm [6] for this
problem requires O(mn+n
2
log log n) time. However, for graphs with m = θ(n
2
),
this algorithm has a running time of θ(n
3
) which matches that of the old and
classical algorithm of Floyd and Warshal. The best known upper bound on the
time complexity of this problem is O(n
3
log log n/ log n) due to Zwick [10],
which is marginally sub-cubic.
In the recent past, there has been a growing interest in designing efficient
(sub-cubic running time) and simple algorithms for all-pairs approximate shortest-
paths, and successful attempts have been made for undirected graphs. Zwick [9]
provides an excellent survey on algorithms for computing approximate shortest

All-Pairs Nearly 2-Approximate Shortest-Paths in O(n
2
polylog n) Time 661
paths. An algorithm is said to compute all-pairs t-approximate distances, if for
any pair of vertices u, v V , the distance δ
(u, v) reported by the algorithm
satisfies 1
δ
(u,v)
δ(u,v)
t. In the following paragraph, we provide a very brief
summary of the current state-of-the-art algorithms for all-pairs t-approximate
shortest paths.
Cohen and Zwick [2], building upon the work of Dor et al. [3], designed
an algorithm that given any undirected weighted graph with n vertices and m
edges, computes all-pairs 2-approximate shortest paths in O(n
3/2
m) time and
all-pairs 3-approximate shortest paths in just O(n
2
log n) time. For unweighted
graphs, given arbitrarily small ζ, , ρ > 0, Elkin [4] designed an algorithm that
requires O(mn
ρ
+ n
2+ζ
) time, and for any pair of vertices u, v V , reports
distance δ
(u, v) satisfying the inequality :
δ(u, v) δ
(u, v) (1 + )δ(u, v) + β
where β is a function of ζ, , ρ. If the two vertices u, v V are separated by
sufficiently long distances in the graph, the stretch
δ
(u,v)
δ(u,v)
ensured by Elkin’s
algorithm is quite close to (1 + ). But the stretch factor may be quite huge for
short paths since β depends on ζ as (1)
log 1
, depends inverse exponentially
on ρ and inverse polynomially on . Thorup and Zwick [7] introduced a remark-
able data-structure called approximate distance oracle, that requires sub-cubic
preprocessing time and sub-quadratic space, and yet answers an approximate-
distance query in constant time (hence the name oracle). For a given integer
k 2, the space of the approximate distance oracle is O(kn
1+1/k
) and it reports
any (2k 1)-approximate distance query in O(k) time. The preprocessing time
for (2k 1)-approximate distance oracle is O(mn
1/k
) which has been improved
to O(min(mn
1/k
, n
2
log n)) for unweighted graphs in [1]. Thorup and Zwick [7]
also show that for any t < 3, a data-structure that answers any t-approximate
distance query in constant time must occupy θ(n
2
) space. This implies a lower
bound of (n
2
) on space as well as on time complexity of any algorithm that an-
swers any 2-approximate distance query in constant time. As mentioned above,
the algorithm of Cohen and Zwick [2] establishes an upper bound of O(n
3/2
m)
on time complexity of all-pairs 2-approximate shortest path problem.
1.1 Our Contribution
As an important contribution of this paper, we show that we can, in time
O(n
2
polylog n), compute all-pairs nearly 2-approximate shortest paths for un-
weighted undirected graphs.
1. We first design a data-structure that, given any u, v V , requires constant
time to report distance bounded by 2δ(u, v) + 1, that is, an additive error
of one unit over the 2-approximate distance. The expected preprocessing
time required to build this data-structure is O(m
2/3
n log n + n
2
). In this
way, our new algorithm, at the expense of introducing an additive error of
just one unit, achieves a significant improvement in the running time over

662 Surender Baswana, Vishrut Goyal, and Sandeep Sen
the previous best algorithm [2] for all-pairs 2-approximate distances. The
improvement is by a factor of at-least n
1/6
for the range m > n
3/2
, whereas
for m < n
3/2
, the new algorithm takes expected O(n
2
) time.
2. We further reduce the expected preprocessing time to O(n
2
log
3/2
n) at the
expense of increasing the additive error to 3, that is, given any pair of vertices
u, v V , the distance δ
(u, v) reported by our data-structure satisfies
δ(u, v) δ
(u, v) 2δ(u, v) + 3
As would become clear subsequently from the paper, the additive error shows
up only in some restricted worst case only. In general, the algorithm will
behave very much like a 2-approximate shortest path algorithm.
3. As an additional and final contribution, this paper shows that it takes ex-
pected O(n
2
) time to compute 3-approximate distance oracle of size O(n
3/2
).
Without any modifications, all our data-structures for reporting approximate
distances can also be used to report approximate shortest-paths in optimal time.
2 A New Scheme for 2-Approximate Shortest Paths
Let G(V, E) be an unweighted graph. The basic construct of our scheme is a
restricted breadth-first-search (BFS) tree defined as Ball as follows.
Definition 1. For a vertex u and a set R V of vertices, Ball(u, R) denotes
the set of vertices of the graph, such that the distance from u to these vertices is
less than the distance from u to the nearest vertex of the set R.
New scheme for approximate distance
Let R V be a set of vertices. Let n
u
denote the vertex from the set R nearest
to u.
1. Global distance information
For each vertex s R, keep a BFS tree storing distance to all the vertices
in the graph.
2. Local distance information
For each vertex u V \R, compute distance to all the vertices of Ball(u, R)
and its nearest vertex n
u
.
3. Keep a data-structure to determine, in constant time, whether any two
Balls overlap (share a common vertex) or not.
The above scheme may appear similar to 3-approximate distance oracle of Tho-
rup and Zwick [7] except the third step. It is this step that proves to be crucial
in achieving 2-approximate distances.
Now we shall describe how our scheme can be used to answer a distance
query with stretch 2.

All-Pairs Nearly 2-Approximate Shortest-Paths in O(n
2
polylog n) Time 663
Case−1 Case−2
Case−3
PSfrag replacements
a
a + 1
b
b + 1
uu
u v
v
vw
n
u
n
u
n
u
n
v
n
v
x
vertex of set R
Fig. 1. Three cases in reporting distance between u and v
Answering distance query using new scheme
Q(u, v) : We answer a distance query between u and v in the following order.
If v Ball(u, R) or u Ball(v, R) :
report δ(u, v)
Else if Ball(u, R) and Ball(v, R) overlap :
report δ(u, w) + δ(v, w) for some w Ball(u, R) Ball(v, R)
Else :
report minimum of (δ(u, n
u
) + δ(n
u
, v)) and (δ(v, n
v
) + δ(n
v
, u))
The query Procedure Q(u, v) explores all the three possible cases in the fixed
order. In the first two cases, we manage to report distance using only the local
distance information stored at vertices u and v. In the final and the third case,
when the two Balls are non-overlapping, we use the global distance information
stored at n
u
and n
v
.
Lemma 1. Given a graph G(V, E) and any two vertices u, v V , the approx-
imate distance between u and v as reported by the query procedure Q(u, v) is
bounded by 2δ(u, v) + 1.
Proof. Let a and b be the radii of Ball(u, R) and Ball(v, R) respectively. The
approximation factor associated with the distance reported by Q(u, v) depends

664 Surender Baswana, Vishrut Goyal, and Sandeep Sen
on which of the three steps, we report the distance at. So we analyze the three
cases as follows:
Case 1 : The distance is reported in the first step of Q(u, v).
In this case, either u or v lie in the Ball of the other. Without loss of generality,
let us assume that v lies in Ball(u, R) (see Fig. 1, Case-1). Here we report the
exact distance between u and v.
Case 2 : The distance is reported in the second step of Q(u, v).
Note that since the query procedure failed to report the distance in the first step,
therefore, the distance between u and v is more than the radius of Ball(u, R)
and Ball(v, R). In other words, δ(u, v) is more than a and b. (see Fig. 1, Case-2).
Let w be a vertex lying in both Ball(u, R) and Ball(v, R). Clearly, δ(u, w)
a and δ(v, w) b. Therefore, the distance reported in this step is bounded by
a + b, which is no more than 2δ(u, v) as explained above.
Case 3 : The distance is reported in the third step of Q(u, v).
Since the query procedure failed to report the distance in the second step,
Ball(u, R) and Ball(v, R) are separated by distance x 1. So the shortest
path between u and v can be viewed as consisting of three sub-paths : the first
subpath is the portion of the path lying inside Ball(u, R) and has length a, the
second sub-path is the portion of the path lying outside the two Balls and has
length x, and the third sub-path is the portion of the path lying inside Ball(v, R)
and has length b. Hence, the distance between u and v is a+x+b for some x 1.
(see Fig. 1, Case-3).
In the third step, we report the minimum of (δ(u, n
u
)+δ(n
u
, v)) and (δ(v, n
v
)+
δ(n
v
, u)). It can be noted that δ(u, n
u
) = a + 1 and δ(v, n
v
) = b + 1. Now con-
sidering the path from n
u
to v passing through u, we can observe that δ(n
u
, v)
is bounded by 2a + x + b + 1. Similarly, analyzing the path from n
v
to u passing
through v, we can observe that δ(n
v
, u) is bounded by 2b + x + a + 1. Therefore,
the distance reported by Q(u, v) is bounded as follows.
min((δ(u, n
u
) + δ(n
u
, v)) , (δ(v, n
v
) + δ(n
v
, u)))
min(3a + x + b + 2, 3b + x + a + 2)
= min(3a + b, 3b + a) + x + 2
= 3b + a + x + 2 {wlog assume that a b}
2a + 2b + x + 2 {since a b}
2(a + x + b) + 1 {since x 1}
= 2δ(u, v) + 1
Hence, the distance between u, v as reported by Q(u, v) is bounded by 2δ(u, v)+1.
Remark: It is worth noting that the distance between any two vertices u, v V ,
as reported by Q(u, v), is bounded by 2δ(u, v) even in the Case-3, if at-least
one of the following conditions hold:
(i) x > 1, that is, the two Balls are separated by a path longer than one edge.
(ii) a 6= b, that is, the radii of the two Balls differs.

Citations
More filters
Proceedings ArticleDOI

Fast approximation algorithms for the diameter and radius of sparse graphs

TL;DR: This paper presents the first improvement over the diameter approximation algorithm of Aingworth et.
Journal IssueDOI

A simple and linear time randomized algorithm for computing sparse spanners in weighted graphs

TL;DR: The size of the t-spanner computed essentially matches the worst case lower bound implied by a 43-year old girth lower bound conjecture made independently by Erdos, Bollobas, and Bondy & Simonovits.
Proceedings ArticleDOI

Better approximation algorithms for the graph diameter

TL;DR: Two algorithms are deterministic, and thus the first deterministic (2 -- e)-approximation algorithm for the diameter that takes subquadratic time in sparse graphs is presented.
Journal ArticleDOI

Approximate distance oracles for unweighted graphs in expected O(n2) time

TL;DR: This article shows that one can actually construct approximate distance oracles in expected O(n) time if the graph is unweighted, and leads to the first expected linear-time algorithm for computing an optimal size (2, 1)-spanner of an unweighting graph.
Proceedings ArticleDOI

Faster Algorithms for Approximate Distance Oracles and All-Pairs Small Stretch Paths

TL;DR: An O(n2 log n) algorithm is presented to construct a data structure of size O(kn1+1k/) for all integers k ges 2 and a new generic scheme for all-pairs approximate shortest paths is used for these results.
References
More filters
Journal ArticleDOI

Gaussian elimination is not optimal

TL;DR: In this paper, Cook et al. gave an algorithm which computes the coefficients of the product of two square matrices A and B of order n with less than 4. 7 n l°g 7 arithmetical operations (all logarithms in this paper are for base 2).
Journal ArticleDOI

Matrix multiplication via arithmetic progressions

TL;DR: In this article, a new method for accelerating matrix multiplication asymptotically is presented, based on the ideas of Volker Strassen, by using a basic trilinear form which is not a matrix product.
Journal ArticleDOI

Storing a Sparse Table with 0(1) Worst Case Access Time

TL;DR: A data structure for representing a set of n items from a universe of m items, which uses space n+o(n) and accommodates membership queries in constant time and is easy to implement.
Journal ArticleDOI

Approximate distance oracles

TL;DR: The most impressive feature of the data structure is its constant query time, hence the name "oracle", and it provides faster constructions of sparse spanners of weighted graphs, and improved tree covers and distance labelings of weighted or unweighted graphs.
Proceedings ArticleDOI

Approximate distance oracles

TL;DR: The most impressive feature of the data structure is its constant query time, hence the name ``oracle', which provides faster constructions of sparse spanners of weighted graphs, and improved tree covers and distance labelings of weighted or unweighted graphs.
Frequently Asked Questions (15)
Q1. What have the authors contributed in "All-pairs nearly 2-approximate shortest-paths in o(n polylog n) time" ?

An algorithm is said to compute all-pairs t-approximate shortestpaths/distances, for some t ≥ 1, if for each pair of vertices u, v ∈ V, the path/distance reported by the algorithm is not longer/greater than t · δ ( u, v ). This paper presents two randomized algorithms for computing allpairs nearly 2-approximate distances. The first algorithm takes expected O ( mn log n+n ) time, and for any u, v ∈ V reports distance no greater than 2δ ( u, v ) + 1. This paper also presents the first expected O ( n ) time algorithm to compute all-pairs 3-approximate distances. 

Given an undirected unweighted graph G(V, E) on |V | = n vertices, the authors can compute all-pairs 3-approximate distances in O(n2) time. 

But the stretch factor may be quite huge for short paths since β depends on ζ as (1/ζ)log 1/ζ , depends inverse exponentially on ρ and inverse polynomially on . 

To improve its preprocessing time to (n2 polylog n), one idea is to perform BFS from R on a spanner (having o(n2) edges) of the original graph. 

The preprocessing time of the first two steps in Algorithm The authordescribed above can be bounded by O(n2 log n) with a suitable choice of p. 

For a vertex u and a set R ⊂ V of vertices, Ball(u, R) denotes the set of vertices of the graph, such that the distance from u to these vertices is less than the distance from u to the nearest vertex of the set R.New scheme for approximate distanceLet R ⊂ V be a set of vertices. 

Case 1: Ball(u, R) = {u} Let v0(= u), v1, · · · , vl(= v) be the shortest path between u and v. Since Ball(u, R) consists of vertex u only, u must be adjacent to nu. 

In its most generic version, that is, for directed graph with real edge-weights, the best known algorithm [6] for this problem requires O(mn+n2 log log n) time. 

Now the part of the path Pwu excluding the edge e(u′, u) is of length x−1, and can’t be stretched to more than 3(x−1) in the spanner. 

Add a uniform sample of size np from V ′ to R; For every u ∈ V \\R doCompute Ball(u, R); For every v ∈ V \\R doC(v, R)← {u ∈ V | v ∈ Ball(u, R)}; V ′ ← {v ∈ V | |C(v, R)| > 4/p};Return R; }For the first iteration, R is a uniform sample from V , that is, R = Rp. So using Theorem 1, the first iteration requires expected O(m + n/p2) time. 

1. Now considering the path from nu to v passing through u, the authors can observe that δ(nu, v) is bounded by 2a + x + b +1. Similarly, analyzing the path from nv to u passing through v, the authors can observe that δ(nv , u) is bounded by 2b + x + a + 1. Therefore, the distance reported by Q(u, v) is bounded as follows. 

in the worst case, the authors have been able to improve the running time by a factor of O(n1/6) at the expense of introducing an additive error of just one unit. 

In the final and the third case, when the two Balls are non-overlapping, the authors use the global distance information stored at nu and nv.Lemma 1. Given a graph G(V, E) and any two vertices u, v ∈ V , the approximate distance between u and v as reported by the query procedure Q(u, v) is bounded by 2δ(u, v) + 1.Proof. 

The best known upper bound on the time complexity of this problem is O(n3 √ log log n/ log n) due to Zwick [10], which is marginally sub-cubic. 

Without any modifications, all their data-structures for reporting approximate distances can also be used to report approximate shortest-paths in optimal time.