thorupinearssspppt dfd sdfsdcx dsfds dsfds

MohamedKhalil199 11 views 45 slides Sep 27, 2024
Slide 1
Slide 1 of 45
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45

About This Presentation

Avoiding sorting Bottlenck


Slide Content

MIKKEL THORUP
1999 Journal of the ACM
Undirected Single-Source
Shortest Paths with Positive
Integer Weights in Linear Time

Presenters
資訊四 巨彥霖
資訊四 羅婉嫣
資訊四 許恒瑞

Outline
Introduction
Preliminary
Avoiding the Sorting Bottleneck
The Component Hierarchy
Visiting Minimal Vertices
Towards Linear Time
The Component Tree

Introduction(1)
Mikkel Thorup
http://www.diku.dk/~mthorup/

Introduction(2)
Given a positively weighted graph G with a source vertex s,
find the shortest path from s to all other vertices in the graph
ingleS ourcehortestath
problem
S PS
S
Shortest path
Shortest path
Shortest path

Introduction(3)
History
Since 1959, all developments in SSSP have
been based on Dijkstra’s algorithm (1959)

Dijkstra’s algorithm(1)
Notation:
G = (V, E)
| v | = n , | E | = m
weighted function l : edge  positive integer

If (v, w) E , define l(v, w) = ∞
 d(v) : distance from s to v
D(v) : super distance
D(v) d(v)
≧
D(v) : super distance
a set S V
v S : D(v) = d(v)
v S : D(v) = min { d(u) + l(u, v) } 

13
80
20
53
d(v)
10

D(v)
v can go to S
v can go to S
u S

Dijkstra’s algorithm(2)
V = {
0
v1v2v3v4v5v6v7
S = {
v8}
}
4





5
min
4 7
6
6
min
5
7
6
6
77
70
v1 v4v3v2 v7v5v6v8
Initially
v1
v5
v3
v6
v2
v8
v7
v4
v1
v2
v7
v4
v8
v3
v5
v6
Increasing order
visit

Introduction(3)
History
)log( nnmO
Dijkstra’s algorithm
(1959)
Simple :
Applying William’s heap :

(1964)
Fredman & Tarjan Fibonacci heaps :

(1987)
Fredman & Willard’s fusion trees :

(1993)
O(m)
our target !!
)log( nmO
)(
2
mnO
)log( nmO )loglog/log( nnnmO
)log(
1
 nnmO
)logloglog( nnnmO
Fredman & Willard’s atmoic heaps :
(1994)
Thorup’s priority queue :
(1996)
Raman :
(1996)

Introduction(4)
In fact, Dijkstra’s algorithm can be implemente
d 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 Dijkstra’
s algorithm in that we do not visit the vertices in
order of increasing distance from s.
Our algorithm is based on a hierarchical buck
eting structure.
 may visit the vertices in any order

Outline
Introduction
Preliminary
Avoiding the Sorting Bottleneck
The Component Hierarchy
Visiting Minimal Vertices
Towards Linear Time
The Component Tree

Preliminary(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

Preliminary(2)
Notation:
x >> i
is [ x / 2 ]
If x y => x >> i y >> i
≦ ≦
If W V , minD(W) >> i
is (min{ D(w) | w W }) >> i

i

Preliminary(3)
Bucket
which elements can be inserted and deleted,and
from which we can pick out an unspecified eleme
nt.
each operation should be supported in constant ti
me.

Outline
Introduction
Preliminary
Avoiding the Sorting Bottleneck
The Component Hierarchy
Visiting Minimal Vertices
Towards Linear Time
The Component Tree

Avoiding the Sorting Bottleneck(1)
Dijkstra’s 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)

Avoiding the Sorting Bottleneck(2)
0

∞ ∞
5 ∞
∞4
V
3
V
2
V
1
δ
For some i, v V
i\S,
D(v) = min D(V
i\S)
min D(V\S) + δ

d(v) = D(v)

0 1 2 3 4 index
content…

Avoiding the Sorting Bottleneck(3)
Criteria on D(v) = d(v)
D(v) = min D(V
i\S) ≦ min D(V\S) + δ
<= min D(V
i\S) ≦ min D(V\S) + 2
α
<= min D(V
i\S) >> α ≦ min D(V\S) >> α
Bucketing structure
i
min D(V
i
\S) >> αix
j
D(v) ≦ Σ
e l(e)
Δ = Σ
e
l(e) >> α
Δ+ 2

Avoiding the Sorting Bottleneck(4)
SSSP algorithm A
0

∞ ∞


∞∞
V
3
V
2
V
1
δ
δ = 2
0
, α = 0
4
5 01234


5 ∞
12 3
ix
B(min D(Vi\S) >> α) = i
4
6
7
2
67
min D(V\S) = min d(V\S) is nond
ecreasing
5

Avoiding the Sorting Bottleneck(5)
SSSP algorithm A
O(m + Δ) + cost of maintaining min D(V
i
\S) for each i
Δ = Σe l(e) >> α
δ = 2
α

Outline
Introduction
Preliminary
Avoiding the Sorting Bottleneck
The Component Hierarchy
Visiting Minimal Vertices
Towards Linear Time
The Component Tree

The Component Hierarchy(1)
Definition
G
i:the subgraph of
G with l(e) < 2
i
[v]
i:the connected
component on level i
containing v
children of [v]
i:[w]
i-1,
w [v]
i
G
oG
1G
2G
3 = G
v
[v]
1

v
[v]
2
w
[w]
1

The Component Hierarchy(2)
Definition
[v]
i is a min-child of [v]
i+1
if min D([v]
i
-
) >> i = min D([v]
i+1
-
) >> i
[v]
i is minimal if [v]
j is a min-child of [v]
j+1 for j = i, …,
b-1
[v]
2
[v]
1
v

The Component Hierarchy(3)

Dijkstra’s algorithm
visit v, if v V\S minimizes D(v)
i, min D([v]
i
-
) >> i = D([v]
i+1
-
) >> i = D(v) >> i => [v]
0
minimal
minimal D(v) = d(v) [v]
0 minimal
D(v) = d(v) [v]
0
minimal

The Component Hierarchy(4)
lemma 8
If v S and [v]
i is minimal, min D([v]
i
-
) = min d([v]
i
-
).
In particular, D(v) = d(v) if [v]
0
= {v} is minimal.

Outline
Introduction
Preliminary
Avoiding the Sorting Bottleneck
The Component Hierarchy
Visiting Minimal Vertices
Towards Linear Time
The Component Tree

Visiting Minimal Vertices(1)
Definition
visiting a vertex requires that [v]
0 = {v} is minimal
when v is visited, v is moved to S and relax
Lemma 10
For all [v]
i,
max d([v]
i\[v]
i
-
) >> i-1 ≦ min d([v]
i
-
) >> i-1
Lemma 11
min D([v]
i
-
) >> i = min d([v]
i
-
) >> i, visiting w changes
min D([v]
i
-
) >> i, and the change in min D([v]
i
-
) >> i is i
ncreased by one

Visiting Minimal Vertices(2)
Lemma 12, 13
If [v]
i has once been minimal, in all future,
min D([v]
i
-
) >> i = min d([v]
i
-
) >> i

Visiting Minimal Vertices(3)
SSSP algorithm B,C
[s]
3
= G, i = 3
0
∞ ∞
∞5
4


d(w) >> i = min D([s]
i
-
) >> i
min D([w]
i-1
-
) >> i - 1
= min D([s]
i
-
) >> i - 1
Visit([s]
i)
Visit([w]
i-1
)
[s]
2, i = 2
s
[s]
1, i = 1[s]
0, i = 0
4
[w]
i
minimal

Visiting Minimal Vertices(4)
Towards Linear Time !!

Outline
Introduction
Preliminary
Avoiding the Sorting Bottleneck
The Component Hierarchy
Visiting Minimal Vertices
Towards Linear Time
The Component Tree

Towards Linear Time(1)
Component tree
2
2)(e
a b c d e f
1 2
3
a b c
d e
f
1 1
1
2 3
3 2
1
2)(e
12nNumber of nodes

Towards Linear Time(2)
Linear size bucket structure

   )1)(min,(in bucket
of children allfor


iwDvBw
vw
hih
ih
0 1 2 3 4 index
content…

i
ix
j
Δ = Σ
e
l(e) >> αΔ+ 2

1)]([min)]([ 

ivDvix
ii
1)]([max)]([
1)]([min)]([
0



ivdvix
ivdvix
ii
ii
ix
0 index
content…
… ix

Towards Linear Time(3)
Lemma 18. The total number of relevant buckets is
< 4m + 4n
Diameter of [v]
I is bounded by
=>
Define
=>


i
ve
e
][
)(



i
ve
ii
evdvd
][
)()]([min)]([max 
)]([)]([)]([
0 iii
vvixvix 

 
1
][
2/)()]([


i
ve
i
i
ev 





ii
vev
i
en
][,][
1
2/)(4 
Towards Linear Time(4)
Lemma 18. The total number of relevant buckets is
< 4m + 4n

 


Ee ev
i
i
en
][
1
2/)(4 

 


Ee ev
ij
i
n
][
1
2/24
mnn
Ee
4444 

4
2
2
2
2
2
2
2/2
11
1




 
j
j
j
j
j
j
ji
ij
 
1
][
2/)()]([


i
ve
i
i
ev 
 
 











i ii v ve
i
v
i
ev
][ ][
1
][
2/)(2)]([1  12 is in node#  n
 1)(log
2
 ej 

Towards Linear Time(5)

Towards Linear Time(6)
O(m)

Towards Linear Time(7)

Towards Linear Time(8)
1)]([min ivD
i )]([)]([
0 ii vvix 
ix
0 index
content…
… ix

0 0 0 0 0 0
O(m)

Towards Linear Time(9)
Total: O(m)
Total: O(m)
Total: O(n)
Total: O(m)

Towards Linear Time(10)
Assume that the component tree has been com
puted in linear time. Then no more than O(m) time a
nd space is needed to solve the SSSP problem
How to construct the component tree ?

Outline
Introduction
Preliminary
Avoiding the Sorting Bottleneck
The Component Hierarchy
Visiting Minimal Vertices
Towards Linear Time
The Component Tree

The Component Tree(1)
i
i
levelon 2 weight of edges all 
 xxmsb
2log)(
elinear timin treespanning minimum aconstruct M
})2)(|{,(][
[v]
i
iM
i
i
eMeVv
G



)]([)]([)()(
][][
i
M
i
veve
vdiametervdiameteree
M
ii




The Component Tree(2)
Use union-find operation
Let e
1, …, e
n-1 be the edges of M sorted
according to

))((
iemsb
))(())((
1
ii emsbemsb 

The Component Tree(3)
0)(
0)(


v
vc


Xc
vs
,0
0)(
4 3
2
1 1 4
1
22
5
1
v
1 v
2
v
3
v
4
v
7
v
5 v
6
v
8
v
1
v
2v
3v
4v
5v
6v
7v
8
1s},{
54
vvX
),())(())((
)}(),({
uvufindsvfindss
ufindvfindXX


svfinds
uvunion
))((
),(
v4,v5
No! ?))(())((
1
ii emsbemsb 
2 },,,{
654  svvvX
,v6 v7,v8
},,,,{
87654 vvvvvX
!Yes! ?))(())((
1
ii emsbemsb 
},{
74
'
vvX
v4,v5,v6,v7,v8v3,v2
,
v1,v2,v3,v4,v5,v6,v7,v8
12 nodes ofnumber n