6.3 The Upper Bound Results
6.3.5 Single Source Shortest Paths
Now we present a randomised algorithm for the-approximate single source shortest paths problem. The input is a weighted graph G = (V, E) with a non-negative integer weight associated with each edge, and a source vertex s from which to find an -approximate shortest path for each vertex v ∈V. The sum of weights of all edges is W, and logW = O(logV).
The randomized algorithm of Demetrescu et al. [29] solves SSSP inO((CV logV)/√ M) passes, where C is the largest weight of an edge in G, and logC =O(logV).
Our algorithm uses a subroutine from [29], and some ideas from [56].
Demetrescu et al.’s Algorithm
We now briefly describe the algorithm of Demetrescu et al.
The algorithm first picks a subsetAof vertices such thatAincludes the source vertex s, the other vertices of A are picked uniformly randomly, and |A| = √
M. A streamed implementation of Dijkstra’s algorithm (which we call “StreamDijkstra”) computes exact shortest paths of length at most l = αCV√logV
M (for an α > 1) from each vertex u ∈ A in O(√V
M +l) passes.
Next an auxiliary graphG0 is formed in the working memory on vertex setA, where the weightw0(x, y) of an edge{x, y}inG0 is set to the length of the shortest path fromx to y found above. SSSP is solved on G0 using s as the source vertex. This computation takes place within the working memory. For x ∈ A, let P0(x) denote the path obtained by taking the shortest path in G0 from s to x, and replacing every edge {u, v} in it by the shortest path inGfrom uto v. For v ∈V, do the following: For xinA, concatenate P0(x) with the shortest path from x to v found in the invocation of StreamDijkstra to formP0(x, v). Report as a shortest path froms tov the shortest P0(x, v) over all x∈A.
This reporting can be done for all vertices in O(V /M) passes, once the auxiliary graph is computed. The total number of passes is, therefore,O(CV√logV
M ). It can be shown that the reported path is a shortest path with high probability. See [29].
Now we describe StreamDijkstra in greater detail, as we will be using it as a subrou- tine. StreamDijkstra takes a parameter l.
Load A into the memory. Recall, |A| = √
M. Visualise the input stream as par- titioned as follows: γ1, δ1, . . . , γq, δq, where each δi is an empty sequence, each γi is a sequence of edges (u, yi, wuyi), and ∀i < q, yi 6= yi+1. For cj ∈ A, let Pcj = {cj} and dj = 0; Pcj will always have a size of at most√
M and will stay in the memory. Execute the following loop:
loop
Perform an extraction pass;
Perform a relaxation pass;
if everyPcj is empty, then halt;
endloop
In a extraction pass, stream through the γ-δ sequence; in general, δi is a sequence
(di1, fi1), . . . ,(di√M, fi√M) where dij is an estimate on the distance from cj toyi through an edge in γi, and fij is a boolean that is 1 iff yi is settled w.r.t. cj. For j = 1 to √
M, let dj be the smallest dij over all i such that yi is unsettled w.r.t. cj. For j = 1 to √
M, copy into Pcj at most√
M yi’s so that dij =dj ≤l.
In a relaxation pass, stream through theγ-δ sequence; As the pass proceeds, ivaries from 1 toq. Forj = 1 to √
M, initialise Xj =∞. For each (u, yi, wuyi)∈γi, and for each cj ∈ A, if u ∈ Pcj, and Xj > dj +wuyi then set Xj =dj +wuyi. For each (dij, fij) ∈ δi, if (Xj 6=∞) and dij > Xj then set dij toXj. For eachyi ∈ Pcj and (v, yi, wvyi)∈ γi, set flag fij = 1.
Our Approximate Shortest Paths Algorithm
We use ideas from [56] to compute in O(Vlog√VlogW
M ) passes paths that are approximate shortest paths with high probability; hereW is the sum of the edge weights. Our algorithm invokes Procedure StreamDijkstra dlogWe times in as many phases.
The algorithm first picks a subsetAof vertices such thatAincludes the source vertex s, the other vertices of Aare picked uniformly randomly, and|A|=√
M. Letl0 = αV√logV
M ,
for an α >1. For 1 to dlogWe, execute the i-th phase. Phase i is as follows:
• Letβi = (·2i−1)/l0.
• Round up each edge weight upto the nearest multiple of β. Replace zero with β. Formally, the new weight function wi on edges is defined as follows: wi(e) = βidw(e)/βie, if w(e)>0;wi(e) =βi, if w(e) = 0.
• Letl =d2(1+)l 0e. Invoke Procedure StreamDijkstra withlβi as the input parameter.
• For each vertex x ∈ A and v ∈ V, if pi(x, v) and ˆP(x, v) are the shortest paths fromx to v computed in the above, and in the earlier phases respectively, then set Pˆ(x, v) to the shorter of pi(x, v) and ˆP(x, v).
IfP is a path fromx∈A tov ∈V such that its length is between 2i−1 to 2i and the number of edges in it is at most l0, then the length w(pi) of the path pi(x, v) computed in thei-th phase above is at most (1 +) times the length w(P) ofP. We can prove this as follows. (A similar proof is given in [56].)
We have,wi(e)≤w(e)+βi. So,wi(P)≤w(P)+βil0 =w(P)+2i−1. As 2i−1 ≤w(P), this means thatwi(P)≤ (1 +)w(P). Furthermore, since w(P)≤2i, wi(P) ≤(1 +)2i. Thus, if Procedure StreamDijkstra iterates at least (1+)2β i
i = 2(1+)l 0 ≤ l times, then P would be encountered by it, and therefore w(pi) would be at most (1 +)w(P). Thus, Pˆ(x, v) at the end of thedlogWe-th phase, will indeed be an-approximate shortest path of size at mostl0, for every v ∈V and x∈A.
Since, each phase requires O(√V
M +l) passes, where l = d2(1+)αVlogV
√
M e, the total number of passes required fordlogWephases is O((1+)VlogVlogW
√
M ).
The rest is as in the algorithm of Demetrescu et al. An auxiliary graphG0 is formed in the working memory on vertex set A, where the weight w0(x, y) of an edge {x, y} in G0 is set to the length of the shortest path from x to y found above. SSSP is solved on G0 using s as the source vertex. For x∈A, let P0(x) denote the path obtained by taking the shortest path inG0 froms tox, and replacing every edge {u, v} in it by the reported path ˆP(u, v) in G from u to v. For v ∈ V, do the following: For x in A, concatenate P0(x) with the reported path ˆP(x, v). Report as a shortest path from s tov the shortest P0(x, v) over all x∈A.
Lemma 6.2. Any path computed by our algorithm has a length of at most (1+)times the length of a shortest path between the same endpoints with probability at least 1−1/Vα−1. Proof. The proof is similar to the one in [29]. The lemma is obvious for shortest paths of at mostl0 edges. Now consider a path P of τ > l0 edges. P has bτ /l0c subpaths of size l0 each, and a subpath of size at mostl0. We show that each subpath contains at least one vertexx from setA. The probability of not containing any vertex fromA in a subpath is at least (1− |A|/V)l0 <2−|A|l
0
V = 1/Vα.
Since, there are at most V /l0 ≤V disjoint subpaths, the probability of containing a vertex from setA in each subpath is at least 1−(1/Vα−1). Furthermore, each subpath is of size at most (1 +) times the shortest path of G. Thus, the computed path is at most (1 +) times the shortest path with probability 1−1/Vα−1.
Putting everything together, we have the following lemma.
Lemma 6.3. The paths computed by our algorithm are-approximate shortest paths with high probability; the algorithm runs in O((1+)V logV logW
√
M ) passes.
IfC is the maximum weight of an edge, then W ≤V C, and our algorithm improves the Demetrescu et al.’s algorithm [29] by a factor of C/logV C at the cost a small error in accuracy of negligible probability.