Title: MIKKEL THORUP
1Undirected Single-Source Shortest Paths with
Positive Integer Weights in Linear Time
- MIKKEL THORUP
- 1999 Journal of the ACM
2Presenters
3Outline
- Introduction
- Preliminary
- Avoiding the Sorting Bottleneck
- The Component Hierarchy
- Visiting Minimal Vertices
- Towards Linear Time
- The Component Tree
4Introduction(1)
- Mikkel Thorup
- http//www.diku.dk/mthorup/
5Introduction(2)
P
S
S
S
ingle
ath
hortest
ource
Shortest path
problem
Shortest path
S
Shortest path
- Given a positively weighted graph G with a source
vertex s, - find the shortest path from s to all other
vertices in the graph
6Introduction(3)History
- Since 1959, all developments in SSSP have been
based on Dijkstras algorithm (1959)
7Dijkstras algorithm(1)
D(v)
- Notation
- G (V, E)
- v n , E m
- weighted function l edge ? positive integer
- If (v, w) E , define l(v, w) 8
- d(v) distance from s to v
- D(v) super distance
- D(v) ? d(v)
a set S V v S D(v)
d(v) v S D(v) min
d(u) l(u, v)
u S
v can go to S
D(v) super distance
v can go to S
8Dijkstras algorithm(2)
V
v8
v4
v6
v7
v8
v1
v4
v7
v1
v2
v3
v5
v3
v2
v5
v6
min
v3
v1
v2
0
7
0
8
7
4
4
S
v5
8
6
6
v4
visit
v6
v3
Initially
v8
8
8
7
7
7
v6
v5
v4
v7
min
v2
v1
5
8
5
6
6
v7
v8
Increasing order
9Introduction(3)History
Thorups priority queue (1996)
Raman (1996)
Fredman Willards fusion trees
(1993)
Fredman Tarjan Fibonacci heaps
(1987)
Fredman Willards atmoic heaps
(1994)
Applying Williams heap
(1964)
Simple
O(m)
our target !!
Dijkstras algorithm (1959)
10Introduction(4)
- In fact, Dijkstras algorithm can be
implemented in linear time ? - ( Fredman Tarjan 1987 , Thorup 1996 )
linear time sorting
Since we do not know how to sort in linear time,
this implies that we are deviating from
Dijkstras algorithm in that we do not visit the
vertices in order of increasing distance from s.
Our algorithm is based on a hierarchical
bucketing structure. ? may visit the vertices
in any order
11Outline
- Introduction
- Preliminary
- Avoiding the Sorting Bottleneck
- The Component Hierarchy
- Visiting Minimal Vertices
- Towards Linear Time
- The Component Tree
12Preliminary(1)
- Lemma 1
- If v S\V minimize D(v) , D(v) d(v)
- Lemma 2
- minD(V\S) mind(V\s) is non-decreasing
13Preliminary(2)
- Notation
- x gtgt i
- is x / 2
- If x ? y gt x gtgt i ? y gtgt i
- If W V , minD(W) gtgt i
- is (min D(w) w W ) gtgt i
i
14Preliminary(3)
- Bucket
- which elements can be inserted and deleted,and
from which we can pick out an unspecified
element. - each operation should be supported in constant
time.
15Outline
- Introduction
- Preliminary
- Avoiding the Sorting Bottleneck
- The Component Hierarchy
- Visiting Minimal Vertices
- Towards Linear Time
- The Component Tree
16Avoiding the Sorting Bottleneck(1)
- Dijkstras algorithm
- visit the vertices in order of increasing D(v)
- New approach
- visit the vertices where D(v) d(v)
- D(v) ? min D(V\S)
17Avoiding the Sorting Bottleneck(2)
- For some i, v Vi\S,D(v) min D(Vi\S)? min
D(V\S) d - d(v) D(v)
d
18Avoiding the Sorting Bottleneck(3)
- Criteria on D(v) d(v)
- D(v) min D(Vi\S) ? min D(V\S) d
- lt min D(Vi\S) ? min D(V\S) 2a
- lt min D(Vi\S) gtgt a ? min D(V\S) gtgt a
- Bucketing structure
i
j
D(v) ? Se l(e) ? Se l(e) gtgt a
19Avoiding the Sorting Bottleneck(4)
d 20 , a 0
4
min D(V\S) min d(V\S) is nondecreasing
0
8
8
4
7
B(min D(Vi\S) gtgt a) i
8
6
8
8
1
2
3
2
0
5
8
1
2
3
4
6
7
8
5
5
8
20Avoiding the Sorting Bottleneck(5)
? Se l(e) gtgt a d 2a
O(m ?) cost of maintaining min D(Vi\S) for
each i
21Outline
- Introduction
- Preliminary
- Avoiding the Sorting Bottleneck
- The Component Hierarchy
- Visiting Minimal Vertices
- Towards Linear Time
- The Component Tree
22The Component Hierarchy(1)
- Definition
- Githe subgraph of G with l(e) lt 2i
- vithe connected component on level i
containing v - children of viwi-1, w vi
v
v2
v1
w1
v
w
Go
G1
G2
G3 G
23The Component Hierarchy(2)
- Definition
- vi is a min-child of vi1 if min D(vi-) gtgt
i min D(vi1-) gtgt i - vi is minimal if vj is a min-child of vj1
for j i, , b-1
24The Component Hierarchy(3)
Dijkstras algorithm
visit v, if v V\S minimizes D(v)
i, min D(vi-) gtgt i D(vi1-) gtgt i D(v) gtgt
i gt v0 minimal
minimal D(v) d(v) v0 minimal
D(v) d(v) v0 minimal
25The Component Hierarchy(4)
lemma 8 If v S and vi is minimal, min
D(vi-) min d(vi-). In particular, D(v)
d(v) if v0 v is minimal.
26Outline
- Introduction
- Preliminary
- Avoiding the Sorting Bottleneck
- The Component Hierarchy
- Visiting Minimal Vertices
- Towards Linear Time
- The Component Tree
27Visiting Minimal Vertices(1)
- Definition
- visiting a vertex requires that v0 v is
minimal - when v is visited, v is moved to S and relax
- Lemma 10
- For all vi, max d(vi\vi-) gtgt i-1 ? min
d(vi-) gtgt i-1 - Lemma 11
- min D(vi-) gtgt i min d(vi-) gtgt i, visiting w
changes min D(vi-) gtgt i, and the change in min
D(vi-) gtgt i is increased by one
28Visiting Minimal Vertices(2)
- Lemma 12, 13
- If vi has once been minimal, in all future,min
D(vi-) gtgt i min d(vi-) gtgt i
29Visiting Minimal Vertices(3)
wi minimal
Visit(si)
s
8
4
4
0
d(w) gtgt i min D(si-) gtgt i
min D(wi-1-) gtgt i - 1 min D(si-) gtgt i - 1
8
Visit(wi-1)
8
8
s0, i 0
s3 G, i 3
s2, i 2
s1, i 1
8
5
30Visiting Minimal Vertices(4)
Towards Linear Time !!
31Outline
- Introduction
- Preliminary
- Avoiding the Sorting Bottleneck
- The Component Hierarchy
- Visiting Minimal Vertices
- Towards Linear Time
- The Component Tree
32Towards Linear Time(1)
Number of nodes
1
1
b
c
a
3
2
3
1
d
e
2
1
3
2
f
c
a
b
d
f
e
33Towards Linear Time(2)
- Linear size bucket structure
i
j
? Se l(e) gtgt a
34Towards Linear Time(3)
- Lemma 18. The total number of relevant buckets is
lt 4m 4n - Diameter of vI is bounded by
- gt
- Define
- gt
35Towards Linear Time(4)
- Lemma 18. The total number of relevant buckets is
lt 4m 4n
36Towards Linear Time(5)
37Towards Linear Time(6)
38Towards Linear Time(7)
39Towards Linear Time(8)
0 0 0 0
0 0
40Towards Linear Time(9)
Total O(m)
Total O(m)
Total O(n)
Total O(m)
41Towards Linear Time(10)
- Assume that the component tree has been
computed in linear time. Then no more than O(m)
time and space is needed to solve the SSSP
problem - How to construct the component tree ?
42Outline
- Introduction
- Preliminary
- Avoiding the Sorting Bottleneck
- The Component Hierarchy
- Visiting Minimal Vertices
- Towards Linear Time
- The Component Tree
43The Component Tree(1)
44The Component Tree(2)
- Use union-find operation
- Let e1, , en-1 be the edges of M sorted
according to -
45The Component Tree(3)
v1
v3
v2
v1,v2,v3,v4,v5,v6,v7,v8
4
3
2
v4,v5,v6,v7,v8
v3,
v2,
v4
4
5
1
1
v4,v5
v7,v8
,v6
v5
v6
1
2
2
1
v1
v2
v3
v4
v5
v6
v7
v8
v7
v8