undirected single-source shortest paths with positive integer weights in linear time

Post on 19-Jan-2016

28 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

Undirected Single-Source Shortest Paths with Positive Integer Weights in Linear Time. MIKKEL THORUP 1999 Journal of the ACM. Presenters. 資訊四 巨彥霖 資訊四 羅婉嫣 資訊四 許恒瑞. Outline. Introduction Preliminary Avoiding the Sorting Bottleneck The Component Hierarchy Visiting Minimal Vertices - PowerPoint PPT Presentation

TRANSCRIPT

MIKKEL THORUP1999 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 ource hortest ath

problem

S PSS

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

v1 v2 v3 v4 v5 v6 v7

S = {

v8}

}4

5

min

4 7

6

6

min

5

7

6

6

77

70

v1 v4v3v2 v7v5 v6 v8

Initially

v1

v5

v3

v6

v2

v8v7

v4

v1v2

v7v4

v8v3

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 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 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 bucketing 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 element.

each operation should be supported in constant time.

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

V3V2V1

δ

For some i, v Vi\S,

D(v) = min D(Vi\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(Vi\S) ≦ min D(V\S) + δ

<= min D(Vi\S) ≦ min D(V\S) + 2α

<= min D(Vi\S) >> α ≦ min D(V\S) >> α

Bucketing structure

i

min D(Vi\S) >> αix

j

D(v) ≦ Σe l(e)

Δ = Σe l(e) >> αΔ+ 2

Avoiding the Sorting Bottleneck(4)

SSSP algorithm A

0

∞ ∞

∞ ∞

∞∞

V3V2V1

δ

δ = 20 , α = 04

5 0 1 2 3 4

……5 ∞

12 3

ix

B(min D(Vi\S) >> α) = i4

6

7

26 7

min D(V\S) = min d(V\S) is nondecreasing

5

Avoiding the Sorting Bottleneck(5)

SSSP algorithm A

O(m + Δ) + cost of maintaining min D(Vi\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 Gi: the subgraph of

G with l(e) < 2i

[v]i: the connected component on level i containing v

children of [v]i: [w]i-1, w [v]i

GoG1G2G3 = 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 increased 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

22)( e

a b c d e f

1 2

3 a b c

d e

f

1 1

12 3

3 212)( 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

ix0 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

=>

ivee

][)(

iveii evdvd][

)()]([min)]([max

)]([)]([)]([ 0 iii vvixvix

1

][2/)()]([

i

veiiev

ii vev

ien][,][

12/)(4

Towards Linear Time(4)

Lemma 18. The total number of relevant buckets is < 4m + 4n

Ee ev

i

i

en][

12/)(4

Ee ev

ij

i

n][

12/24

mnnEe

4444

42

2

2

2

2

22/2

111

j

j

j

j

j

j

ji

ij

1

][2/)()]([

i

veiiev

i ii v ve

i

vi ev

][ ][

1

][

2/)(2)]([1 12 is in node# n

1)(log2 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

ix0 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 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 ?

Outline

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

The Component Tree(1)

ii levelon 2 weight of edges all

xxmsb 2log)(

elinear timin treespanning minimum aconstruct M

})2)(|{,(][

[v]i

iMi

i

eMeVv

G

)]([)]([)()(][][

iMi

veve

vdiametervdiametereeMii

The Component Tree(2)

Use union-find operation

Let e1, …, en-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

v1 v2 v3

v4

v7

v5 v6

v8

v1 v2 v3 v4 v5 v6 v7 v8

1s},{ 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

top related