Single-Source Shortest-Paths on Arbitrary Directed Graphs
in Linear Average-Case Time
Ulrich Meyer*
In each iteration, the queued node v with smallest
Abstract
The quest for a linear-time single-source shortest-path tentative distance is selected and declared settled, and
(SSSP) algorithm on directed graphs with positive edge all edges (v,w) are relaxed, i.e., tent(w) is set to
weights is an ongoing hot research topic. While Thorup rain{tent(w), tent(v) + c(v, w)}. If w was unreached, it
recently found an O(n + m) time RAM algorithm for is now queued. It is well known that tent(v) = dist(v),
undirected graphs with n nodes, m edges and integer when v is selected from the queue.
Label-correcting SSSP algorithms may remove
edge weights in { 0 , . . . , 2 w - 1} where w denotes the
word length, the currently best time bound for directed nodes from the queue for which tent(v) > dist(v) and
hence have to re-insert those nodes until they are finally
sparse graphs on a RAM is O(n + m . loglogn).
In the present paper we study the average-case settled (dist(v) = tent(v)). In spite of poor worst-case
complexity of SSSP. We give a simple algorithm for rurming times, implementations of label-correcting aparbitrary directed graphs with random edge weights proaches frequently outperform label-setting algorithms
uniformly distributed in [0, 1] and show that it needs [4, 27].
linear time O(n + m) with high probability.
1.1 P r e v i o u s W o r k
Using Fibonacci heaps [11] Dijkstra's algorithm can be
1 Introduction
ilnplemented to run in O(n log n + m) time for positive
The single-source shortest-path problem (SSSP) is a funedge weights. A number of faster algorithms have been
damental and well-studied combinatorial optimization
developed on the more powerful RAM (random access
problem with many practical and theoretical applicamachine) model which basically reflects what one can
tions [1]. Let G = (l~ E) be a directed graph, lYl = n,
use in a programming language such as ¢. Nearly all of
IEI = m, let s be a distinguished vertex of the graph,
these algorithms are based on Dijkstra's algorithm and
and c be a function assigning a non-negative real weight
improve the priority queue data structure (see [25] for
to each edge of G. The objective of the SSSP is to coman overview). Thorup [25] has given the first O(n + m)
pute, for each vertex v reachable fi'om s, the weight of a
time RAM algorithm for undirected graphs with integer
nfinimum-weight ("shortest") path from s to v, denoted
edge weights in { 0 , . . . , 2w - 1} for word length w. His
by dist(v); the weight of a path is the sum of the weights
approach applies label-setting but significantly deviates
of its edges.
from Dijkstra's algorithm in that it does not visit
Shortest-paths algorithms are typically classified
the nodes in order of increasing distance from s but
into two groups: label-setting and label-correcting. The
traverses a so-called component tree.
basic label-setting approach is Dijkstra's algorithm [8].
Hagerup [14] recently generalized Thorup's apIt maintains a partition of V into settled, queued,
proach to directed graphs, the time complexity, howand unreached nodes~ and for each node v a tentative
ever, remains super-linear O(n + m • log w). The curdistance tent(v); tent(v) is always the weight of some
rently fastest RAM algorithm for sparse directed graphs
path from s to v and hence an upper bound on dist(v).
is due to Thorup [26] and needs O(n + m • loglogn)
For unreached nodes v, tent(v) = c¢. Initially, s is
time. Faster approaches for somewhat denser graphs
queued, tent(s) = 0, and all other nodes are unreached.
have been proposed by Raman [22, 23]: they require
O(rn+n. v/log n • loglog n) and O ( m + n . (w .logn) 1/3)
"--'-~-]~x-Planck-Institut ffir Informatik, Stohlsatzenhausweg 85,
tirne, respectively.
66123 Saarbrficken, Germany. E-mail: umeyer~mpi-sb.mpg.de
The classic label-correcting algorithm of BellmanWWW: h t t p : / / w w w . m p i - s b . m p g . d e / ~ u m e y e r /
PartiMly supported by the IST Programme of the EU under Ford [3, 10] and all of its improved derivatives (see [4] for
contract number IST-1999-14186 (ALCOM-FT).
797
an overview) need O(n. m) time in the worst case. Some
of these algorithms, however, show very good practical behavior for SSSP on sparse graphs [4, 27]. Nevertheless, average-case analysis of shortest paths algorithms mainly focused on the All-Pairs Shortest Paths
(APSP) problem on the complete graph with random
edge weights [5, 12, 15, 19, 24]. Mehlhorn and Priebe
[17] proved that for the complete graph with random
edge weights, every SSSP algorithm has to check at
least ~ ( n l o g n ) edges with high probability. Noshita
[20] and Goldberg and Tarjan [13] analyzed the expected number of decreaseKey operations in Dijkstra's
algorithm; the time bound, however, does not improve
over the worst-case complexity of the algorithm. Meyer
and Sanders [18] gave a label-correcting algorithm for
random edge weights in [0, 1] that runs in average-case
time O(n + m + d . de) where d denotes the maximum
node degree in the graph and d~ denotes the maximum
weight of a shortest, path to a node reachable fi'om s,
i.e., d~ = maxveG,dist/vl<c~ dist(v). However, there are
graphs where m = O(n) but d . E[d¢] = fl(n2), thus
incurring ~ ( n 2) time on average.
and relaxes the outgoing edges of v. In the following we
will also use the term current bucket, B¢,r, for the first
nonempty bucket. However, in the worst case, Dial's
implementation has to traverse C • n buckets.
Alternatively, a whole interval of tentative distances
can be mapped to a single bucket: v is kept in the bucket
with index [ t e n t ( v ) / A ] . The parameter ,~ is called the
bucket width. Let A denote the smallest edge weight in
the graph. Dinitz [9] and Denardo and Fox [6] observed
that taking A < A, Dijkstra's algorithm correctly settles
any node from Bcur. Choosing ,.~ > A either requires to
repeatedly find a node with smallest tentative distance
in Bcur or results in a label-correcting algorithm which
may re-insert nodes into Bcur: e.g., the algorithm of
[18] uses buckets of width 1/max.node_degree in order
to limit the number of re-insertions. However, on sparse
graphs with few high-degree nodes, a large number of
buckets is needed.
2.2 T h e A l g o r i t h m
Iu this section we present, our new algorithm, called
ADAP-SP. It. combines ideas from label-setting algorithms and label-correcting algorithms. For ease of exposition we assume real edge weights from the interval
1.2 N e w Results
In Section 2 we present a new label-correcting SSSP [0, 1]. The algorithm begins with n buckets at level Lo,
algorithm with adaptive bucket splitting and analyze its B0,0,..., B0,n-1, each of which has width &0 = 2 -0 = 1,
average-case complexity (Sections 3 and 4). To the best and s E Bo,0 with tent(s) = 0. Bucket B0,j, 0 _< j < n,
of our knowledge it is the first, algorithm which provably represents tentative distances in the range [j, j + 1). A
achieves linear C9(n + m) time with high probability current bucket can be split, i.e., a new level of buck(whp) a on arbitrary directed graphs with random edge ets is created, and the nodes of Beur are redistributed.
weights. Besides the attractive theoretical time bound The current bucket is always located in the highest level
our new algorithm is also easy to implement and allows of the bucket hierarchy. Adaptive splitting is applied to
parallelization (Section 5). In Section 6 we propose achieve a compromise between either scanning too many
a general method to construct graphs with random narrow buckets or incurring too many re-insertions due
edge weights which incur large non-linear running times to broad buckets.
on many traditional label-correcting algorithms whp.
ADAP-SP works in phases: first, it checks the
While this problem is interesting in its own right, it, maximmn node degree d* (sum of in-degree plus outalso stresses the asymptotic superiority of our new degree) among all nodes in the current bucket B c u r =
algorithm.
Bi,j of width &i at level Li. If d* < l/&i, then the
algorithm removes all nodes froln the current bucket
2 A d a p t i v e Bucket-Splitting
Bcur, relaxes their outgoing edges, and a new phase
starts.
Otherwise, it splits Bcur into ~ = A i / & i + l > 2
2.1 Preliminaries
new
buckets
having width Ai+l = 2 -[l°g~d*] each. If
Our algorithm is based on keeping nodes in buckets.
Bcur
represents
a distance range [a, a + zXi), then Bi+l,k,
This technique has already been used in Dial's imple0
<_
k
<
g,
represents
tentative distances in the range
mentation [7] of Dijkstra's algorithm for integer weights
in {0 . . . . ,C}: a queued node v is stored in the bucket [a + k • . ~ i + l , a .+ ( k + 1) • ,L~i+l), see Figure 1 for
Bi with index i = tent(v). In each iteration the algo- Bc,r = B2,2, a = 2 and ~ = 2. Those nodes from Bi,j
rithm removes a node v from the first nonempty bucket which have surely reached their final distance values are
removed, and their outgoing edges are relaxed (details
follow
in Section 2.3 and Figure 2). All remaining
l F o r a p r o b l e m of size ~, we s a y t h a t a n e v e n t o c c u r s with high
nodes from Bi,j are redistributed into the new buckets
probability ( w h p ) if it o c c u r s w i t h p r o b a b i l i t y a t l e a s t 1 - O ( n - c )
for a n a r b i t r a r y b u t fixed c o n s t a n t c > 1.
of Li+l according to their tentative distances. The
798
Lo
Lo
E] emptied
[ ] split
[ ] current
[ ] unvisited
Figure 1: Adding hierarchy level Lz by splitting the
current bucket B2,2 into B3,o and /33,1.
first nonempty bucket of Li+l becomes the new current
bucket Bc~ur, and ADAP-SP checks again the m a x i m u m
!
node degree d* in Bcu r. A new phase starts if d*
1/Ai+l; otherwise, a new level Li+2 is created, the nodes
I
of Bcu
r are redistributed, and so on.
After all buckets of the highest level have been
emptied, ADAP-SP deletes this level and continues with
the next nonempty bucket of the previous level. Thus,
whenever the algorithm starts removing all the nodes
from Bout, then the following holds:
INVARIANT 1. If d denotes the maximum node degree in
the current bucket B .... = Bi,j at level Li, then its bucket
width Ai is at most 2 -[l°g2d] < 2 - i . Furthermore, the
total level "width of Li, Ai-1, is at most 2 -i+1 for i > 1.
2.3 Early R e m o v a l s and R e l a x a t i o n s
During a bucket split ADAP-SP does not redistribute
nodes which have surely reached their final distance
values. This helps to reduce the overhead for transferring nodes to higher and higher levels. Clearly, the
node v with minimum tent(v) in Bcur is settled: all
edge weights are non-negative, hence tent(v) cannot be
decreased further by edge relaxations. Additionally, a
node is surely settled if all of its incoming edges have
weight at least ,lout:
ADAP-SP:
Create level L0 and insert s into Bo.o
i:=0, j:=0, ,~i:=l
while i > 0 d o
while nonempty bucket exists in Li do
repeat
go_on := true
j := min {k > j[Bi, k ~ 0}
d* := max {degree(v) [ v E Bi,j}
if d* > 1/,t~ i t h e n
Create level Li+l with Ai+l := 2 -[l°g2 d']
U1 :----{v e Bi,j [Vu e Bi,j : tent(v) _< tent(u)}
u~ := {v e B~,j IVb,, v) e E : ~(.,v) _> ai}
Remove UI U U2 from Bi,j and
relax all outgoing edges from nodes in U1 U/U~
Redistribute all remaining nodes from Bi,j to Li+l
go_on :=false, i : = i + l ,
j:=0
until go_on = true
Remove all nodes of Bid and relax their outgoing edges
Remove level Li, i : = i - 1
Figure 2: Pseudo-code for ADAP-SP
since all incoming edges of v have weight at least Ac,~
such a path cannot exist.
[]
For the relaxation of an edge e = (u, v) from a node
u E Be,r, it is necessary to find the appropriate target
bucket which is in charge of tent(v), either B~u~ or a so
far unvisited bucket. The search starts bottom-up from
level L0, and each level can be checked in constant time.
Since the m a x i m u m node degree in G is at most 2.n, the
search will be successful after at most [log: 2n] levels.
THEOREM 1. The worst-case execution time of A D A P SP is O(n . m . log n).
Proofi Initializing global arrays for tentative distances,
level zero buckets, pointers to the queued nodes, and
storing the lightest incoming edge for each node can
clearly be done in linear time.
During the algorithm, if a node u E Bcur is found
that has degree d > 1/Acur, then Bcur is split into at
most x < 2. ( d - 1) new buckets. Each node node u can
cause at most one splitting since u is redistributed to
LEMMA 1. Let v be a node in the current bucket BLur buckets having width at most lid, and u never moves
of width Ac~).. The tentative distance tent(v) is final if back to buckets of larger width. Hence, the costs for
the lightest incoming edge of v has weight at least Acur. the following actions can be charged on the degree of the
node u that caused the splitting: setting up, visiting and
Proof." Let [t, t + At,r) denote the interval of tentative finally removing the at most x buckets of the new level.
distances which belong to Bent. The value tent(v) can Over all splittings this amounts to O(m) operations.
Finally, each phase or splitting settles at least one
only be reduced via a path (u . . . . , v) with total weight
less than tent(v) - t < ~cur an([ u G Be,r- However, node. Thus, there are at most n phases or splittings,
799
each of which transfers at most nfin{n, m} nodes during
a splitting and relaxes at most m edges. Since the target.
buckets can be found in O(log n) time, the total amount
of operations is bounded by O(n • m - log n).
[]
Therefore, the expected number of redistributions for v
can be bounded by
[log~,d J
1+ E
j=l
3
1
~
i=1
.3_ j
=5.
j=0
[]
Average-Case Complexity
Now we examine the average-case running time of
ADAP-SP. We assume random edge weights which are
independent and uniformly distributed in the interval
[0, 1]. First we will bound the average-case overhead
due to node redistributions during bucket splits.
LEMMA 2. For any node v, the average number of
redistributions of v is bounded front above by a constant.
P r o o f : Let v be an arbitrary node with degree d in
B c u r - Let A~u
0 ~ denote the width of B~ur, and let d* >
o
1/ZXcur denote tile rnaximum node degree in Bcur, i.e., a
redistribution is required. If all incoming edges of v have
weight at least A~ur,
0 then v can be removed according
to the criterion of L e m m a 1 (and never re-enters a
bucket) 2. Otherwise, after the first redistribution, v is
stored in a bucket of width 1/d* or less. After the i-th
time v was moved to a higher level, it is reconsidered in
a current bucket of width A~u ~ <_ 1/(2 i-1 • d*).
For the analysis we use the principle of deferred
decisions: in order to decide whether v needs to be
redistributed from the current bucket of width A~ur,
we query the incoming edges of v one by one. However,
instead of checking their concrete weights, we just reveal
whether they are smaller than Ac,,r or not. We stop
after detecting the first edge e* = (u, v) with weight less
than A~u~. The only knowledge we gained is that c(e*)
is uniformly distributed in [0, ACur). Possible further
redistributions of v are due to splits of buckets with even
smaller widths. Thus, the edges into t, which were tested
prior to e* (and therefore have weight at least &Cur) do
not need to be queried again later. The weights of the
(at most d - 1) remaining edges that have not yet been
tested are uniformly distributed in [0, 1].
Now assume that v was already redistributed i times
and that the current bucket B~u r it resides in is split:
i ~ has width A~u
i ~ < 1/(2 i - 1 . d*). Furthermore,
then BCu
i
P[c(e*) < Acu~] < 1/2 s i n c e L~icur __< 1/2 . Acuri-1, and
c(e*) is uniformly distributed in [0,'ACur)"
i-1
Hence, the
probability that v is not redistributed any more is at
least
1
A i
~d-1 > ~ 1
,~ . (1 . - - c u.r ,
.
.
(1
d
i
]
--___
Acur) > 2
1
2i "
"2"N'Tte t h a t this criterion is i n d e p e n d e n t of tent(v) within Bcur.
800
1
H ( 1 - ( ' 2 - 9~)) < l + E ( 4 )
COROLLARY 1. All bucket splittings can be done in
average-case time O(n + m) in total.
Some parts of the following analysis extend proofs
from the full version 3 of [18]. In order to give a
bound on the number of re-insertions we m a p them
on connection pairs between nodes in the same bucket.
In the following, a path with total weight at most A
which does not follow any edge more than once (a path
"without edge repetition" (w.e.r.)) will be called a Apath. We define Gi to be the subgraph of G which is
induced by all vertices with degree at most 2 i. Let Ci
be the set of all node pairs [u, v]i connected by some
(2-i)-path ( u , . . . , v) in Gi. Furthermore, let C~ be the
set of those pairs in Ci whose second component is v.
LEMMA 3. The total number of re-insertions of a node
v is bounded by i=[log~degree(v)] ICY[ •
P r o o f : Consider a node v which is re-inserted into
a fixed current bucket Bcur for phase t. We give an
injective m a p p i n g from the set of re-insertions into
C ~ = OiC~'. Due to Invariant 1, Acu~ = 2-J <_ 2 -k,
for some j, where k = [log s degree(v)]. There must be
a most recent phase g < l when v was removed from
this particular Bcur (and no split happened since then).
Consider any shortest path A = ( s , . . . , v l , . . . , v) where
v' is the first unsettled node on A immediately before
phase g. Note that the sub-path A' = ( v ' , . . . , v) of A
is a shortest path from v ~ to v in Gj. In contrast to
v, v' is settled ill phase t', i.e., v' # v. Since both v
and v ~ are removed from Bcur in phase t ~, A ~ is also a
(2-J)-path, i.e., Iv', v]j E C~. Since v' becomes settled,
the re-insertion of v in phase t can be uniquely m a p p e d
to [v', v]j.
C O R O L L A R Y 2.
[]
The total number of re-insertions, n+,
[log 2 2n l - 1
is bounded by z..~i=o
ICil, and ICil is bounded by
the number of simple (2-i)-paths in Gi.
Now we show that long paths without edge repetition
(w.e.r.) that have small total weight are unlikely:
http://www.mpl-sb.mpg.de/,,~umeyer/dps/delta-long.ps.gz
LEMMA 4. ([18]) Given a path 79 of l edges with independent and uniformly distributed edge weights in [0, 1].
The probability that P is a A-path for A < 1 is bounded
by At~l!.
P r o o f i By induction. Let Xi denote the weight of
the i-th edge on the path. The weight of the path is
l
then ~ i = l Xi. For I = 1, clearly P [Xi 5_ A] = A. For
l+l+l:
P
Xi < A
Li=I
/0 ~ ( A
] /o [±
=
P
- -
X) l
]
Xi < A - x dx <
i=1
A l+1
?
(l+1)!
[]
LEMMA 5. For any node v, A D A P - S P incurs at most
2. e re-insertions on average.
P r o o f : Consider an arbitrary node v with degree d, and
let k = [log 2 d]. According to Invariant 1, the algorithm
tries to settle v for the first time by removing it from a
k r having width Acu
, k r _< 2 - k . If Bcu
k r is split
bucket Bcu
and v is not filtered out by an early removal, then v may
be reconsidered again in other current buckets BcJur of
higher levels. According to Lemma 3 and Corollary 2,
an upper bound on the number of re-insertion for v is
given by
[log,2 2n] - 1
E
i=k
# simple (2-i)-paths into v in Gi
(3.1)
Since all nodes in Gi have degree at most 2i, no more
than d . (2i) (/-1) simple paths of I edges each enter
node v in Gi. Taking into account the probability that
such paths are (2-i)-paths (Lemma 4), the average-case
number of re-insertions of v is bounded from above by
[log_.2n] oo
E
Zd"
i=k I=1
LEMMA 6. The target bucket for an (re-) insertion or
(re-) relaxation via an edge e = (u,v) can be found in
constant time on average.
Proof." The weight of e is uniformly distributed in [0, 1].
Therefore, looking at a specific level Li, the probability
that tent(v) = tent(u)+c(u, v) with u E Bcur belongs to
Li is at most the total width o f L i , Ai-b By Invariant 1,
Aiq _< 2 -i+1 for i > I. Thus, the expected search time
when checking levels in bottom-up fashion is bounded
by
O(1 +
[loga 2n]
E
i" 2 -i+1) : O(1).
i=1
[]
THEOREM 2. A D A P - S P runs on arbitrary directed
graphs with random edge weights that are independent
and uniformly drawn from [0, 1] in O(n + m) averagecase time.
4
A High-Probability B o u n d
In order to prove a linear time bound that holds with
high probability, ADAP-SP has to be changed in some
aspects; we will call the refined algorithm ADAP*-SP.
In this section we sketch the main points:
1. For each node u create a list On, that keeps the
outgoing edges of u and their weights in semi-sorted
order, i.e., O,, consists of at most [log 2 2n] groups
where group gi holds all outgoing edges ek with
2 -i+l < c(ek) ~ 2 -i in arbitrary order, and gi
appears before gj for all j < i.
2 I'`l-1). 2-i'l/l[ :
[Iog~2nl d
E
i=k
Finally, we address the complexity to find the appropriate target bucket for node (re-) insertions or (re-) relaxations. A modification of ADAP-SP (Section 5) reduces
the worst-case search time from O(log n) to O(1), thus
immediately yielding a linear time average-case bound
for the algorithm. However, for random edge weights,
the simple bottom-up search strategy is equally suited.
E
i=k
l=l
[]
Hence, over the whole algorithm the expected immber
of re-insertions is bounded by E[n+] = O(n) and the
expected number of re-relaxations is bounded by
Elm+] _< 2 . e . E out-degree(v) = O(m).
vEG
2. Let u be a node which is removed from Bc,r. Unless
u is removed from Bcur during a bucket split (i.e.,
tent(u) is final by" Lemma 1), only edges (u, v) with
weight at most ACur are relaxed. They always
constitute the first groups in O= due to the sentisorting. The remaining edges are relaxed once and
for all after Bcur and its refining buckets (if present)
finally renaain empty. By then all involved nodes
are surely settled.
In order to remember those edges which still have to be
relaxed, every bucket Bid is equipped with an additional
801
edge list Ei,i. Whenever a node u is deleted from
Ucur = Bi d (either by removing or redistributing) we
move all remaining edges ek satisfying c(ek) > .~cur
from Ou to Ei,i. Note that these edges constitute tile
last groups in 0~. Hence, if u is re-inserted into Bc,,~ no
transferable edges are left in 0~, and this can be checked
in constant time. All edges in Ei,j are relaxed once after
Bid finally remains empty or - - in case Eij has been
split - - after its refining level Li+l is removed. It is easy
to check that this schedule of deferred edge relaxations
does not affect the correctness of the algorithm since all
potentially relevant edges are relaxed in time.
LEMMA 7. Each (2-i+l)-path w.e.r, in Gi contains
no more than l* = Ot-J2-a2-Xloglogn) edges for all 0 <_ i <
[log 2 2n] whp.
P r o o f : There are at. most 2 i't paths w.e.r, of length l
into each node of Gi. By Lemma 4, the probability for
tile presence of any (2-i+l)-path in Gi with l edges can
be bounded by n- (2 -i+1 • 2i)l/l! = n . 2t/l!. Hence, by
Boole's inequality there are no (2-i+l)-paths of l _> l*
edges ill Gi for all 0 <_ i < [log 2 2n] with probability at
least.
1- Z
n . [logs 2 n ] . 2'/l!
l>'*
4.1
Modified Analysis
By our modifications listed above, re-relaxations of
e = (v,w) for v E BCu~ can only occur if c(e) < Acur.
Therefore, arguing along the lines of Lemma 3 rerelaxations can be uniquely mapped to the set C* =
Ui C'~ where C~ holds triples [u, v, w]i with [u, v]i E Ci
and e = (v, w) having weight at most 2 -i. Thus, m+ <
[C*[. Similarly to Lemma 5, the nulnber of re-relaxation
for edges out of node v where kt. = [log s degree(v)] can
be bounded by
[log 2 2n] - 1
2n].
/>0
=
>
1 - O ( n . l o g n ) . ( -2~ -e.,.
)
_ 1 - n -c
for some arbitrary positive constant c and l*
0(-~..~-.~
l o g l o g n j"
=
[]
Clearly, the bound of Lemma 7 also holds for (2-i) paths w.e.r, in Gi. Now we bound the number of nodes
reached from a given node via (2-1)-paths and (2-i+1) paths w.e.r, in Gi:
Z
( # sirnple(2-i)-paths into v within Gi
LEMMA 8. For any node v, I{u : [u,w, vl, e C* v
i=k~
• # edges e = (v, a,) with c(e) _< 2 -i ) (4.2)
[v,w,a]~ E C * , 0 < i < [log22n]} [ _< n °(1/'°s'°gn)
whp. The same bound holds for elements of the form.
[u, v]i or [v, u]i in C.
Furthermore, the total number of re-relaxations, m+,
does not exceed
[1o82 2 n ] -- 1
E
E
vEG
i=k~
# (2-i+l)-paths w.e.r, into v in Gi (4.3)
Using Lemma 4, (4.3) and the observation that there
are at most 2 i'' paths w.e.r, of length l into each node
of Gi, it is easy to show that the total expected number
of re-relaxations in ADAP*-SP is E[m+] = O(n).
The actual values of n+ and m+ can be regarded
as functions of the n independent random variables
X~, := { ( v , w , c ( v , w ) ) : ( v , w ) E E)}, i.e., Xv describes
all edges leaving node v including their weight. On
the other hand, n+ and m+ are bounded by [CI and
[C* [, respectively, and the sizes of these sets in turn are
bounded by certain numbers of paths (Fornmlae (3.1)
and (4.3))•
In the following we will show that all these paths
consist of O ( l o g n / l o g l o g n ) edges whp and that the
modification of a single random variable X~ can affect
at most O(n °(l/'°gl°g'')) such paths whp. Finally,
applying Azuma's Martingale tail inequality [16] leads
to the desired high-probability bound on n+ and m+.
802
>_ 1 - ,r. [log
P r o o f : Consider the nodes reached from v via (2-i+1) paths in Gi. We argue that the number of nodes
reachable by connections in C* of length l can be
bounded by the offspring in the l-th generation of the
following branching process: An individual (a node) u
has its offspring defined by the number Y,, of edges with
weight at most 2 -i+1 leaving it. Let Z, denote the total
offspring after l generations (i.e., Z0 = Y,). As long
as new edges are encountered when following paths out
of v, the offspring of the braaching process is an exact
model for the number of paths leaving v which use only
edges with weight at. most. 2 -i+l. After a node has been
reached from multiple paths, the events on those paths
are no longer independent. However, all but one of the
multiple paths produce only dnplicate entries into C[.
The additional paths can therefore be discarded. All
remaining events are independent.
We have E[Y~,] < d e g r e e ( u ) - 2 -i+1 ~ '2, and by
the elementary theory of branching processes, E[Z~] <
(max-degree(Gi) • 2-i+1) / ~ 2'. The tail bounds in [2]
additionally show that
Zi : O((max-deg.(Gi) • 2-i+1) ' • logn) = 0(2' • logn)
whp. Furthermore, ~ j < t Z j = 0 ( 2 ~- logn) whp. By
Lemma 7 we have l < l* = O ( ~l o)g l o g n whp. Hence,
-
:
o (flogs 2n1 • ,~" ° ( ~I g) l o g
:
n (~)
l
in total O(n + m) time whp.
-
e c*, o _< i < rlog 2nl}1
O
LEMMA 10. ADAP*-SP performs all (re-)relaxations
n
• log n)
whp
for all nodes v by Boole's inequality. The cases of paths
entering a node and of elements from C can be handled
analogously.
[]
LEMMA 9. ADAP*-SP incurs n+ < E[n+] + O(n) reinsertions and m+ <_ E[m+] + O(n) re-relaxations with
P r o o f : Let Xi be the weight of the i-th edge in G.
Let r ( X ) denote an upper bound on the total time for
all relaxations in that it assumes for each node a worst
case position in the bucket hierarchy as presented in
Lemma 6. We have E[r] = O(E[m+] + m) = O(n + m)
since the expected time for a single (re-)relaxation is
O(1). Let R be the proposition that the statements
of Lemma 7 and Lemma 9 hold (this happens whp).
Otherwise there are at most O(m • n) relaxations each
of which takes O(log n) time. Hence, E[r ] R] _< E[r] +
o(n + m) = o ( n + ~ ) .
In the best case an edge does not have to be relaxed
high probability.
at all, On the other hand by Lemma 7 and proposition
P r o o f : Let the proposition Q stand for the property R each edge can be relaxed at most O(log n~ loglog n)
that in Gi at most a . logn edges with weight at times per level, thus altogether O(log2n) times, and
most (2 -i+1) leave any node and that the number each relaxation takes at most O(logn) operations. By
of (2-i+a)-paths entering or leaving any node is at the definition of r(X) the changes of node placements
most n a / l ° g l ° g n for some constant a. Using Chernoff induced by a modification of ei will not affect r(X) for
bounds [16] and Lemma 8 we can see that Q holds edges ej # el. Thus, modifying Xi will change r(X)
whp for an appropriate constant a and sufficiently large by at most O(log 3 n), given R. We apply Azuma's
n. Therefore, E[m+[O] < E[,n+] + o ( n ) ( r e m e m b e r inequality and get
that n+ < n 2 and m+ < n 3) and it suffices to bound
P[r(X) > E[r In] + n l n ] < e .~.,~o~, .
P[m+ > E[m+[ Q] + t [ Q] for some t = O(n).
[]
By our definition of the n independent random
variables Xv := {(v, w,c(v, w)) : (v,w) C E)} we can
apply Azuma's Martingale tail inequalit.y [16] to show
LEMMA 11. All node redistributions can be done in
total O(n) time whp.
P[m+>E[m+IQ]+t[Q]<
exp
2.~cac~
P r o o f : We apply Azuma's inequality with n indepenwhere c~ is defined such that changing the value of dent random variables Xw := {(v, w, c(v, w)) : (v, w) E
variable X~ could change m+ by at most c,, (given Q). E)}, i.e., X,o describes all edges entering node w inBy definition of Q, there can be at most n a / l ° g l ° g n cluding their weight. Let t(X) denote an upper bound
(2-i+l)-paths entering a node; the number of edges on the total time for all node redistributions during
leaving v is at most a. log n and from each node reached splittings in that we assume the worst case scenario of
over these edges there are at most n a / l o g l o g n outgoing Lemma 2 where each node v may be reconsidered up to
(2-i+l)-paths, i.e., the edges emanating from v can be [log(2 • n/degree(v))] times. By Lemma 2 the expected
involved in at most cv < flog2 2n] • (na/l°gl°gn) ~" a" number of redistributions for any node is constant, and
logn : n O ( 1 / l ° g l ° g n ) many (2-1+1)-paths. This is a each redistribution can be achieved in constant time,
bound on co, i.e., 2. ~,ec; e2 <- 2. n . ( n ° ( 1 / l ° g l ° g n ) ) 2 :
thus E[t I = O(n).
n • n O(1/Ioglogn).
Finally, we get
In the best case a node v is removed without any
redistribution, in the worst case it is moved up at
most [log(2. n/degree(v))] = O(log n) times. Due to
P[m+ > E[m+] Q] + n I Q] _< e - " ( ' - ° ' '°s'°s--l--~')
the definition of t(X), changing Xw with its influence
An analogous proof can be made for n+.
[] on the placement of other nodes within the bucket
hierarchy will not increase t(X) for nodes v # w. Hence,
So far we have shown that n+ and m+ do not signifi- modifying X~,, will change t(X) by at most O(logn):
cantly deviate from their expected values whp. We still
have to address the bounds to perform (re-)relaxations
P [ t ( x ) > E[t] + n] < c .... ~ - .
[]
(Lennna 6) and early node removals (Lemma 2).
n
803
forms O(min{m + n, n logn}) expected time and linear expected work on worst case directed graphs with
THEOREM 3. SSSP ou arbitrary directed graphs with random edge weights. On graphs with small diameter
random edge weights which are independent and uni- and few high degree nodes the execution time decreases
formly drawn from [0, 1] can be solred in O(n + m) time respectively. On random graphs polylogarithmic execuwith high probability.
tion time can be achieved.
Alternative Bucket Splitting: It is also possible to
5 Extensions
split Bcu, according to the number of stored nodes until
Other Edge Weight Distributions:
For the large only a single node remains in the new current bucket.
class of random distributions with values in [0, 1] and This approach realizes a label-setting algorithm with
distribution functions G with the properties that G(0) = similar bounds like ADAP-SP but excludes paralleliza0 and that (7'(0) exists, Lemma 4 can be restated [5]: tion beyond ~(n) time.
There are constants o < t, !~ > 1 such that the
probability that 79 is a A-path for A < c~ is bounded 6 Constructing Worst Case Graphs with
Random Edge Weights
by (/3. A)t/li. Shrinking all bucket, widths by the
constant factor fl/a, ADAP-SP still runs in linear time In this sectiou we demonstrate that random edge
on average.
weights do not automatically result in good algorithmic
Worst-Case Performance: Edge relaxations can be performance.
performed in worst-case constant time, thus improving
Deterministic worst case inputs for label-correcting
the total worst-case time bound to O ( n - m ) by main- algorithms are usually based on the principle that paths
taining an additional array Si[-] with [ l / A i ] entries for with few edges are found first but longer paths have
each level Li:
smaller total weights and hence lead to improvements on
Si [[log2(1/c(e))J] = r < i de,rotes the highest the tentative distances. Each such improvement triggers
level L,. containing an unvisited bncket B which can re-insertions which eventually make the computation
be the target of a relaxation from Bcur in Li via an expensive.
edge e with weight c(e) > Ai. Furthermore, the last
Figure 3 provides an example for the Bellman-Ford
bucket of each level Li keeps a pointer to its immediate algorithm [3, 10] with a FIFO queue: the shortest path
successor bucket B~ in some level Lk, k < i. Theu the between s and q follows the node sequence a, b, c. The
search for the target of a relaxation from Bear in Li algorithm improves tent(q) for each node on this path,
via an edge e with c(e) < Ai can be restricted to Li re-inserts q and relaxes its outgoing edges. In general,
and B~. In case c(e) > Ai, it is sufficient to lookup let the path from s to q consist of O(n) nodes and
S~ [[log2(1/c(e))J] = r and check the level i~ and the let q have out-degree O(n). Then the Bellman-Ford
bucket B~.
algorithm requires ®(n 2) time on this graph class with
Parallelization: ADAP-SP can be efficiently paral- m : O(n) edges.
lelized on shared memory machines with dynamic allocation of free processors (PUs): the more elements are
stored in Bcur the more PUs can be applied to remove all
nodes of Bcur in parallel and relax their outgoing edges.
The algorithm can compute the optimal number of pros
1
a I
cessors for the current phase itself and does not need any
knowledge about the dimneter of the input graph etc.
Figure 3: Bad input graph for the Bellman-Ford algoMost importantly, the existence of a few high-degree rithm.
nodes will not necessarily slow down the whole computation since those nodes do not. impose a globally fixed
small step width (as opposed to the A-stepping of [18]). 6.1 Emulating Fixed Edge Weights
Concurrent access to the non-replicated bucket Our main idea to construct difficult graphs with random
structure is realized by semi-sorting and implementing edge weights is to emulate edges ei with fixed weight by
the bucket lists via arrays with dynamic space doubling. whole subgraphs Si with random edge weights. Each
Skipping k empty buckets is done in O(log k) iterations ,S'i contains exactly one source si and one sink ti.
where iteration i applies ®(2 *) PUs in order to check Furthermore, the subgraphs are pairwise edge-disjoint
the next O(2/) buckets. As there are at. most n bucket and can only share sources and sinks. Each Si is built
splits and nonempty current buckets the algorithm per- by a chain of l = ~(logn) so-called (u, v,k)-gadgets.
Combining Lennnas 9, 10 and 11 gives
7! :l
804
q
Sr-I
Figure 4: Modified bad input graph with random edge weights.
An (u, v,k)-gadget consists of k + 2 nodes u, v and
w l , . . . , wk and the '2. k edges (u, wi) and (wi, v). The
parameter k is called the blow-up factor of a gadget. As
before, we will assmne that random edge weights are
independent and unifornfly drawn fi'om [0, 1].
LEMMA 12. The expected shortest path weight between
u and v in a (u, v, l)-gadget is 1, in a (u, v, 2)-gadget it
is 23/30.
P r o o f : For k = 1, there is only one a-v path in the
(u, v, 1)-gadget and its expected total weight is clearly
2 . 1 / 2 = 1.
For k = 2, let X1 and X2 be the random variables
which denote the weight of the paths (u, wl, v) and
(u, w2, v), respectively. The density function for X i is
given by f ( x ) = x, if 0 ~ x < 1, and f ( x ) = 2 - x,
1 < x < 2. The distribution function for the shortest
path weight in a (u, v, 2)-gadget is
The expected value of the shortest path is calculated
via the derivative of W ( z ) as .[£z x • w ( x ) dz = 23/30.
[]
The largest fixed edge weight is emulated by a chain of
l gadgets each of which has blow-up factor one. Shorter
fixed weights are enmlated by choosing higher blow-up
factors for some or all of the l gadgets in their respective
subgraphs. If we take the parameter I large enough then
the actual shortest paths in 5} will just slightly deviate
from their expected values with high probability. In case
the gradations between these expected values are much
higher than the deviations then the emulated behavior
will be as desired.
6.2 Example for B e l l m a n - F o r d
Now we provide a concrete conversion example for the
Belhnan-Ford algorithm with a FIFO queue. As a basis
we use the input class of Figure 3. The fixed weight
edges entering the node q are replaced by r = @(n 1/3-a)
subgraphs Si, each of which consists of a chain with
l = O(n 2/3+~) gadgets for some arbitrary constant
0 < o < 1/3. More specifically, Si includes (i. n 1/3+~')
(.,.,2)-gadgets, the remaining gadgets have blow-up
factor one. Figure 4 shows the principle.
The shortest path ~oi from s to q via Si has expected
total weight
E[wd = l - i . 7/30. n ~/3+~ +
O(rtl/3-a).
Using Chernoff bounds [16] it turns out that each wi
deviates from its expected value by at most
O ( n '13+~12 . logn) = o(n a13+~) whp.
Hence, 'too > wx > ... > wr-1 whp. On the other
hand the number of edges on the paths Pi increases in i.
Consequently, the node q is re-inserted r times whp. If q
has out-degree O(n) this means Bellman-Ford requires
non-linear O(n 4/3-~) operations on these inputs whp.
LEMMA 13. There are input graphs with n nodes and
m = O(n) edges and random edge weights such that
the Bellman-Ford algorithm, with a F I F O queue requires
O(n 4/3-c~) operations whp for any constant 0 < a
1/3.
The above input, class also yields poor performance
on other SSSP label-correcting approaches like Pallottino's algorithm [21] which has worst-case execution
tilne O(n 2 • m) but performs very well on many practical inputs [4, 27]. Pallottino's algorithm maintains two
FIFO queues Q1 and Q2. The next node to be removed
is taken from the head of Q1 if this queue is not empty
and from the head of Q2 otherwise. A node with improved distance value is added to the tail of Q1 if it. had
been queued before, or to the tail of Q2 otherwise.
805
Due to the structure of our graph class the only
nodes which can ever appear in queue Q1 are the node
q and its immediate successors nodes. Similar to the
Belhnan-Ford algorithm the FIFO queues in Pallottino's
algorithm enforce that q is reached via paths ~i in order
of increasing i. Since wo > Wl > ... > w~-i whp,
Pallottino's algorithm frequently puts q into Q1 and
thus relaxes the @(n) outgoing edges of q before the
computation carries on. Altogether the algorithm incurs
O(n 4/3-~) operations whp.
6.3
Conclusions
We have presented a label-correcting SSSP algorithm
which requires linear time whp on arbitrary directed
graphs with random edge weights. To the best of
our knowledge this is the first algorithm which provably achieves this time bound. Furthermore, we have
shown how to construct difficult non-deterministic input
graphs for many traditional label-correcting algorithms.
6.4 A c k n o w l e d g e m e n t s
The author would like to thank Volker Priebe for
valuable discussions and comments.
References
[1] R. K. Ahuja, T. L. Magnanti, and J. B. Orlin. Network
flows : Theory, Algorithms and Applications. Prentice
Hall, Englewood Cliffs, NJ, 1993.
[2] K. B. Athreya. Large deviation rates for branching
processes - I, single type case. Annals of Applied
Probability, 4(3):779-790, 1994.
[3] R. Bellman. On a routing problem. Quart. Appl.
Math., 16:87-90, 1958.
[4] B. V. Cherkassky, A. V. Goldberg, and T. Radzik.
Shortest path algorithms: Theory and experimental
evaluation. Math. Programming, 73:129-174, 1996.
[5] C. Cooper, A. Frieze, K. Mehlhorn, and V. Priebe.
Average-case complexity of shortest-paths problems
in the vertex-potential model. Random Structures
Algorithms, 16:33-46, 2000.
[6] E. V. Denardo and B. L. Fox. Shortest route methods:
1. reaching pruning and buckets. Operations Research,
27:161-186, 1979.
[7] R. B. Dial. Algorithm 360: Shortest-path forest with
topological ordering.
Commvnications of the ACM,
12(11):632-633, 1969.
[8] E. W. Dijkstra. A note on two problems in connexion
with graphs. Num. Math., 1:269-271, 1959.
[9] E. A. Dinic. Economical algorithms for finding shortest paths in a network. In Transportation Modeling
Systems, pages 36-44, 1978.
[10] L. R. Ford and D. R. Fulkerson. Flows in Netu,orks.
Princeton Univ. Press, Princeton, NJ, 1963.
806
[11] M. L. Fredman and R. E. Tarjan. Fibonacci heaps
and their uses in improved network optimization algorithms. Journal of the ACM, 34:596-615, 1987.
[12] A. M. Frieze and G. R. Grimmett. The shortest-path
problem for graphs with random arc-lengths. Discrete
Applied Mathematics, 10:57-77, 1985.
[13] A. V. Goldberg and R. E. Tarjan. Expected performance of Dijkstra's shortest path algorithm. Technical
Report TR-96-062, NEC Research, 1996.
[14] T. Hagerup. Improved shortest paths on the word
RAM. In 27th Colloquium on Automata, Languages
and Programming (ICALP), volume 1853 of LNCS,
pages 61-72. Springer, 2000.
[15] R. Hassin and E. Zemel. On shortest paths in graphs
with random weights. Math. Oper. Res., 10(4):557-564,
1985.
[16] C. McDiarmid. Concentration. In Michel Habib, Colin
McDiarmid, Jorge Ramirez-Alfonsin, and Bruce Reed,
editors, Probabilistic Methods for Algorithmic Discrete
Mathematics, volume 16 of Algorithms Combin., pages
195 248. Springer, 1998.
[17] K. Mehlhorn and V. Priebe. On the all-pairs shortestpath algorithm of Moffat and Takaoka. Random Structures ~J Algorithms, 10:205-220, 1997.
[18] U. Meyer and P. Sanders.
A-stepping: A parallel
shortest path algorithm. In 6th European Symposium
on Algorithms (ESA), volume 1461 of LNCS, pages
393-404. Springer, 1998.
[19] A. Moffat and T. Takaoka.
An all pairs shortest
path algorithm with expected time O(n 2 log n). SIAM
Jo,trnal on Computing, 16:1023-1031, 1987.
[20] K. Noshita. A theorem on the expected complexity
of Dijkstra's shortest path algorithm.
Journal o]
Algorithms, 6:400-408, 1985.
[21] S. Pallottino. Shortest-path methods: Complexity,
interrelations and new propositions. Networks, 14:257267, 1984.
[22] R. Raman. Priority queues: Small, monotone and
trans-dichotomous. In 4th Annual European Symposium on Algorithms (ESA), volume 1136 of LNCS,
pages t21-137. Springer, 1996.
[23] R. Raman. Recent results on the single-source shortest
paths problem. ACM SIGACT News, 28(2):81-87,
June 1997.
[24] P. M. Spira. A new algorithm for finding all shortest
paths in a graph of positive arcs in average time
O(n 2 log 2 n). SL4M Journal on Computing, 2:28-32,
1973.
[25] M. Thorup. Undirected single-source shortest paths
with positive integer weights in linear time. Journal of
the ACM, 46:362-394, 1999.
[26] M. Thorup. On RAM priority queues. SIAM Journal
on Computing, 30:86-109, 2000.
[27] F. B. Zhan and C. E. Noon. Shortest path algorithms:
An evahmtion using real road networks. Transportation
Science, 32:65-73, 1998.
© Copyright 2026 Paperzz