SlideShare une entreprise Scribd logo
1  sur  158
Télécharger pour lire hors ligne
Implementation
of Thorup's
Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive

Implementation of Thorup's Linear Time

Integer Weights
Nick Prühs

Algorithm for Undirected Single-Source
Shortest Paths with Positive Integer Weights

Introduction
Thorup's
algorithm

Overview

Nick Prühs

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B

Department of Computer Science, CAU Kiel

September 30, 2009

Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation
of Thorup's
Linear Time
Algorithm for
Undirected

Introduction

Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation
of Thorup's
Linear Time
Algorithm for
Undirected

Introduction

Single-Source
Shortest Paths
with Positive
Integer Weights

Thorup's algorithm

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation
of Thorup's
Linear Time
Algorithm for
Undirected

Introduction

Single-Source
Shortest Paths
with Positive
Integer Weights

Thorup's algorithm

Nick Prühs

Introduction

Implementation details

Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation
of Thorup's
Linear Time
Algorithm for
Undirected

Introduction

Single-Source
Shortest Paths
with Positive
Integer Weights

Thorup's algorithm

Nick Prühs

Introduction

Implementation details

Thorup's
algorithm

Overview

Performance

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation
of Thorup's
Linear Time
Algorithm for
Undirected

Introduction

Single-Source
Shortest Paths
with Positive
Integer Weights

Thorup's algorithm

Nick Prühs

Introduction

Implementation details

Thorup's
algorithm

Overview

Performance

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B

Conclusion

Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation
of Thorup's

Introduction

Linear Time
Algorithm for
Undirected
Single-Source

Thorup's algorithm
Overview
msb-Minimum spanning tree M
Component tree T
Bucketing structure B
Unvisited data structure U
Visiting components and vertices
Implementation details
Performance

Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details

Conclusion

Performance
Conclusion
Introduction

Implementation
of Thorup's
Linear Time

The Single-Source Shortest Paths Problem

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

in:

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Introduction

of Thorup's
Linear Time

The Single-Source Shortest Paths Problem

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

in:

Introduction

undirected, connected graph
vertices and |E | = m edges

G = (V , E ) with |V | = n

Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Introduction

Implementation
of Thorup's
Linear Time

The Single-Source Shortest Paths Problem

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

in:

Introduction

undirected, connected graph G = (V , E ) with |V | = n
vertices and |E | = m edges
positive edge weight function w : V × V → N with

∀(u , v ) ∈ E : w (u , v ) = ∞
/

Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Introduction

of Thorup's
Linear Time

The Single-Source Shortest Paths Problem

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

in:

Introduction

undirected, connected graph G = (V , E ) with |V | = n
vertices and |E | = m edges
positive edge weight function w : V × V → N with

∀(u , v ) ∈ E : w (u , v ) = ∞
/

distinguished source vertex

s∈V

Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Introduction

of Thorup's
Linear Time

The Single-Source Shortest Paths Problem

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

in:

Introduction

undirected, connected graph G = (V , E ) with |V | = n
vertices and |E | = m edges
positive edge weight function w : V × V → N with

∀(u , v ) ∈ E : w (u , v ) = ∞
/

distinguished source vertex

s∈V

out: d (v ) = dist (v , s ) for all other vertices v ∈ V  {s }

Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Introduction

Implementation
of Thorup's
Linear Time

Dijkstra's algorithm

Algorithm for
Undirected

proposed by Edsger W. Dijkstra [Dij59]

Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Introduction

of Thorup's
Linear Time

Dijkstra's algorithm

Algorithm for
Undirected

proposed by Edsger W. Dijkstra [Dij59]
additional denitions:
set of visited vertices S ⊆ V
super distance D (v ) ≥ d (v ) for every vertex
with

D (v ) =

d (v ),

minu∈S {d (u ) + w (u , v )},

v ∈S
v ∈S
/

Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

v ∈ V,

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Introduction

of Thorup's
Linear Time

Dijkstra's algorithm

Algorithm for
Undirected

proposed by Edsger W. Dijkstra [Dij59]
additional denitions:
set of visited vertices S ⊆ V
super distance D (v ) ≥ d (v ) for every vertex
with

D (v ) =
initialization:

d (v ),

minu∈S {d (u ) + w (u , v )},

S = {s }
D (s ) = d (s ) = 0
∀v = s : D (v ) = w (s , v )

v ∈S
v ∈S
/

Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

v ∈ V,

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Introduction

of Thorup's
Linear Time

Dijkstra's algorithm

Algorithm for
Undirected

proposed by Edsger W. Dijkstra [Dij59]
additional denitions:
set of visited vertices S ⊆ V
super distance D (v ) ≥ d (v ) for every vertex
with

D (v ) =

d (v ),

minu∈S {d (u ) + w (u , v )},

Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

v ∈ V,

v ∈S
v ∈S
/

initialization:

Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

S = {s }
D (s ) = d (s ) = 0
∀v = s : D (v ) = w (s , v )

algorithm:
1. while S = V :

Introduction

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation

visit the vertex v ∈ S minimizing D (v )
/

details
Performance
Conclusion
Implementation

Introduction

of Thorup's
Linear Time

Dijkstra's algorithm

Algorithm for
Undirected

proposed by Edsger W. Dijkstra [Dij59]
additional denitions:
set of visited vertices S ⊆ V
super distance D (v ) ≥ d (v ) for every vertex
with

D (v ) =

d (v ),

minu∈S {d (u ) + w (u , v )},

Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

v ∈ V,

Introduction

v ∈S
v ∈S
/

Thorup's
algorithm

Overview

msb-Minimum

spanning tree M

initialization:

Component tree

T

S = {s }
D (s ) = d (s ) = 0
∀v = s : D (v ) = w (s , v )

algorithm:
1. while S = V :
1.1

move

1.2

for all

v

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation

visit the vertex v ∈ S minimizing D (v )
/

to

S,

because

(u , v ) ∈ E ,

the latter is less

Performance

D (v )

decrease

= d (v )
D (u ) to D (v ) + w (u , v ),

details

Conclusion

if
Introduction

Implementation
of Thorup's
Linear Time

The problem: The bottleneck of Dijkstra's algorithm

Algorithm for
Undirected

running time results from two operations:

Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Introduction

of Thorup's
Linear Time

The problem: The bottleneck of Dijkstra's algorithm

Algorithm for
Undirected

running time results from two operations:
deleteMin: nd a vertex v ∈ S minimizing
/
(exactly n − 1 times)

Single-Source
Shortest Paths

D (v )

with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Introduction

Implementation
of Thorup's
Linear Time

The problem: The bottleneck of Dijkstra's algorithm

Algorithm for
Undirected

running time results from two operations:
deleteMin: nd a vertex v ∈ S minimizing D (v )
/
(exactly n − 1 times)
decreaseKey: decrease D (u ) (at most m times)

Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Introduction

Implementation
of Thorup's
Linear Time

The problem: The bottleneck of Dijkstra's algorithm

Algorithm for
Undirected

running time results from two operations:
deleteMin: nd a vertex v ∈ S minimizing D (v )
/
(exactly n − 1 times)
decreaseKey: decrease D (u ) (at most m times)
naive implementation:
deleteMin in O (n)
decreaseKey in O (1)
total running time is O (n2 + m)

Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Introduction

Implementation
of Thorup's
Linear Time

The problem: The bottleneck of Dijkstra's algorithm

Algorithm for
Undirected

running time results from two operations:
deleteMin: nd a vertex v ∈ S minimizing D (v )
/
(exactly n − 1 times)
decreaseKey: decrease D (u ) (at most m times)
naive implementation:
deleteMin in O (n)
decreaseKey in O (1)
total running time is O (n2 + m)
implementation with Fibonacci heaps [FT84]:
deleteMin has amortized running time O (log n)
decreaseKey has running time O (1)
total running time is O (n log n + m)

Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Introduction

Implementation
of Thorup's
Linear Time

The problem: The bottleneck of Dijkstra's algorithm

Algorithm for
Undirected

running time results from two operations:
deleteMin: nd a vertex v ∈ S minimizing D (v )
/
(exactly n − 1 times)
decreaseKey: decrease D (u ) (at most m times)
naive implementation:
deleteMin in O (n)
decreaseKey in O (1)
total running time is O (n2 + m)
implementation with Fibonacci heaps [FT84]:
deleteMin has amortized running time O (log n)
decreaseKey has running time O (1)
total running time is O (n log n + m)
linear time Dijkstra requires linear time sorting

Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Introduction

Implementation
of Thorup's
Linear Time

The problem: The bottleneck of Dijkstra's algorithm

Algorithm for
Undirected

running time results from two operations:
deleteMin: nd a vertex v ∈ S minimizing D (v )
/
(exactly n − 1 times)
decreaseKey: decrease D (u ) (at most m times)
naive implementation:
deleteMin in O (n)
decreaseKey in O (1)
total running time is O (n2 + m)
implementation with Fibonacci heaps [FT84]:
deleteMin has amortized running time O (log n)
decreaseKey has running time O (1)
total running time is O (n log n + m)
linear time Dijkstra requires linear time sorting
sorting using comparisons only requires Ω(n log n)
comparisons

Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Introduction

Implementation
of Thorup's
Linear Time

The solution: Avoiding the sorting bottleneck

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Introduction

Implementation
of Thorup's
Linear Time

The solution: Avoiding the sorting bottleneck

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Thorup [Tho99] does not visit the vertices in order of
increasing distance from s

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Introduction

Implementation
of Thorup's
Linear Time

The solution: Avoiding the sorting bottleneck

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Thorup [Tho99] does not visit the vertices in order of
increasing distance from s
identies vertex pairs that can be visited in any order,
using a hierarchical bucketing structure

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Introduction

Implementation
of Thorup's
Linear Time

The solution: Avoiding the sorting bottleneck

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Thorup [Tho99] does not visit the vertices in order of
increasing distance from s

Introduction
Thorup's
algorithm

identies vertex pairs that can be visited in any order,
using a hierarchical bucketing structure

Overview

requires several other data structures to be computed
before

Bucketing
structure B

msb-Minimum

spanning tree M
Component tree

T

Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation
of Thorup's

Introduction

Linear Time
Algorithm for
Undirected
Single-Source

Thorup's algorithm
Overview
msb-Minimum spanning tree M
Component tree T
Bucketing structure B
Unvisited data structure U
Visiting components and vertices
Implementation details
Performance

Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details

Conclusion

Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

Overview

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive

Thorup's algorithm inherits. . .

Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm

of Thorup's
Linear Time

Overview

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive

Thorup's algorithm inherits. . .
. . . the denition of G , V , E , n,

Integer Weights

m, w , d , s , S and D

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm

of Thorup's
Linear Time

Overview

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive

Thorup's algorithm inherits. . .
. . . the denition of G , V , E , n,
. . . the initialization of S and D

Integer Weights

m, w , d , s , S and D

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

Overview

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive

Thorup's algorithm inherits. . .
. . . the denition of G , V , E , n, m, w , d , s , S and D
. . . the initialization of S and D
. . . visiting a vertex v ∈ V , which might decrease D (u )
for some adjacent vertices u ∈ V and moves v to S

Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

Overview

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive

Thorup's algorithm inherits. . .
. . . the denition of G , V , E , n, m, w , d , s , S and D
. . . the initialization of S and D
. . . visiting a vertex v ∈ V , which might decrease D (u )
for some adjacent vertices u ∈ V and moves v to S
but Thorup allows visiting a vertex v ∈ S not
/
minimizing D (v )

Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

Overview

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive

Thorup's algorithm inherits. . .
. . . the denition of G , V , E , n, m, w , d , s , S and D
. . . the initialization of S and D
. . . visiting a vertex v ∈ V , which might decrease D (u )
for some adjacent vertices u ∈ V and moves v to S
but Thorup allows visiting a vertex v ∈ S not
/
minimizing D (v )
in order to identify the next vertex to be visited, the
vertices are placed in buckets

Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

Overview

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive

Thorup's algorithm inherits. . .
. . . the denition of G , V , E , n, m, w , d , s , S and D
. . . the initialization of S and D
. . . visiting a vertex v ∈ V , which might decrease D (u )
for some adjacent vertices u ∈ V and moves v to S
but Thorup allows visiting a vertex v ∈ S not
/
minimizing D (v )
in order to identify the next vertex to be visited, the
vertices are placed in buckets
every bucket is associated with a component, a node of
the component tree explained later

Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

The main routine

Algorithm for
Undirected
Single-Source
Shortest Paths

The whole algorithm can be summarized in top-level
pseudo-code as follows:

with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

The main routine

Algorithm for
Undirected
Single-Source
Shortest Paths

The whole algorithm can be summarized in top-level
pseudo-code as follows:
1. Construct an msb-minimum spanning tree M in O (m).

with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

The main routine

Algorithm for
Undirected
Single-Source
Shortest Paths

The whole algorithm can be summarized in top-level
pseudo-code as follows:
1. Construct an msb-minimum spanning tree M in O (m).
2. Construct the component tree T in O (m).

with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

The main routine

Algorithm for
Undirected
Single-Source
Shortest Paths

The whole algorithm can be summarized in top-level
pseudo-code as follows:
1. Construct an msb-minimum spanning tree M in O (m).
2. Construct the component tree T in O (m).
3. Construct the unvisited data structure U in O (n).

with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

The main routine

Algorithm for
Undirected
Single-Source
Shortest Paths

The whole algorithm can be summarized in top-level
pseudo-code as follows:
1. Construct an msb-minimum spanning tree M in O (m).
2. Construct the component tree T in O (m).
3. Construct the unvisited data structure U in O (n).
4. Set S = {s }.
5. Set D (s ) = 0.
6. For all v ∈ V with v = s : Set D (v ) = w (s , v ).

with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

The main routine

Algorithm for
Undirected
Single-Source
Shortest Paths

The whole algorithm can be summarized in top-level
pseudo-code as follows:
1. Construct an msb-minimum spanning tree M in O (m).
2. Construct the component tree T in O (m).
3. Construct the unvisited data structure U in O (n).
4. Set S = {s }.
5. Set D (s ) = 0.
6. For all v ∈ V with v = s : Set D (v ) = w (s , v ).
7. Visit the root of the component tree T .
8. Return D .

with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation
of Thorup's

Introduction

Linear Time
Algorithm for
Undirected
Single-Source

Thorup's algorithm
Overview
msb-Minimum spanning tree M
Component tree T
Bucketing structure B
Unvisited data structure U
Visiting components and vertices
Implementation details
Performance

Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details

Conclusion

Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

Constructing a minimum spanning tree in linear time?

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

construction of a minimum spanning tree is possible in
linear time [FW90]

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

Constructing a minimum spanning tree in linear time?

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

construction of a minimum spanning tree is possible in
linear time [FW90]
this requires a priority queue called atomic heap, which
requires n  212
20

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

Constructing a minimum spanning tree in linear time?

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

construction of a minimum spanning tree is possible in
linear time [FW90]
this requires a priority queue called atomic heap, which
requires n  212
20

nd a dierent way for today's computers

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
The

msb -minimum

spanning tree

of Thorup's

M

Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

let msb(x ) = log2 x denote the position of the most
signicant bit of x ∈ N

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
The

msb -minimum

spanning tree

of Thorup's

M

Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

let msb(x ) = log2 x denote the position of the most
signicant bit of x ∈ N
an msb-minimum spanning tree of a graph G is a
spanning tree that is minimal in G where each weight x
is replaced by msb(x )

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
The

msb -minimum

spanning tree

of Thorup's

M

Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

let msb(x ) = log2 x denote the position of the most
signicant bit of x ∈ N
an msb-minimum spanning tree of a graph G is a
spanning tree that is minimal in G where each weight x
is replaced by msb(x )
use such an msb-minimum spanning tree for
constructing the component tree

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
An example of an input graph

of Thorup's

G

(n

= 11, m = 16)

Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
The input graph

G

after having replaced each weight

of Thorup's

x

by

msb (x )

Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
An

msb -minimum

spanning tree of

of Thorup's

G

Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
How to construct an

msb -minimum

of Thorup's
Linear Time

spanning tree

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction

1. sort all edges according to their msb-weights in linear
time using simple bucketing

Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
How to construct an

msb -minimum

of Thorup's
Linear Time

spanning tree

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction

1. sort all edges according to their msb-weights in linear
time using simple bucketing
2. compute a minimum spanning tree with Kruskal's
algorithm [Kru56], using the pre-sorted edges

Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
How to construct an

msb -minimum

of Thorup's
Linear Time

spanning tree

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction

the clustering is done with Tarjan's union-nd algorithm
[Tar75]

Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
How to construct an

msb -minimum

of Thorup's
Linear Time

spanning tree

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction

the clustering is done with Tarjan's union-nd algorithm
[Tar75]
the use of union with size, and nd with path
compression leads to a time bound of O (α(m, n)m)

Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation
of Thorup's

Introduction

Linear Time
Algorithm for
Undirected
Single-Source

Thorup's algorithm
Overview
msb-Minimum spanning tree M
Component tree T
Bucketing structure B
Unvisited data structure U
Visiting components and vertices
Implementation details
Performance

Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details

Conclusion

Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

The component hierarchy

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

let Gi be the subgraph of G containing all edges e ∈ E
with w (e )  2i

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

The component hierarchy

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

let Gi be the subgraph of G containing all edges e ∈ E
with w (e )  2i
Level i of Thorup's component hierarchy consists of the
components of Gi

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

The component hierarchy

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

let Gi be the subgraph of G containing all edges e ∈ E
with w (e )  2i
Level i of Thorup's component hierarchy consists of the
components of Gi
use the msb-minimum spanning tree here

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

The component hierarchy

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

let Gi be the subgraph of G containing all edges e ∈ E
with w (e )  2i
Level i of Thorup's component hierarchy consists of the
components of Gi
use the msb-minimum spanning tree here
let [v ]i denote the component on level i containing the
vertex v ∈ V

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

The component hierarchy

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

let Gi be the subgraph of G containing all edges e ∈ E
with w (e )  2i
Level i of Thorup's component hierarchy consists of the
components of Gi
use the msb-minimum spanning tree here
let [v ]i denote the component on level i containing the
vertex v ∈ V
the children of a component [v ]i are all components
[w ]i −1 with [w ]i = [v ]i , in other words with w ∈ [v ]i

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

The component hierarchy

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

let Gi be the subgraph of G containing all edges e ∈ E
with w (e )  2i
Level i of Thorup's component hierarchy consists of the
components of Gi
use the msb-minimum spanning tree here
let [v ]i denote the component on level i containing the
vertex v ∈ V
the children of a component [v ]i are all components
[w ]i −1 with [w ]i = [v ]i , in other words with w ∈ [v ]i

[v ]i = [w ]i ⇒ dist (v , w ) ≥ 2i

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm
The subgraph

G4

Implementation
of Thorup's
Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm
The component tree

T

Implementation
of Thorup's
Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

the component tree T skips all nodes [v ]i = [v ]i −1 :

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm
The component tree

T

Implementation
of Thorup's
Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

the component tree T skips all nodes [v ]i = [v ]i −1 :

Every leaf of T is a singleton component [v ]0 = {v },
v ∈ V.

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm
The component tree

T

Implementation
of Thorup's
Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

the component tree T skips all nodes [v ]i = [v ]i −1 :

Every leaf of T is a singleton component [v ]0 = {v },
v ∈ V.
Every internal node of T is a component [v ]i , v ∈ V ,
with i  0 and [v ]i −1 [v ]i .

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm
The component tree

T

Implementation
of Thorup's
Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

the component tree T skips all nodes [v ]i = [v ]i −1 :

Every leaf of T is a singleton component [v ]0 = {v },
v ∈ V.
Every internal node of T is a component [v ]i , v ∈ V ,
with i  0 and [v ]i −1 [v ]i .
The root of T is the node [v ]r = G with r minimized.

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm
The component tree

T

Implementation
of Thorup's
Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

the component tree T skips all nodes [v ]i = [v ]i −1 :

Every leaf of T is a singleton component [v ]0 = {v },
v ∈ V.
Every internal node of T is a component [v ]i , v ∈ V ,
with i  0 and [v ]i −1 [v ]i .
The root of T is the node [v ]r = G with r minimized.

the parent of a node [v ]i is its nearest ancestor in the
component hierarchy with at least two children

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm
The component tree

T

Implementation
of Thorup's
Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

the component tree T skips all nodes [v ]i = [v ]i −1 :

Every leaf of T is a singleton component [v ]0 = {v },
v ∈ V.
Every internal node of T is a component [v ]i , v ∈ V ,
with i  0 and [v ]i −1 [v ]i .
The root of T is the node [v ]r = G with r minimized.

the parent of a node [v ]i is its nearest ancestor in the
component hierarchy with at least two children

T has no nodes with exactly one child ⇒ the total
number of nodes is bounded by 2n ∈ O (n)

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm
The component tree

T

of

G

Implementation
of Thorup's
Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm
The components of

G4

Implementation
of Thorup's
Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm
The subgraph

G4

Implementation
of Thorup's
Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
How to construct the component tree

of Thorup's

T

Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

1. sort the edges of M according to the most signicant
bits of their weights

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
How to construct the component tree

of Thorup's

T

Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

1. sort the edges of M according to the most signicant
bits of their weights
2. process the resulting sequence of edges e1 , . . . , en−1 in
the following way: For i = 1 to n − 1:

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
How to construct the component tree

of Thorup's

T

Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

1. sort the edges of M according to the most signicant
bits of their weights
2. process the resulting sequence of edges e1 , . . . , en−1 in
the following way: For i = 1 to n − 1:
2.1 Let (v , w ) = ei .
2.2 Call union(v , w ).
2.3 If msb(w (ei ))  msb(w (ei +1 )): Insert all new
components of the union-nd structure into T .

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
How to construct the component tree

of Thorup's

T

Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

using Tarjan's union-nd algorithm [Tar75] again, the
running time is O (α(m, n)m)

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
How to construct the component tree

of Thorup's

T

Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

using Tarjan's union-nd algorithm [Tar75] again, the
running time is O (α(m, n)m)
construction T in linear time is also possible:

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
How to construct the component tree

of Thorup's

T

Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

using Tarjan's union-nd algorithm [Tar75] again, the
running time is O (α(m, n)m)
construction T in linear time is also possible:
requires the tabulation-based union-nd algorithm by
Gabow and Tarjan which runs in O (m + n) time [GT85]

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
How to construct the component tree

of Thorup's

T

Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

using Tarjan's union-nd algorithm [Tar75] again, the
running time is O (α(m, n)m)
construction T in linear time is also possible:
requires the tabulation-based union-nd algorithm by
Gabow and Tarjan which runs in O (m + n) time [GT85]
much more complicated than the one by Tarjan
we use the simpler one here

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation
of Thorup's

Introduction

Linear Time
Algorithm for
Undirected
Single-Source

Thorup's algorithm
Overview
msb-Minimum spanning tree M
Component tree T
Bucketing structure B
Unvisited data structure U
Visiting components and vertices
Implementation details
Performance

Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details

Conclusion

Performance
Conclusion
Thorup's algorithm
The bucketing structure

B

Implementation
of Thorup's
Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive

visit the nodes of the component tree T in the right
order

Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm
The bucketing structure

B

Implementation
of Thorup's
Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive

visit the nodes of the component tree T in the right
order
whenever a component [v ]i is visited, so are all its
ancestors in T

Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm
The bucketing structure

B

Implementation
of Thorup's
Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive

visit the nodes of the component tree T in the right
order
whenever a component [v ]i is visited, so are all its
ancestors in T
bucket the children [w ]h of a component [v ]i into
B ([v ]i , min D ([w ]− ) i − 1)
h

Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm
The bucketing structure

B

Implementation
of Thorup's
Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive

visit the nodes of the component tree T in the right
order
whenever a component [v ]i is visited, so are all its
ancestors in T
bucket the children [w ]h of a component [v ]i into
B ([v ]i , min D ([w ]− ) i − 1)
h
maintain two additional properties for every component:
ix ([v ]i ) ≤ the smallest index of a nonempty bucket of
[v ]i
∆([v ]i ) = number buckets of [v ]i

Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm
The bucketing structure

B

Implementation
of Thorup's
Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive

visit the nodes of the component tree T in the right
order
whenever a component [v ]i is visited, so are all its
ancestors in T
bucket the children [w ]h of a component [v ]i into
B ([v ]i , min D ([w ]− ) i − 1)
h
maintain two additional properties for every component:
ix ([v ]i ) ≤ the smallest index of a nonempty bucket of
[v ]i
∆([v ]i ) = number buckets of [v ]i

the total number of buckets is bounded by 8n

Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation
of Thorup's

Introduction

Linear Time
Algorithm for
Undirected
Single-Source

Thorup's algorithm
Overview
msb-Minimum spanning tree M
Component tree T
Bucketing structure B
Unvisited data structure U
Visiting components and vertices
Implementation details
Performance

Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details

Conclusion

Performance
Conclusion
Implementation

Thorup's algorithm
The unvisited data structure

of Thorup's

U

Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

The unvisited data structure U . . .

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
The unvisited data structure

of Thorup's

U

Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

The unvisited data structure U . . .
. . . represents the unvisited subforest of the component
tree T

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
The unvisited data structure

of Thorup's

U

Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

The unvisited data structure U . . .
. . . represents the unvisited subforest of the component
tree T
. . . is required for maintaining the changing values
min D ([v ]− ) for the changing set of roots [v ]i in the
i
unvisited part of T in linear total time

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
The unvisited data structure

of Thorup's

U

Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

The unvisited data structure U . . .
. . . represents the unvisited subforest of the component
tree T
. . . is required for maintaining the changing values
min D ([v ]− ) for the changing set of roots [v ]i in the
i
unvisited part of T in linear total time

[v ]i is a root of a tree in U if and only if [v ]i is an
unvisited child of a visited component in T

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
The unvisited data structure

of Thorup's

U

Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

The unvisited data structure U . . .
. . . represents the unvisited subforest of the component
tree T
. . . is required for maintaining the changing values
min D ([v ]− ) for the changing set of roots [v ]i in the
i
unvisited part of T in linear total time

[v ]i is a root of a tree in U if and only if [v ]i is an
unvisited child of a visited component in T
[v ]i = [v ]i for each of these roots, because they are
unvisited
−

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

The problem: Operations of the unvisited data structure

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

two operations in amortized constant time:
1. Update min D ([v ]i ) whenever D (v ) is decreased for
some vertex v ∈ V with unvisited root [v ]i .
2. Turn all children [w ]h of [v ]i in T into roots in U and
compute min D ([w ]− ) for all of them whenever an
h
unvisited root [v ]i is visited.

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

The problem: Operations of the unvisited data structure

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

two operations in amortized constant time:
1. Update min D ([v ]i ) whenever D (v ) is decreased for
some vertex v ∈ V with unvisited root [v ]i .
2. Turn all children [w ]h of [v ]i in T into roots in U and
compute min D ([w ]− ) for all of them whenever an
h
unvisited root [v ]i is visited.
transform this problem into another one that can be
solved by the split-ndmin structure by Gabow [Gab85]

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
The initial unvisited data structure

of Thorup's

U

of

G

Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion

[1, 2, 3, 10, 8, 9, 4, 5, 7, 11, 6]
Implementation

Thorup's algorithm
The unvisited data structure

of Thorup's

U

after having called

visit([1]11 )

Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion

[1, 2, 3, 10, 8, 9, 4, 5, 7, 11] [6]
Implementation

Thorup's algorithm
The unvisited data structure

of Thorup's

U

after having called

visit([1]9 )

Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion

[1, 2, 3, 10, 8, 9, 4, 5, 7] [11] [6]
Implementation

Thorup's algorithm
The unvisited data structure

of Thorup's

U

after having called

visit([1]7 )

Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion

[1, 2, 3, 10, 8, 9] [4, 5, 7] [11] [6]
Thorup's algorithm

Implementation
of Thorup's
Linear Time

Total running time of the operations of the unvisited data structure

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

for k ∈ N, k  2, each split in k can be implemented by
k − 1 splits in two

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

Total running time of the operations of the unvisited data structure

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

for k ∈ N, k  2, each split in k can be implemented by
k − 1 splits in two
at most n − 1 splits in two, because |V | = n

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

Total running time of the operations of the unvisited data structure

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

for k ∈ N, k  2, each split in k can be implemented by
k − 1 splits in two
at most n − 1 splits in two, because |V | = n
at most m decreases, one for each edge in G

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

Total running time of the operations of the unvisited data structure

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

for k ∈ N, k  2, each split in k can be implemented by
k − 1 splits in two
at most n − 1 splits in two, because |V | = n
at most m decreases, one for each edge in G
Gabow's split-ndmin data structure supports exactly
these two operations

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

Total running time of the operations of the unvisited data structure

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

for k ∈ N, k  2, each split in k can be implemented by
k − 1 splits in two
at most n − 1 splits in two, because |V | = n
at most m decreases, one for each edge in G
Gabow's split-ndmin data structure supports exactly
these two operations
the total runinng time for n − 1 splits and m decreases is
O (α(m, n)m)

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

Operations of the unvisited data structure in linear total time?

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Thorup presented an O (m + n) solution [Tho99]), which
is based on the atomic heaps by Fredman and Willard

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

Operations of the unvisited data structure in linear total time?

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Thorup presented an O (m + n) solution [Tho99]), which
is based on the atomic heaps by Fredman and Willard
as mentioned above, these priority queues require
n  212
20

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

Operations of the unvisited data structure in linear total time?

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Thorup presented an O (m + n) solution [Tho99]), which
is based on the atomic heaps by Fredman and Willard

Introduction
Thorup's
algorithm

as mentioned above, these priority queues require
n  212

Overview

fall back to the solution by Gabow and to a total
running time of O (α(m, n)m)

Bucketing
structure B

20

msb-Minimum

spanning tree M
Component tree

T

Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation
of Thorup's

Introduction

Linear Time
Algorithm for
Undirected
Single-Source

Thorup's algorithm
Overview
msb-Minimum spanning tree M
Component tree T
Bucketing structure B
Unvisited data structure U
Visiting components and vertices
Implementation details
Performance

Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details

Conclusion

Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

The main routine revisited

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive

1. Construct an msb-minimum spanning tree M in O (m).

Integer Weights
Nick Prühs

(done)

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

The main routine revisited

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive

1. Construct an msb-minimum spanning tree M in O (m).

Integer Weights
Nick Prühs

(done)

2. Construct the component tree T in O (m). (done)

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

The main routine revisited

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive

1. Construct an msb-minimum spanning tree M in O (m).

Integer Weights
Nick Prühs

(done)

2. Construct the component tree T in O (m). (done)
3. Construct the unvisited data structure U in O (n).

(done)

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

The main routine revisited

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive

1. Construct an msb-minimum spanning tree M in O (m).

Integer Weights
Nick Prühs

(done)

2. Construct the component tree T in O (m). (done)
3. Construct the unvisited data structure U in O (n).

(done)
4. Set S = {s }. (done)
5. Set D (s ) = 0. (done)
6. For all v ∈ V with v = s : Set D (v ) = w (s , v ). (done)

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm

Implementation
of Thorup's
Linear Time

The main routine revisited

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive

1. Construct an msb-minimum spanning tree M in O (m).

Integer Weights
Nick Prühs

(done)

2. Construct the component tree T in O (m). (done)
3. Construct the unvisited data structure U in O (n).

(done)
4. Set S = {s }. (done)
5. Set D (s ) = 0. (done)
6. For all v ∈ V with v = s : Set D (v ) = w (s , v ). (done)

7. Visit the root of the component tree T .
8. Return D .

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm
Visit(

[v ]i ):

Implementation
of Thorup's
Linear Time

Step 1

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction

If [v ]i is the root of T ,
1. then: Set j = ω + 1.
2. else: Let [v ]j be the parent of [v ]i in T .

Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
Visit(

[v ]i ):

of Thorup's
Linear Time

Step 2

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive

If i = 0:

Integer Weights
Nick Prühs

1. Add v to S .
2. For all edges (u , v ) ∈ E :
2.1 If D (v ) + w (u , v )  D (w ):
2.1.1
2.1.2
2.1.3
2.1.4
2.1.5

[u ]h be the unvisited root of [u ]0 in U .
Let [u ]i be the visited parent of [u ]h in T .
−
Set oldMin = min D ([u ] )
i − 1.
h
Decrease D (u ) to D (v ) + w (u , v ).
−
i − 1  oldMin: Move [u ]h
If min D ([u ] )
h
B ([u ]i , min D ([u ]h )
i − 1).

Introduction
Thorup's
algorithm

Overview

Let

3. Remove [v ]i from its bucket of [v ]j .
4. Return.

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B

to bucket

Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Thorup's algorithm
Visit(

[v ]i ):

Implementation
of Thorup's
Linear Time

Step 3

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

If [v ]i is visited for the rst time:
1. Construct the ∆([v ]i ) buckets of [v ]i .
2. Delete [v ]i from U , turning its children into roots in U .
3. For all children [w ]h of [v ]i :
3.1 Bucket [w ]h in B ([v ]i , min D ([w ]− ) i − 1).
h

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
Visit(

[v ]i ):

of Thorup's
Linear Time

Steps 4-6

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

Set oldIndex = ix ([v ]i )

j − i.

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
Visit(

[v ]i ):

of Thorup's
Linear Time

Steps 4-6

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

Set oldIndex = ix ([v ]i )
j − i.
−
While [v ]i = ∅ and oldIndex = ix ([v ]i )
1. While B ([v ]i , ix ([v ]i )) = ∅:
1.1
1.2

[w ]h ∈ B ([v ]i , ix ([v ]i )).
Call visit ([w ]h ).

Let

2. Increment

ix ([v ]i ).

Nick Prühs

j − i:

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Thorup's algorithm
Visit(

[v ]i ):

of Thorup's
Linear Time

Steps 4-6

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

Set oldIndex = ix ([v ]i )
j − i.
−
While [v ]i = ∅ and oldIndex = ix ([v ]i )
1. While B ([v ]i , ix ([v ]i )) = ∅:
1.1
1.2

[w ]h ∈ B ([v ]i , ix ([v ]i )).
Call visit ([w ]h ).

Nick Prühs

j − i:

Let

2. Increment ix ([v ]i ).
If [v ]− = ∅,
i
1. then: If [v ]i is not the root of T , remove it from its
bucket of [v ]j .
2. else: Move [v ]i to bucket B ([v ]j , ix ([v ]i ) j − i ).

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation
of Thorup's

Introduction

Linear Time
Algorithm for
Undirected
Single-Source

Thorup's algorithm
Overview
msb-Minimum spanning tree M
Component tree T
Bucketing structure B
Unvisited data structure U
Visiting components and vertices
Implementation details
Performance

Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details

Conclusion

Performance
Conclusion
Implementation details

Implementation
of Thorup's
Linear Time

The strategy pattern

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Java implementation:
imperative programming language
ts the required RAM model
object-oriented
word length ω = 32, number of vertices n ≤ 232
allows the extensive use of the strategy pattern

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation details

Implementation
of Thorup's
Linear Time

Implemented data structures

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

an undirected, weighted graph using adjacency lists
an array priority queue

Introduction
Thorup's
algorithm

Overview

a Fibonacci heap [FT84]

msb-Minimum

a split-ndmin structure [GT85]

T

a union-nd structure [Tar75]

spanning tree M
Component tree
Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation details

Implementation
of Thorup's
Linear Time

Implemented algorithms

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction

Kruskal [Kru56]
Dijkstra [Dij59]
Thorup [Tho99]

Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation
of Thorup's

Introduction

Linear Time
Algorithm for
Undirected
Single-Source

Thorup's algorithm
Overview
msb-Minimum spanning tree M
Component tree T
Bucketing structure B
Unvisited data structure U
Visiting components and vertices
Implementation details
Performance

Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details

Conclusion

Performance
Conclusion
Performance

Implementation
of Thorup's
Linear Time

The performance tests

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction

average of ve passes

Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Performance

Implementation
of Thorup's
Linear Time

The performance tests

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction

average of ve passes
the test system:
Intel Core 2 Duo E6300 at 1,86 GHz
2048 MB DDR2 667 PC2-5300 RAM
Java 1.6.0_15

Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Performance

Implementation
of Thorup's
Linear Time

Varying the number of vertices

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction

start with n = 1000 and increase it in steps of 1000 until
n = 10000
about m = 5n edges
edge weights 1 ≤ w ≤ 100000

Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Performance

Implementation
of Thorup's
Linear Time

Varying the number of vertices: Results

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details

Figure: Running times for 1000 ≤ n ≤ 10000, m = 5n.

Performance
Conclusion
Performance

Implementation
of Thorup's
Linear Time

Varying the number of vertices

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

start with n = 4000 and increase it in steps of 4000 until
n = 40000
about m = 5n edges again
edge weights 1 ≤ w ≤ 100000 again

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Performance

Implementation
of Thorup's
Linear Time

Varying the number of vertices

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

start with n = 4000 and increase it in steps of 4000 until
n = 40000
about m = 5n edges again
edge weights 1 ≤ w ≤ 100000 again
leave out the naive implementation of Dijkstra's
algorithm and focus on the faster one

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Performance

Implementation
of Thorup's
Linear Time

Varying the number of vertices

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

start with n = 4000 and increase it in steps of 4000 until
n = 40000
about m = 5n edges again
edge weights 1 ≤ w ≤ 100000 again
leave out the naive implementation of Dijkstra's
algorithm and focus on the faster one
nd out which n is required for Thorup to catch up with
Dijkstra

Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Performance

Implementation
of Thorup's
Linear Time

Varying the number of vertices: Results

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance

Figure: Running times for 4000 ≤ n ≤ 40000, m = 5n.

Conclusion
Performance

Implementation
of Thorup's
Linear Time

Varying the number of edges per vertex

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction

x the number of vertices n = 20000
start with m = 3n edges and increase it in steps of 3n
until m = 24n
edge weights 1 ≤ w ≤ 100000 again

Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Implementation

Performance

of Thorup's
Linear Time

Varying the number of edges per vertex: Results

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance

Figure: Running times for

n = 20000, 3n ≤ m ≤ 24n.

Conclusion
Performance

Implementation
of Thorup's
Linear Time

Varying the maximum edge weight

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

x the number of vertices n = 20000
x the number of edges m = 5n
start by choosing all edge weights 1 ≤ w ≤ 5 and
increase the maximum edge weight in steps of 5 until
1 ≤ w ≤ 100

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Performance

Implementation
of Thorup's
Linear Time

Varying the maximum edge weight: Results

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation

Figure: Running times for n = 20000, m = 5n, and maximum edge
weights between 5 and 100.

details
Performance
Conclusion
Implementation

Performance

of Thorup's
Linear Time

Varying the maximum edge weight: Results

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights

maximum edge weight

256

1024

16384

Dijkstra (Fibonacci heap)

212

209

212

219

Thorup (MST)
Thorup (other DS)
Thorup (visit)

148
153
461

153
171
423

145
156
430

168
140
403

Nick Prühs

262144

Table: Running times for n = 20000, m = 5n and maximum edge
weights 28 , 210 , 214 and 218 .

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Performance

Implementation
of Thorup's
Linear Time

Repetitive queries

Algorithm for
Undirected
Single-Source
Shortest Paths

nd out whether Thorup's algorithm can catch up with
the one by Dijkstra making repetive queries

with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Performance

Implementation
of Thorup's
Linear Time

Repetitive queries

Algorithm for
Undirected
Single-Source
Shortest Paths

nd out whether Thorup's algorithm can catch up with
the one by Dijkstra making repetive queries
at the rst query, all required data structures are
computed once
this is the initial lead Dijkstra's algorithm has over the
one by Thorup

with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Performance

Implementation
of Thorup's
Linear Time

Repetitive queries

Algorithm for
Undirected
Single-Source
Shortest Paths

nd out whether Thorup's algorithm can catch up with
the one by Dijkstra making repetive queries
at the rst query, all required data structures are
computed once
this is the initial lead Dijkstra's algorithm has over the
one by Thorup
clean up between two queries:
1. Reset the set S of visited vertices.
2. Clear all buckets.
3. Reset the unvisited data structure U , making it contain
only the root of T .

with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Performance

Implementation
of Thorup's
Linear Time

Repetitive queries

Algorithm for
Undirected
Single-Source
Shortest Paths

nd out whether Thorup's algorithm can catch up with
the one by Dijkstra making repetive queries
at the rst query, all required data structures are
computed once
this is the initial lead Dijkstra's algorithm has over the
one by Thorup
clean up between two queries:
1. Reset the set S of visited vertices.
2. Clear all buckets.
3. Reset the unvisited data structure U , making it contain
only the root of T .
still takes signicantly less time than before the rst
query

with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Performance

Implementation
of Thorup's
Linear Time

Repetitive queries

Algorithm for
Undirected
Single-Source

test instance: the road network of New York City
number of vertices n = 264, 346
number of edges m = 733, 846 (about m = 3n)

Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Performance

Implementation
of Thorup's
Linear Time

Repetitive queries

Algorithm for
Undirected
Single-Source

test instance: the road network of New York City
number of vertices n = 264, 346
number of edges m = 733, 846 (about m = 3n)
source: 9th DIMACS Implementation Challenge Shortest Paths [Dem06]

Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Performance

Implementation
of Thorup's
Linear Time

Repetitive queries

Algorithm for
Undirected
Single-Source

test instance: the road network of New York City
number of vertices n = 264, 346
number of edges m = 733, 846 (about m = 3n)
source: 9th DIMACS Implementation Challenge Shortest Paths [Dem06]

Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

nd the shortest paths from the vertices with indices 0
to 9 to all other ones

Overview

accumulate the resulting running times

Bucketing
structure B

msb-Minimum

spanning tree M
Component tree

T

Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Performance

Implementation
of Thorup's
Linear Time

Repetitive queries

Algorithm for
Undirected
Single-Source

test instance: the road network of New York City
number of vertices n = 264, 346
number of edges m = 733, 846 (about m = 3n)
source: 9th DIMACS Implementation Challenge Shortest Paths [Dem06]

Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

nd the shortest paths from the vertices with indices 0
to 9 to all other ones

Overview

accumulate the resulting running times

Bucketing
structure B

the initialization of Thorup's algorithm takes about 2100
ms and is added to the rst accumulated time
the time required for cleaning up all data structures is
always about 200 ms and is added to the accumulated
time of the query the clean-up has been done before

msb-Minimum

spanning tree M
Component tree

T

Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Performance

Implementation
of Thorup's
Linear Time

Repetitive queries: Results

Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details

Figure: Accumulated running times for ten queries on the road
network of New York City.

Performance
Conclusion
Implementation
of Thorup's

Introduction

Linear Time
Algorithm for
Undirected
Single-Source

Thorup's algorithm
Overview
msb-Minimum spanning tree M
Component tree T
Bucketing structure B
Unvisited data structure U
Visiting components and vertices
Implementation details
Performance

Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details

Conclusion

Performance
Conclusion
Conclusion

Implementation
of Thorup's
Linear Time
Algorithm for
Undirected
Single-Source

Thorup's algorithm does not require comparison-based
sorting and is today's theoretically fastest SSSP
algorithm, . . .

Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Conclusion

Implementation
of Thorup's
Linear Time
Algorithm for
Undirected
Single-Source

Thorup's algorithm does not require comparison-based
sorting and is today's theoretically fastest SSSP
algorithm, . . .
. . . but our implementation of the algorithm is still
signicantly slower than our implementation of
Dijkstra's algorithm using a Fibonacci heap

Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Conclusion

Implementation
of Thorup's
Linear Time
Algorithm for
Undirected
Single-Source

Thorup's algorithm does not require comparison-based
sorting and is today's theoretically fastest SSSP
algorithm, . . .
. . . but our implementation of the algorithm is still
signicantly slower than our implementation of
Dijkstra's algorithm using a Fibonacci heap
possbile reasons are:
an inecient implementation
a word length which is still too small for realizing the
full potential of Thorup's algorithm

Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Conclusion

Implementation
of Thorup's
Linear Time
Algorithm for
Undirected
Single-Source

Thorup's algorithm does not require comparison-based
sorting and is today's theoretically fastest SSSP
algorithm, . . .
. . . but our implementation of the algorithm is still
signicantly slower than our implementation of
Dijkstra's algorithm using a Fibonacci heap
possbile reasons are:
an inecient implementation
a word length which is still too small for realizing the
full potential of Thorup's algorithm
these observations essentially equal the conclusion made
by Yasuhito Asano and Hiroshi Imai [AI00]

Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Conclusion

Implementation
of Thorup's
Linear Time

Future work

Algorithm for
Undirected
Single-Source
Shortest Paths

implement the strictly linear time parts of Thorup's
algorithm:
the linear time algorithm for constructing minimum
spanning trees [FW90]
the linear time union-nd [GT85] structure
the linear time split-ndmin structure [Tho99]

with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Conclusion

Implementation
of Thorup's
Linear Time

Future work

Algorithm for
Undirected
Single-Source
Shortest Paths

implement the strictly linear time parts of Thorup's
algorithm:
the linear time algorithm for constructing minimum
spanning trees [FW90]
the linear time union-nd [GT85] structure
the linear time split-ndmin structure [Tho99]
see how well Thorup's algorithm does compared to fast
all shortest paths algorithms

with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Conclusion

Implementation
of Thorup's
Linear Time

Future work

Algorithm for
Undirected
Single-Source
Shortest Paths

implement the strictly linear time parts of Thorup's
algorithm:
the linear time algorithm for constructing minimum
spanning trees [FW90]
the linear time union-nd [GT85] structure
the linear time split-ndmin structure [Tho99]
see how well Thorup's algorithm does compared to fast
all shortest paths algorithms
see if his component tree can be useful for other
applications

with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Conclusion

Implementation
of Thorup's
Linear Time

Future work

Algorithm for
Undirected
Single-Source
Shortest Paths

implement the strictly linear time parts of Thorup's
algorithm:
the linear time algorithm for constructing minimum
spanning trees [FW90]
the linear time union-nd [GT85] structure
the linear time split-ndmin structure [Tho99]
see how well Thorup's algorithm does compared to fast
all shortest paths algorithms
see if his component tree can be useful for other
applications
run the algorithm on signicantly larger graphs and
check whether it is as attractive for repetitive queries as
expected, as soon as we are able to

with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Conclusion

Implementation
of Thorup's
Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Thank you for your attention!

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Yasuhito Asano and Hiroshi Imai.
Practical eciency of the linear-time algorithm for the
single source shortest path problem.
Journal of the Operations Research, 43:431447, 2000.
Camil Demetrescu.
9th dimacs implementation challenge - shortest paths.
http://www.dis.uniroma1.it/~challenge9/
download.shtml, 2006.
Edsger W. Dijkstra.
A note on two problems in connection with graphs.
Numer. Math., 1:269271, 1959.
Michael L. Fredman and Robert Endre Tarjan.
Fibonacci heaps and their uses in improved network
optimization algorithms.
In FOCS, pages 338346. IEEE, 1984.
Michael L. Fredman and Dan E. Willard.

Implementation
of Thorup's
Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Trans-dichotomous algorithms for minimum spanning
trees and shortest paths.
In FOCS, volume II, pages 719725. IEEE, 1990.
Harold N. Gabow.
A scaling algorithm for weighted matching on general
graphs.
In FOCS, pages 90100. IEEE, 1985.
Harold N. Gabow and Robert Endre Tarjan.
A linear-time algorithm for a special case of disjoint set
union.
J. Comput. Syst. Sci., 30(2):209221, 1985.
Joseph B. Kruskal.
On the shortest spanning subtree of a graph and the
traveling salesman problem.
Proc. Am. Math. Soc, 7:4850, 1956.
Robert Endre Tarjan.
Eciency of a good but not linear set union algorithm.
J. ACM, 22(2):215225, 1975.

Implementation
of Thorup's
Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion
Mikkel Thorup.
Undirected single-source shortest paths with positive
integer weights in linear time.
J. ACM, 46(3):362394, 1999.

Implementation
of Thorup's
Linear Time
Algorithm for
Undirected
Single-Source
Shortest Paths
with Positive
Integer Weights
Nick Prühs

Introduction
Thorup's
algorithm

Overview

msb-Minimum

spanning tree M
Component tree

T

Bucketing
structure B
Unvisited data
structure U
Visiting
components and
vertices
Implementation
details
Performance
Conclusion

Contenu connexe

Tendances

PFI Seminar 2012/03/15 カーネルとハッシュの機械学習
PFI Seminar 2012/03/15 カーネルとハッシュの機械学習PFI Seminar 2012/03/15 カーネルとハッシュの機械学習
PFI Seminar 2012/03/15 カーネルとハッシュの機械学習
Preferred Networks
 
Prml4.4 ラプラス近似~ベイズロジスティック回帰
Prml4.4 ラプラス近似~ベイズロジスティック回帰Prml4.4 ラプラス近似~ベイズロジスティック回帰
Prml4.4 ラプラス近似~ベイズロジスティック回帰
Yuki Matsubara
 
初めてのグラフカット
初めてのグラフカット初めてのグラフカット
初めてのグラフカット
Tsubasa Hirakawa
 

Tendances (20)

SAT/SMTソルバの仕組み
SAT/SMTソルバの仕組みSAT/SMTソルバの仕組み
SAT/SMTソルバの仕組み
 
PFI Seminar 2012/03/15 カーネルとハッシュの機械学習
PFI Seminar 2012/03/15 カーネルとハッシュの機械学習PFI Seminar 2012/03/15 カーネルとハッシュの機械学習
PFI Seminar 2012/03/15 カーネルとハッシュの機械学習
 
正則化項について
正則化項について正則化項について
正則化項について
 
定理証明支援系Coqについて
定理証明支援系Coqについて定理証明支援系Coqについて
定理証明支援系Coqについて
 
GPThreats-3: Is Automated Malware Generation a Threat?
GPThreats-3: Is Automated Malware Generation a Threat?GPThreats-3: Is Automated Malware Generation a Threat?
GPThreats-3: Is Automated Malware Generation a Threat?
 
自動定理証明の紹介
自動定理証明の紹介自動定理証明の紹介
自動定理証明の紹介
 
Prml4.4 ラプラス近似~ベイズロジスティック回帰
Prml4.4 ラプラス近似~ベイズロジスティック回帰Prml4.4 ラプラス近似~ベイズロジスティック回帰
Prml4.4 ラプラス近似~ベイズロジスティック回帰
 
제 17회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [6시내고양포CAT몬] : Cat Anti-aging Project based Style...
제 17회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [6시내고양포CAT몬] : Cat Anti-aging Project based Style...제 17회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [6시내고양포CAT몬] : Cat Anti-aging Project based Style...
제 17회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [6시내고양포CAT몬] : Cat Anti-aging Project based Style...
 
Purely Functional Data Structures in Scala
Purely Functional Data Structures in ScalaPurely Functional Data Structures in Scala
Purely Functional Data Structures in Scala
 
[2021CAPE公開セミナー] 論理学上級 Ⅱ-3「証明論的意味論としてのマーティン・レーフの構成的型理論」
[2021CAPE公開セミナー] 論理学上級 Ⅱ-3「証明論的意味論としてのマーティン・レーフの構成的型理論」[2021CAPE公開セミナー] 論理学上級 Ⅱ-3「証明論的意味論としてのマーティン・レーフの構成的型理論」
[2021CAPE公開セミナー] 論理学上級 Ⅱ-3「証明論的意味論としてのマーティン・レーフの構成的型理論」
 
[PRML] パターン認識と機械学習(第3章:線形回帰モデル)
[PRML] パターン認識と機械学習(第3章:線形回帰モデル)[PRML] パターン認識と機械学習(第3章:線形回帰モデル)
[PRML] パターン認識と機械学習(第3章:線形回帰モデル)
 
初めてのグラフカット
初めてのグラフカット初めてのグラフカット
初めてのグラフカット
 
フラッター開発におけるシークレット情報取扱考察
フラッター開発におけるシークレット情報取扱考察フラッター開発におけるシークレット情報取扱考察
フラッター開発におけるシークレット情報取扱考察
 
ホモトピー型理論入門
ホモトピー型理論入門ホモトピー型理論入門
ホモトピー型理論入門
 
組合せ最適化問題と解法アルゴリズム
組合せ最適化問題と解法アルゴリズム組合せ最適化問題と解法アルゴリズム
組合せ最適化問題と解法アルゴリズム
 
Watch connectivity
Watch connectivityWatch connectivity
Watch connectivity
 
Randomized smoothing
Randomized smoothingRandomized smoothing
Randomized smoothing
 
画像認識における特徴表現 -SSII技術マップの再考-
画像認識における特徴表現 -SSII技術マップの再考-画像認識における特徴表現 -SSII技術マップの再考-
画像認識における特徴表現 -SSII技術マップの再考-
 
SSII2018TS: 3D物体検出とロボットビジョンへの応用
SSII2018TS: 3D物体検出とロボットビジョンへの応用SSII2018TS: 3D物体検出とロボットビジョンへの応用
SSII2018TS: 3D物体検出とロボットビジョンへの応用
 
CVPR2019 読み会「Understanding the Limitations of CNN-based Absolute Camera Pose ...
CVPR2019 読み会「Understanding the Limitations of CNN-based Absolute Camera Pose ...CVPR2019 読み会「Understanding the Limitations of CNN-based Absolute Camera Pose ...
CVPR2019 読み会「Understanding the Limitations of CNN-based Absolute Camera Pose ...
 

Similaire à Implementation of Thorup's Linear Time Algorithm for Undirected Single Source Shortest Paths With Positive Integer Weights

Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10
Traian Rebedea
 
Social network-analysis-in-python
Social network-analysis-in-pythonSocial network-analysis-in-python
Social network-analysis-in-python
Joe OntheRocks
 
lecture 21
lecture 21lecture 21
lecture 21
sajinsc
 

Similaire à Implementation of Thorup's Linear Time Algorithm for Undirected Single Source Shortest Paths With Positive Integer Weights (20)

04 greedyalgorithmsii 2x2
04 greedyalgorithmsii 2x204 greedyalgorithmsii 2x2
04 greedyalgorithmsii 2x2
 
Incremental and Multi-feature Tensor Subspace Learning applied for Background...
Incremental and Multi-feature Tensor Subspace Learning applied for Background...Incremental and Multi-feature Tensor Subspace Learning applied for Background...
Incremental and Multi-feature Tensor Subspace Learning applied for Background...
 
Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10
 
Dijkstra.ppt
Dijkstra.pptDijkstra.ppt
Dijkstra.ppt
 
Social network-analysis-in-python
Social network-analysis-in-pythonSocial network-analysis-in-python
Social network-analysis-in-python
 
Dijksatra
DijksatraDijksatra
Dijksatra
 
Lecture_10_Parallel_Algorithms_Part_II.ppt
Lecture_10_Parallel_Algorithms_Part_II.pptLecture_10_Parallel_Algorithms_Part_II.ppt
Lecture_10_Parallel_Algorithms_Part_II.ppt
 
Graps 2
Graps 2Graps 2
Graps 2
 
Optimisation random graph presentation
Optimisation random graph presentationOptimisation random graph presentation
Optimisation random graph presentation
 
distance_matrix_ch
distance_matrix_chdistance_matrix_ch
distance_matrix_ch
 
(148065320) dijistra algo
(148065320) dijistra algo(148065320) dijistra algo
(148065320) dijistra algo
 
Chapter 24 aoa
Chapter 24 aoaChapter 24 aoa
Chapter 24 aoa
 
lecture 21
lecture 21lecture 21
lecture 21
 
Shortest Path Problem.docx
Shortest Path Problem.docxShortest Path Problem.docx
Shortest Path Problem.docx
 
Goldberg etal 2006
Goldberg etal 2006Goldberg etal 2006
Goldberg etal 2006
 
Goldbergetal2006 211024102451
Goldbergetal2006 211024102451Goldbergetal2006 211024102451
Goldbergetal2006 211024102451
 
bellman-ford Theorem.ppt
bellman-ford Theorem.pptbellman-ford Theorem.ppt
bellman-ford Theorem.ppt
 
Combinatorial Optimization
Combinatorial OptimizationCombinatorial Optimization
Combinatorial Optimization
 
Sequential and parallel algorithm to find maximum flow on extended mixed netw...
Sequential and parallel algorithm to find maximum flow on extended mixed netw...Sequential and parallel algorithm to find maximum flow on extended mixed netw...
Sequential and parallel algorithm to find maximum flow on extended mixed netw...
 
SEQUENTIAL AND PARALLEL ALGORITHM TO FIND MAXIMUM FLOW ON EXTENDED MIXED NETW...
SEQUENTIAL AND PARALLEL ALGORITHM TO FIND MAXIMUM FLOW ON EXTENDED MIXED NETW...SEQUENTIAL AND PARALLEL ALGORITHM TO FIND MAXIMUM FLOW ON EXTENDED MIXED NETW...
SEQUENTIAL AND PARALLEL ALGORITHM TO FIND MAXIMUM FLOW ON EXTENDED MIXED NETW...
 

Plus de Nick Pruehs

Plus de Nick Pruehs (20)

Unreal Engine Basics 06 - Animation, Audio, Visual Effects
Unreal Engine Basics 06 - Animation, Audio, Visual EffectsUnreal Engine Basics 06 - Animation, Audio, Visual Effects
Unreal Engine Basics 06 - Animation, Audio, Visual Effects
 
Unreal Engine Basics 05 - User Interface
Unreal Engine Basics 05 - User InterfaceUnreal Engine Basics 05 - User Interface
Unreal Engine Basics 05 - User Interface
 
Unreal Engine Basics 04 - Behavior Trees
Unreal Engine Basics 04 - Behavior TreesUnreal Engine Basics 04 - Behavior Trees
Unreal Engine Basics 04 - Behavior Trees
 
Unreal Engine Basics 03 - Gameplay
Unreal Engine Basics 03 - GameplayUnreal Engine Basics 03 - Gameplay
Unreal Engine Basics 03 - Gameplay
 
Unreal Engine Basics 02 - Unreal Editor
Unreal Engine Basics 02 - Unreal EditorUnreal Engine Basics 02 - Unreal Editor
Unreal Engine Basics 02 - Unreal Editor
 
Unreal Engine Basics 01 - Game Framework
Unreal Engine Basics 01 - Game FrameworkUnreal Engine Basics 01 - Game Framework
Unreal Engine Basics 01 - Game Framework
 
Game Programming - Cloud Development
Game Programming - Cloud DevelopmentGame Programming - Cloud Development
Game Programming - Cloud Development
 
Game Programming - Git
Game Programming - GitGame Programming - Git
Game Programming - Git
 
Eight Rules for Making Your First Great Game
Eight Rules for Making Your First Great GameEight Rules for Making Your First Great Game
Eight Rules for Making Your First Great Game
 
Designing an actor model game architecture with Pony
Designing an actor model game architecture with PonyDesigning an actor model game architecture with Pony
Designing an actor model game architecture with Pony
 
Game Programming 13 - Debugging & Performance Optimization
Game Programming 13 - Debugging & Performance OptimizationGame Programming 13 - Debugging & Performance Optimization
Game Programming 13 - Debugging & Performance Optimization
 
Scrum - but... Agile Game Development in Small Teams
Scrum - but... Agile Game Development in Small TeamsScrum - but... Agile Game Development in Small Teams
Scrum - but... Agile Game Development in Small Teams
 
Component-Based Entity Systems (Demo)
Component-Based Entity Systems (Demo)Component-Based Entity Systems (Demo)
Component-Based Entity Systems (Demo)
 
What Would Blizzard Do
What Would Blizzard DoWhat Would Blizzard Do
What Would Blizzard Do
 
School For Games 2015 - Unity Engine Basics
School For Games 2015 - Unity Engine BasicsSchool For Games 2015 - Unity Engine Basics
School For Games 2015 - Unity Engine Basics
 
Tool Development A - Git
Tool Development A - GitTool Development A - Git
Tool Development A - Git
 
Game Programming 12 - Shaders
Game Programming 12 - ShadersGame Programming 12 - Shaders
Game Programming 12 - Shaders
 
Game Programming 11 - Game Physics
Game Programming 11 - Game PhysicsGame Programming 11 - Game Physics
Game Programming 11 - Game Physics
 
Game Programming 10 - Localization
Game Programming 10 - LocalizationGame Programming 10 - Localization
Game Programming 10 - Localization
 
Game Programming 09 - AI
Game Programming 09 - AIGame Programming 09 - AI
Game Programming 09 - AI
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Implementation of Thorup's Linear Time Algorithm for Undirected Single Source Shortest Paths With Positive Integer Weights

  • 1. Implementation of Thorup's Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Implementation of Thorup's Linear Time Integer Weights Nick Prühs Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Introduction Thorup's algorithm Overview Nick Prühs msb-Minimum spanning tree M Component tree T Bucketing structure B Department of Computer Science, CAU Kiel September 30, 2009 Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 2. Implementation of Thorup's Linear Time Algorithm for Undirected Introduction Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 3. Implementation of Thorup's Linear Time Algorithm for Undirected Introduction Single-Source Shortest Paths with Positive Integer Weights Thorup's algorithm Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 4. Implementation of Thorup's Linear Time Algorithm for Undirected Introduction Single-Source Shortest Paths with Positive Integer Weights Thorup's algorithm Nick Prühs Introduction Implementation details Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 5. Implementation of Thorup's Linear Time Algorithm for Undirected Introduction Single-Source Shortest Paths with Positive Integer Weights Thorup's algorithm Nick Prühs Introduction Implementation details Thorup's algorithm Overview Performance msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 6. Implementation of Thorup's Linear Time Algorithm for Undirected Introduction Single-Source Shortest Paths with Positive Integer Weights Thorup's algorithm Nick Prühs Introduction Implementation details Thorup's algorithm Overview Performance msb-Minimum spanning tree M Component tree T Bucketing structure B Conclusion Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 7. Implementation of Thorup's Introduction Linear Time Algorithm for Undirected Single-Source Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Conclusion Performance Conclusion
  • 8. Introduction Implementation of Thorup's Linear Time The Single-Source Shortest Paths Problem Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs in: Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 9. Implementation Introduction of Thorup's Linear Time The Single-Source Shortest Paths Problem Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs in: Introduction undirected, connected graph vertices and |E | = m edges G = (V , E ) with |V | = n Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 10. Introduction Implementation of Thorup's Linear Time The Single-Source Shortest Paths Problem Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs in: Introduction undirected, connected graph G = (V , E ) with |V | = n vertices and |E | = m edges positive edge weight function w : V × V → N with ∀(u , v ) ∈ E : w (u , v ) = ∞ / Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 11. Implementation Introduction of Thorup's Linear Time The Single-Source Shortest Paths Problem Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs in: Introduction undirected, connected graph G = (V , E ) with |V | = n vertices and |E | = m edges positive edge weight function w : V × V → N with ∀(u , v ) ∈ E : w (u , v ) = ∞ / distinguished source vertex s∈V Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 12. Implementation Introduction of Thorup's Linear Time The Single-Source Shortest Paths Problem Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs in: Introduction undirected, connected graph G = (V , E ) with |V | = n vertices and |E | = m edges positive edge weight function w : V × V → N with ∀(u , v ) ∈ E : w (u , v ) = ∞ / distinguished source vertex s∈V out: d (v ) = dist (v , s ) for all other vertices v ∈ V {s } Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 13. Introduction Implementation of Thorup's Linear Time Dijkstra's algorithm Algorithm for Undirected proposed by Edsger W. Dijkstra [Dij59] Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 14. Implementation Introduction of Thorup's Linear Time Dijkstra's algorithm Algorithm for Undirected proposed by Edsger W. Dijkstra [Dij59] additional denitions: set of visited vertices S ⊆ V super distance D (v ) ≥ d (v ) for every vertex with D (v ) = d (v ), minu∈S {d (u ) + w (u , v )}, v ∈S v ∈S / Single-Source Shortest Paths with Positive Integer Weights Nick Prühs v ∈ V, Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 15. Implementation Introduction of Thorup's Linear Time Dijkstra's algorithm Algorithm for Undirected proposed by Edsger W. Dijkstra [Dij59] additional denitions: set of visited vertices S ⊆ V super distance D (v ) ≥ d (v ) for every vertex with D (v ) = initialization: d (v ), minu∈S {d (u ) + w (u , v )}, S = {s } D (s ) = d (s ) = 0 ∀v = s : D (v ) = w (s , v ) v ∈S v ∈S / Single-Source Shortest Paths with Positive Integer Weights Nick Prühs v ∈ V, Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 16. Implementation Introduction of Thorup's Linear Time Dijkstra's algorithm Algorithm for Undirected proposed by Edsger W. Dijkstra [Dij59] additional denitions: set of visited vertices S ⊆ V super distance D (v ) ≥ d (v ) for every vertex with D (v ) = d (v ), minu∈S {d (u ) + w (u , v )}, Single-Source Shortest Paths with Positive Integer Weights Nick Prühs v ∈ V, v ∈S v ∈S / initialization: Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T S = {s } D (s ) = d (s ) = 0 ∀v = s : D (v ) = w (s , v ) algorithm: 1. while S = V : Introduction Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation visit the vertex v ∈ S minimizing D (v ) / details Performance Conclusion
  • 17. Implementation Introduction of Thorup's Linear Time Dijkstra's algorithm Algorithm for Undirected proposed by Edsger W. Dijkstra [Dij59] additional denitions: set of visited vertices S ⊆ V super distance D (v ) ≥ d (v ) for every vertex with D (v ) = d (v ), minu∈S {d (u ) + w (u , v )}, Single-Source Shortest Paths with Positive Integer Weights Nick Prühs v ∈ V, Introduction v ∈S v ∈S / Thorup's algorithm Overview msb-Minimum spanning tree M initialization: Component tree T S = {s } D (s ) = d (s ) = 0 ∀v = s : D (v ) = w (s , v ) algorithm: 1. while S = V : 1.1 move 1.2 for all v Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation visit the vertex v ∈ S minimizing D (v ) / to S, because (u , v ) ∈ E , the latter is less Performance D (v ) decrease = d (v ) D (u ) to D (v ) + w (u , v ), details Conclusion if
  • 18. Introduction Implementation of Thorup's Linear Time The problem: The bottleneck of Dijkstra's algorithm Algorithm for Undirected running time results from two operations: Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 19. Implementation Introduction of Thorup's Linear Time The problem: The bottleneck of Dijkstra's algorithm Algorithm for Undirected running time results from two operations: deleteMin: nd a vertex v ∈ S minimizing / (exactly n − 1 times) Single-Source Shortest Paths D (v ) with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 20. Introduction Implementation of Thorup's Linear Time The problem: The bottleneck of Dijkstra's algorithm Algorithm for Undirected running time results from two operations: deleteMin: nd a vertex v ∈ S minimizing D (v ) / (exactly n − 1 times) decreaseKey: decrease D (u ) (at most m times) Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 21. Introduction Implementation of Thorup's Linear Time The problem: The bottleneck of Dijkstra's algorithm Algorithm for Undirected running time results from two operations: deleteMin: nd a vertex v ∈ S minimizing D (v ) / (exactly n − 1 times) decreaseKey: decrease D (u ) (at most m times) naive implementation: deleteMin in O (n) decreaseKey in O (1) total running time is O (n2 + m) Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 22. Introduction Implementation of Thorup's Linear Time The problem: The bottleneck of Dijkstra's algorithm Algorithm for Undirected running time results from two operations: deleteMin: nd a vertex v ∈ S minimizing D (v ) / (exactly n − 1 times) decreaseKey: decrease D (u ) (at most m times) naive implementation: deleteMin in O (n) decreaseKey in O (1) total running time is O (n2 + m) implementation with Fibonacci heaps [FT84]: deleteMin has amortized running time O (log n) decreaseKey has running time O (1) total running time is O (n log n + m) Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 23. Introduction Implementation of Thorup's Linear Time The problem: The bottleneck of Dijkstra's algorithm Algorithm for Undirected running time results from two operations: deleteMin: nd a vertex v ∈ S minimizing D (v ) / (exactly n − 1 times) decreaseKey: decrease D (u ) (at most m times) naive implementation: deleteMin in O (n) decreaseKey in O (1) total running time is O (n2 + m) implementation with Fibonacci heaps [FT84]: deleteMin has amortized running time O (log n) decreaseKey has running time O (1) total running time is O (n log n + m) linear time Dijkstra requires linear time sorting Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 24. Introduction Implementation of Thorup's Linear Time The problem: The bottleneck of Dijkstra's algorithm Algorithm for Undirected running time results from two operations: deleteMin: nd a vertex v ∈ S minimizing D (v ) / (exactly n − 1 times) decreaseKey: decrease D (u ) (at most m times) naive implementation: deleteMin in O (n) decreaseKey in O (1) total running time is O (n2 + m) implementation with Fibonacci heaps [FT84]: deleteMin has amortized running time O (log n) decreaseKey has running time O (1) total running time is O (n log n + m) linear time Dijkstra requires linear time sorting sorting using comparisons only requires Ω(n log n) comparisons Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 25. Introduction Implementation of Thorup's Linear Time The solution: Avoiding the sorting bottleneck Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 26. Introduction Implementation of Thorup's Linear Time The solution: Avoiding the sorting bottleneck Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Thorup [Tho99] does not visit the vertices in order of increasing distance from s Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 27. Introduction Implementation of Thorup's Linear Time The solution: Avoiding the sorting bottleneck Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Thorup [Tho99] does not visit the vertices in order of increasing distance from s identies vertex pairs that can be visited in any order, using a hierarchical bucketing structure Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 28. Introduction Implementation of Thorup's Linear Time The solution: Avoiding the sorting bottleneck Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Thorup [Tho99] does not visit the vertices in order of increasing distance from s Introduction Thorup's algorithm identies vertex pairs that can be visited in any order, using a hierarchical bucketing structure Overview requires several other data structures to be computed before Bucketing structure B msb-Minimum spanning tree M Component tree T Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 29. Implementation of Thorup's Introduction Linear Time Algorithm for Undirected Single-Source Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Conclusion Performance Conclusion
  • 30. Thorup's algorithm Implementation of Thorup's Linear Time Overview Algorithm for Undirected Single-Source Shortest Paths with Positive Thorup's algorithm inherits. . . Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 31. Implementation Thorup's algorithm of Thorup's Linear Time Overview Algorithm for Undirected Single-Source Shortest Paths with Positive Thorup's algorithm inherits. . . . . . the denition of G , V , E , n, Integer Weights m, w , d , s , S and D Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 32. Implementation Thorup's algorithm of Thorup's Linear Time Overview Algorithm for Undirected Single-Source Shortest Paths with Positive Thorup's algorithm inherits. . . . . . the denition of G , V , E , n, . . . the initialization of S and D Integer Weights m, w , d , s , S and D Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 33. Thorup's algorithm Implementation of Thorup's Linear Time Overview Algorithm for Undirected Single-Source Shortest Paths with Positive Thorup's algorithm inherits. . . . . . the denition of G , V , E , n, m, w , d , s , S and D . . . the initialization of S and D . . . visiting a vertex v ∈ V , which might decrease D (u ) for some adjacent vertices u ∈ V and moves v to S Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 34. Thorup's algorithm Implementation of Thorup's Linear Time Overview Algorithm for Undirected Single-Source Shortest Paths with Positive Thorup's algorithm inherits. . . . . . the denition of G , V , E , n, m, w , d , s , S and D . . . the initialization of S and D . . . visiting a vertex v ∈ V , which might decrease D (u ) for some adjacent vertices u ∈ V and moves v to S but Thorup allows visiting a vertex v ∈ S not / minimizing D (v ) Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 35. Thorup's algorithm Implementation of Thorup's Linear Time Overview Algorithm for Undirected Single-Source Shortest Paths with Positive Thorup's algorithm inherits. . . . . . the denition of G , V , E , n, m, w , d , s , S and D . . . the initialization of S and D . . . visiting a vertex v ∈ V , which might decrease D (u ) for some adjacent vertices u ∈ V and moves v to S but Thorup allows visiting a vertex v ∈ S not / minimizing D (v ) in order to identify the next vertex to be visited, the vertices are placed in buckets Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 36. Thorup's algorithm Implementation of Thorup's Linear Time Overview Algorithm for Undirected Single-Source Shortest Paths with Positive Thorup's algorithm inherits. . . . . . the denition of G , V , E , n, m, w , d , s , S and D . . . the initialization of S and D . . . visiting a vertex v ∈ V , which might decrease D (u ) for some adjacent vertices u ∈ V and moves v to S but Thorup allows visiting a vertex v ∈ S not / minimizing D (v ) in order to identify the next vertex to be visited, the vertices are placed in buckets every bucket is associated with a component, a node of the component tree explained later Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 37. Thorup's algorithm Implementation of Thorup's Linear Time The main routine Algorithm for Undirected Single-Source Shortest Paths The whole algorithm can be summarized in top-level pseudo-code as follows: with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 38. Thorup's algorithm Implementation of Thorup's Linear Time The main routine Algorithm for Undirected Single-Source Shortest Paths The whole algorithm can be summarized in top-level pseudo-code as follows: 1. Construct an msb-minimum spanning tree M in O (m). with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 39. Thorup's algorithm Implementation of Thorup's Linear Time The main routine Algorithm for Undirected Single-Source Shortest Paths The whole algorithm can be summarized in top-level pseudo-code as follows: 1. Construct an msb-minimum spanning tree M in O (m). 2. Construct the component tree T in O (m). with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 40. Thorup's algorithm Implementation of Thorup's Linear Time The main routine Algorithm for Undirected Single-Source Shortest Paths The whole algorithm can be summarized in top-level pseudo-code as follows: 1. Construct an msb-minimum spanning tree M in O (m). 2. Construct the component tree T in O (m). 3. Construct the unvisited data structure U in O (n). with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 41. Thorup's algorithm Implementation of Thorup's Linear Time The main routine Algorithm for Undirected Single-Source Shortest Paths The whole algorithm can be summarized in top-level pseudo-code as follows: 1. Construct an msb-minimum spanning tree M in O (m). 2. Construct the component tree T in O (m). 3. Construct the unvisited data structure U in O (n). 4. Set S = {s }. 5. Set D (s ) = 0. 6. For all v ∈ V with v = s : Set D (v ) = w (s , v ). with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 42. Thorup's algorithm Implementation of Thorup's Linear Time The main routine Algorithm for Undirected Single-Source Shortest Paths The whole algorithm can be summarized in top-level pseudo-code as follows: 1. Construct an msb-minimum spanning tree M in O (m). 2. Construct the component tree T in O (m). 3. Construct the unvisited data structure U in O (n). 4. Set S = {s }. 5. Set D (s ) = 0. 6. For all v ∈ V with v = s : Set D (v ) = w (s , v ). 7. Visit the root of the component tree T . 8. Return D . with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 43. Implementation of Thorup's Introduction Linear Time Algorithm for Undirected Single-Source Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Conclusion Performance Conclusion
  • 44. Thorup's algorithm Implementation of Thorup's Linear Time Constructing a minimum spanning tree in linear time? Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs construction of a minimum spanning tree is possible in linear time [FW90] Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 45. Thorup's algorithm Implementation of Thorup's Linear Time Constructing a minimum spanning tree in linear time? Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs construction of a minimum spanning tree is possible in linear time [FW90] this requires a priority queue called atomic heap, which requires n 212 20 Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 46. Thorup's algorithm Implementation of Thorup's Linear Time Constructing a minimum spanning tree in linear time? Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs construction of a minimum spanning tree is possible in linear time [FW90] this requires a priority queue called atomic heap, which requires n 212 20 nd a dierent way for today's computers Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 47. Implementation Thorup's algorithm The msb -minimum spanning tree of Thorup's M Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs let msb(x ) = log2 x denote the position of the most signicant bit of x ∈ N Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 48. Implementation Thorup's algorithm The msb -minimum spanning tree of Thorup's M Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs let msb(x ) = log2 x denote the position of the most signicant bit of x ∈ N an msb-minimum spanning tree of a graph G is a spanning tree that is minimal in G where each weight x is replaced by msb(x ) Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 49. Implementation Thorup's algorithm The msb -minimum spanning tree of Thorup's M Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs let msb(x ) = log2 x denote the position of the most signicant bit of x ∈ N an msb-minimum spanning tree of a graph G is a spanning tree that is minimal in G where each weight x is replaced by msb(x ) use such an msb-minimum spanning tree for constructing the component tree Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 50. Implementation Thorup's algorithm An example of an input graph of Thorup's G (n = 11, m = 16) Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 51. Implementation Thorup's algorithm The input graph G after having replaced each weight of Thorup's x by msb (x ) Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 52. Implementation Thorup's algorithm An msb -minimum spanning tree of of Thorup's G Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 53. Implementation Thorup's algorithm How to construct an msb -minimum of Thorup's Linear Time spanning tree Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction 1. sort all edges according to their msb-weights in linear time using simple bucketing Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 54. Implementation Thorup's algorithm How to construct an msb -minimum of Thorup's Linear Time spanning tree Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction 1. sort all edges according to their msb-weights in linear time using simple bucketing 2. compute a minimum spanning tree with Kruskal's algorithm [Kru56], using the pre-sorted edges Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 55. Implementation Thorup's algorithm How to construct an msb -minimum of Thorup's Linear Time spanning tree Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction the clustering is done with Tarjan's union-nd algorithm [Tar75] Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 56. Implementation Thorup's algorithm How to construct an msb -minimum of Thorup's Linear Time spanning tree Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction the clustering is done with Tarjan's union-nd algorithm [Tar75] the use of union with size, and nd with path compression leads to a time bound of O (α(m, n)m) Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 57. Implementation of Thorup's Introduction Linear Time Algorithm for Undirected Single-Source Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Conclusion Performance Conclusion
  • 58. Thorup's algorithm Implementation of Thorup's Linear Time The component hierarchy Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights let Gi be the subgraph of G containing all edges e ∈ E with w (e ) 2i Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 59. Thorup's algorithm Implementation of Thorup's Linear Time The component hierarchy Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights let Gi be the subgraph of G containing all edges e ∈ E with w (e ) 2i Level i of Thorup's component hierarchy consists of the components of Gi Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 60. Thorup's algorithm Implementation of Thorup's Linear Time The component hierarchy Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights let Gi be the subgraph of G containing all edges e ∈ E with w (e ) 2i Level i of Thorup's component hierarchy consists of the components of Gi use the msb-minimum spanning tree here Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 61. Thorup's algorithm Implementation of Thorup's Linear Time The component hierarchy Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights let Gi be the subgraph of G containing all edges e ∈ E with w (e ) 2i Level i of Thorup's component hierarchy consists of the components of Gi use the msb-minimum spanning tree here let [v ]i denote the component on level i containing the vertex v ∈ V Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 62. Thorup's algorithm Implementation of Thorup's Linear Time The component hierarchy Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights let Gi be the subgraph of G containing all edges e ∈ E with w (e ) 2i Level i of Thorup's component hierarchy consists of the components of Gi use the msb-minimum spanning tree here let [v ]i denote the component on level i containing the vertex v ∈ V the children of a component [v ]i are all components [w ]i −1 with [w ]i = [v ]i , in other words with w ∈ [v ]i Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 63. Thorup's algorithm Implementation of Thorup's Linear Time The component hierarchy Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights let Gi be the subgraph of G containing all edges e ∈ E with w (e ) 2i Level i of Thorup's component hierarchy consists of the components of Gi use the msb-minimum spanning tree here let [v ]i denote the component on level i containing the vertex v ∈ V the children of a component [v ]i are all components [w ]i −1 with [w ]i = [v ]i , in other words with w ∈ [v ]i [v ]i = [w ]i ⇒ dist (v , w ) ≥ 2i Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 64. Thorup's algorithm The subgraph G4 Implementation of Thorup's Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 65. Thorup's algorithm The component tree T Implementation of Thorup's Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights the component tree T skips all nodes [v ]i = [v ]i −1 : Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 66. Thorup's algorithm The component tree T Implementation of Thorup's Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights the component tree T skips all nodes [v ]i = [v ]i −1 : Every leaf of T is a singleton component [v ]0 = {v }, v ∈ V. Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 67. Thorup's algorithm The component tree T Implementation of Thorup's Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights the component tree T skips all nodes [v ]i = [v ]i −1 : Every leaf of T is a singleton component [v ]0 = {v }, v ∈ V. Every internal node of T is a component [v ]i , v ∈ V , with i 0 and [v ]i −1 [v ]i . Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 68. Thorup's algorithm The component tree T Implementation of Thorup's Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights the component tree T skips all nodes [v ]i = [v ]i −1 : Every leaf of T is a singleton component [v ]0 = {v }, v ∈ V. Every internal node of T is a component [v ]i , v ∈ V , with i 0 and [v ]i −1 [v ]i . The root of T is the node [v ]r = G with r minimized. Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 69. Thorup's algorithm The component tree T Implementation of Thorup's Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights the component tree T skips all nodes [v ]i = [v ]i −1 : Every leaf of T is a singleton component [v ]0 = {v }, v ∈ V. Every internal node of T is a component [v ]i , v ∈ V , with i 0 and [v ]i −1 [v ]i . The root of T is the node [v ]r = G with r minimized. the parent of a node [v ]i is its nearest ancestor in the component hierarchy with at least two children Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 70. Thorup's algorithm The component tree T Implementation of Thorup's Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights the component tree T skips all nodes [v ]i = [v ]i −1 : Every leaf of T is a singleton component [v ]0 = {v }, v ∈ V. Every internal node of T is a component [v ]i , v ∈ V , with i 0 and [v ]i −1 [v ]i . The root of T is the node [v ]r = G with r minimized. the parent of a node [v ]i is its nearest ancestor in the component hierarchy with at least two children T has no nodes with exactly one child ⇒ the total number of nodes is bounded by 2n ∈ O (n) Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 71. Thorup's algorithm The component tree T of G Implementation of Thorup's Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 72. Thorup's algorithm The components of G4 Implementation of Thorup's Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 73. Thorup's algorithm The subgraph G4 Implementation of Thorup's Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 74. Implementation Thorup's algorithm How to construct the component tree of Thorup's T Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs 1. sort the edges of M according to the most signicant bits of their weights Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 75. Implementation Thorup's algorithm How to construct the component tree of Thorup's T Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs 1. sort the edges of M according to the most signicant bits of their weights 2. process the resulting sequence of edges e1 , . . . , en−1 in the following way: For i = 1 to n − 1: Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 76. Implementation Thorup's algorithm How to construct the component tree of Thorup's T Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs 1. sort the edges of M according to the most signicant bits of their weights 2. process the resulting sequence of edges e1 , . . . , en−1 in the following way: For i = 1 to n − 1: 2.1 Let (v , w ) = ei . 2.2 Call union(v , w ). 2.3 If msb(w (ei )) msb(w (ei +1 )): Insert all new components of the union-nd structure into T . Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 77. Implementation Thorup's algorithm How to construct the component tree of Thorup's T Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs using Tarjan's union-nd algorithm [Tar75] again, the running time is O (α(m, n)m) Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 78. Implementation Thorup's algorithm How to construct the component tree of Thorup's T Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs using Tarjan's union-nd algorithm [Tar75] again, the running time is O (α(m, n)m) construction T in linear time is also possible: Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 79. Implementation Thorup's algorithm How to construct the component tree of Thorup's T Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs using Tarjan's union-nd algorithm [Tar75] again, the running time is O (α(m, n)m) construction T in linear time is also possible: requires the tabulation-based union-nd algorithm by Gabow and Tarjan which runs in O (m + n) time [GT85] Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 80. Implementation Thorup's algorithm How to construct the component tree of Thorup's T Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs using Tarjan's union-nd algorithm [Tar75] again, the running time is O (α(m, n)m) construction T in linear time is also possible: requires the tabulation-based union-nd algorithm by Gabow and Tarjan which runs in O (m + n) time [GT85] much more complicated than the one by Tarjan we use the simpler one here Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 81. Implementation of Thorup's Introduction Linear Time Algorithm for Undirected Single-Source Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Conclusion Performance Conclusion
  • 82. Thorup's algorithm The bucketing structure B Implementation of Thorup's Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive visit the nodes of the component tree T in the right order Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 83. Thorup's algorithm The bucketing structure B Implementation of Thorup's Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive visit the nodes of the component tree T in the right order whenever a component [v ]i is visited, so are all its ancestors in T Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 84. Thorup's algorithm The bucketing structure B Implementation of Thorup's Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive visit the nodes of the component tree T in the right order whenever a component [v ]i is visited, so are all its ancestors in T bucket the children [w ]h of a component [v ]i into B ([v ]i , min D ([w ]− ) i − 1) h Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 85. Thorup's algorithm The bucketing structure B Implementation of Thorup's Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive visit the nodes of the component tree T in the right order whenever a component [v ]i is visited, so are all its ancestors in T bucket the children [w ]h of a component [v ]i into B ([v ]i , min D ([w ]− ) i − 1) h maintain two additional properties for every component: ix ([v ]i ) ≤ the smallest index of a nonempty bucket of [v ]i ∆([v ]i ) = number buckets of [v ]i Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 86. Thorup's algorithm The bucketing structure B Implementation of Thorup's Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive visit the nodes of the component tree T in the right order whenever a component [v ]i is visited, so are all its ancestors in T bucket the children [w ]h of a component [v ]i into B ([v ]i , min D ([w ]− ) i − 1) h maintain two additional properties for every component: ix ([v ]i ) ≤ the smallest index of a nonempty bucket of [v ]i ∆([v ]i ) = number buckets of [v ]i the total number of buckets is bounded by 8n Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 87. Implementation of Thorup's Introduction Linear Time Algorithm for Undirected Single-Source Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Conclusion Performance Conclusion
  • 88. Implementation Thorup's algorithm The unvisited data structure of Thorup's U Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights The unvisited data structure U . . . Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 89. Implementation Thorup's algorithm The unvisited data structure of Thorup's U Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights The unvisited data structure U . . . . . . represents the unvisited subforest of the component tree T Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 90. Implementation Thorup's algorithm The unvisited data structure of Thorup's U Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights The unvisited data structure U . . . . . . represents the unvisited subforest of the component tree T . . . is required for maintaining the changing values min D ([v ]− ) for the changing set of roots [v ]i in the i unvisited part of T in linear total time Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 91. Implementation Thorup's algorithm The unvisited data structure of Thorup's U Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights The unvisited data structure U . . . . . . represents the unvisited subforest of the component tree T . . . is required for maintaining the changing values min D ([v ]− ) for the changing set of roots [v ]i in the i unvisited part of T in linear total time [v ]i is a root of a tree in U if and only if [v ]i is an unvisited child of a visited component in T Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 92. Implementation Thorup's algorithm The unvisited data structure of Thorup's U Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights The unvisited data structure U . . . . . . represents the unvisited subforest of the component tree T . . . is required for maintaining the changing values min D ([v ]− ) for the changing set of roots [v ]i in the i unvisited part of T in linear total time [v ]i is a root of a tree in U if and only if [v ]i is an unvisited child of a visited component in T [v ]i = [v ]i for each of these roots, because they are unvisited − Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 93. Thorup's algorithm Implementation of Thorup's Linear Time The problem: Operations of the unvisited data structure Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs two operations in amortized constant time: 1. Update min D ([v ]i ) whenever D (v ) is decreased for some vertex v ∈ V with unvisited root [v ]i . 2. Turn all children [w ]h of [v ]i in T into roots in U and compute min D ([w ]− ) for all of them whenever an h unvisited root [v ]i is visited. Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 94. Thorup's algorithm Implementation of Thorup's Linear Time The problem: Operations of the unvisited data structure Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs two operations in amortized constant time: 1. Update min D ([v ]i ) whenever D (v ) is decreased for some vertex v ∈ V with unvisited root [v ]i . 2. Turn all children [w ]h of [v ]i in T into roots in U and compute min D ([w ]− ) for all of them whenever an h unvisited root [v ]i is visited. transform this problem into another one that can be solved by the split-ndmin structure by Gabow [Gab85] Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 95. Implementation Thorup's algorithm The initial unvisited data structure of Thorup's U of G Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion [1, 2, 3, 10, 8, 9, 4, 5, 7, 11, 6]
  • 96. Implementation Thorup's algorithm The unvisited data structure of Thorup's U after having called visit([1]11 ) Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion [1, 2, 3, 10, 8, 9, 4, 5, 7, 11] [6]
  • 97. Implementation Thorup's algorithm The unvisited data structure of Thorup's U after having called visit([1]9 ) Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion [1, 2, 3, 10, 8, 9, 4, 5, 7] [11] [6]
  • 98. Implementation Thorup's algorithm The unvisited data structure of Thorup's U after having called visit([1]7 ) Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion [1, 2, 3, 10, 8, 9] [4, 5, 7] [11] [6]
  • 99. Thorup's algorithm Implementation of Thorup's Linear Time Total running time of the operations of the unvisited data structure Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights for k ∈ N, k 2, each split in k can be implemented by k − 1 splits in two Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 100. Thorup's algorithm Implementation of Thorup's Linear Time Total running time of the operations of the unvisited data structure Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights for k ∈ N, k 2, each split in k can be implemented by k − 1 splits in two at most n − 1 splits in two, because |V | = n Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 101. Thorup's algorithm Implementation of Thorup's Linear Time Total running time of the operations of the unvisited data structure Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights for k ∈ N, k 2, each split in k can be implemented by k − 1 splits in two at most n − 1 splits in two, because |V | = n at most m decreases, one for each edge in G Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 102. Thorup's algorithm Implementation of Thorup's Linear Time Total running time of the operations of the unvisited data structure Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights for k ∈ N, k 2, each split in k can be implemented by k − 1 splits in two at most n − 1 splits in two, because |V | = n at most m decreases, one for each edge in G Gabow's split-ndmin data structure supports exactly these two operations Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 103. Thorup's algorithm Implementation of Thorup's Linear Time Total running time of the operations of the unvisited data structure Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights for k ∈ N, k 2, each split in k can be implemented by k − 1 splits in two at most n − 1 splits in two, because |V | = n at most m decreases, one for each edge in G Gabow's split-ndmin data structure supports exactly these two operations the total runinng time for n − 1 splits and m decreases is O (α(m, n)m) Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 104. Thorup's algorithm Implementation of Thorup's Linear Time Operations of the unvisited data structure in linear total time? Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Thorup presented an O (m + n) solution [Tho99]), which is based on the atomic heaps by Fredman and Willard Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 105. Thorup's algorithm Implementation of Thorup's Linear Time Operations of the unvisited data structure in linear total time? Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Thorup presented an O (m + n) solution [Tho99]), which is based on the atomic heaps by Fredman and Willard as mentioned above, these priority queues require n 212 20 Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 106. Thorup's algorithm Implementation of Thorup's Linear Time Operations of the unvisited data structure in linear total time? Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Thorup presented an O (m + n) solution [Tho99]), which is based on the atomic heaps by Fredman and Willard Introduction Thorup's algorithm as mentioned above, these priority queues require n 212 Overview fall back to the solution by Gabow and to a total running time of O (α(m, n)m) Bucketing structure B 20 msb-Minimum spanning tree M Component tree T Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 107. Implementation of Thorup's Introduction Linear Time Algorithm for Undirected Single-Source Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Conclusion Performance Conclusion
  • 108. Thorup's algorithm Implementation of Thorup's Linear Time The main routine revisited Algorithm for Undirected Single-Source Shortest Paths with Positive 1. Construct an msb-minimum spanning tree M in O (m). Integer Weights Nick Prühs (done) Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 109. Thorup's algorithm Implementation of Thorup's Linear Time The main routine revisited Algorithm for Undirected Single-Source Shortest Paths with Positive 1. Construct an msb-minimum spanning tree M in O (m). Integer Weights Nick Prühs (done) 2. Construct the component tree T in O (m). (done) Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 110. Thorup's algorithm Implementation of Thorup's Linear Time The main routine revisited Algorithm for Undirected Single-Source Shortest Paths with Positive 1. Construct an msb-minimum spanning tree M in O (m). Integer Weights Nick Prühs (done) 2. Construct the component tree T in O (m). (done) 3. Construct the unvisited data structure U in O (n). (done) Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 111. Thorup's algorithm Implementation of Thorup's Linear Time The main routine revisited Algorithm for Undirected Single-Source Shortest Paths with Positive 1. Construct an msb-minimum spanning tree M in O (m). Integer Weights Nick Prühs (done) 2. Construct the component tree T in O (m). (done) 3. Construct the unvisited data structure U in O (n). (done) 4. Set S = {s }. (done) 5. Set D (s ) = 0. (done) 6. For all v ∈ V with v = s : Set D (v ) = w (s , v ). (done) Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 112. Thorup's algorithm Implementation of Thorup's Linear Time The main routine revisited Algorithm for Undirected Single-Source Shortest Paths with Positive 1. Construct an msb-minimum spanning tree M in O (m). Integer Weights Nick Prühs (done) 2. Construct the component tree T in O (m). (done) 3. Construct the unvisited data structure U in O (n). (done) 4. Set S = {s }. (done) 5. Set D (s ) = 0. (done) 6. For all v ∈ V with v = s : Set D (v ) = w (s , v ). (done) 7. Visit the root of the component tree T . 8. Return D . Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 113. Thorup's algorithm Visit( [v ]i ): Implementation of Thorup's Linear Time Step 1 Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction If [v ]i is the root of T , 1. then: Set j = ω + 1. 2. else: Let [v ]j be the parent of [v ]i in T . Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 114. Implementation Thorup's algorithm Visit( [v ]i ): of Thorup's Linear Time Step 2 Algorithm for Undirected Single-Source Shortest Paths with Positive If i = 0: Integer Weights Nick Prühs 1. Add v to S . 2. For all edges (u , v ) ∈ E : 2.1 If D (v ) + w (u , v ) D (w ): 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 [u ]h be the unvisited root of [u ]0 in U . Let [u ]i be the visited parent of [u ]h in T . − Set oldMin = min D ([u ] ) i − 1. h Decrease D (u ) to D (v ) + w (u , v ). − i − 1 oldMin: Move [u ]h If min D ([u ] ) h B ([u ]i , min D ([u ]h ) i − 1). Introduction Thorup's algorithm Overview Let 3. Remove [v ]i from its bucket of [v ]j . 4. Return. msb-Minimum spanning tree M Component tree T Bucketing structure B to bucket Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 115. Thorup's algorithm Visit( [v ]i ): Implementation of Thorup's Linear Time Step 3 Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs If [v ]i is visited for the rst time: 1. Construct the ∆([v ]i ) buckets of [v ]i . 2. Delete [v ]i from U , turning its children into roots in U . 3. For all children [w ]h of [v ]i : 3.1 Bucket [w ]h in B ([v ]i , min D ([w ]− ) i − 1). h Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 116. Implementation Thorup's algorithm Visit( [v ]i ): of Thorup's Linear Time Steps 4-6 Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Set oldIndex = ix ([v ]i ) j − i. Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 117. Implementation Thorup's algorithm Visit( [v ]i ): of Thorup's Linear Time Steps 4-6 Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Set oldIndex = ix ([v ]i ) j − i. − While [v ]i = ∅ and oldIndex = ix ([v ]i ) 1. While B ([v ]i , ix ([v ]i )) = ∅: 1.1 1.2 [w ]h ∈ B ([v ]i , ix ([v ]i )). Call visit ([w ]h ). Let 2. Increment ix ([v ]i ). Nick Prühs j − i: Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 118. Implementation Thorup's algorithm Visit( [v ]i ): of Thorup's Linear Time Steps 4-6 Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Set oldIndex = ix ([v ]i ) j − i. − While [v ]i = ∅ and oldIndex = ix ([v ]i ) 1. While B ([v ]i , ix ([v ]i )) = ∅: 1.1 1.2 [w ]h ∈ B ([v ]i , ix ([v ]i )). Call visit ([w ]h ). Nick Prühs j − i: Let 2. Increment ix ([v ]i ). If [v ]− = ∅, i 1. then: If [v ]i is not the root of T , remove it from its bucket of [v ]j . 2. else: Move [v ]i to bucket B ([v ]j , ix ([v ]i ) j − i ). Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 119. Implementation of Thorup's Introduction Linear Time Algorithm for Undirected Single-Source Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Conclusion Performance Conclusion
  • 120. Implementation details Implementation of Thorup's Linear Time The strategy pattern Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Java implementation: imperative programming language ts the required RAM model object-oriented word length ω = 32, number of vertices n ≤ 232 allows the extensive use of the strategy pattern Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 121. Implementation details Implementation of Thorup's Linear Time Implemented data structures Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs an undirected, weighted graph using adjacency lists an array priority queue Introduction Thorup's algorithm Overview a Fibonacci heap [FT84] msb-Minimum a split-ndmin structure [GT85] T a union-nd structure [Tar75] spanning tree M Component tree Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 122. Implementation details Implementation of Thorup's Linear Time Implemented algorithms Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Kruskal [Kru56] Dijkstra [Dij59] Thorup [Tho99] Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 123. Implementation of Thorup's Introduction Linear Time Algorithm for Undirected Single-Source Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Conclusion Performance Conclusion
  • 124. Performance Implementation of Thorup's Linear Time The performance tests Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction average of ve passes Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 125. Performance Implementation of Thorup's Linear Time The performance tests Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction average of ve passes the test system: Intel Core 2 Duo E6300 at 1,86 GHz 2048 MB DDR2 667 PC2-5300 RAM Java 1.6.0_15 Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 126. Performance Implementation of Thorup's Linear Time Varying the number of vertices Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction start with n = 1000 and increase it in steps of 1000 until n = 10000 about m = 5n edges edge weights 1 ≤ w ≤ 100000 Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 127. Performance Implementation of Thorup's Linear Time Varying the number of vertices: Results Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Figure: Running times for 1000 ≤ n ≤ 10000, m = 5n. Performance Conclusion
  • 128. Performance Implementation of Thorup's Linear Time Varying the number of vertices Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights start with n = 4000 and increase it in steps of 4000 until n = 40000 about m = 5n edges again edge weights 1 ≤ w ≤ 100000 again Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 129. Performance Implementation of Thorup's Linear Time Varying the number of vertices Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights start with n = 4000 and increase it in steps of 4000 until n = 40000 about m = 5n edges again edge weights 1 ≤ w ≤ 100000 again leave out the naive implementation of Dijkstra's algorithm and focus on the faster one Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 130. Performance Implementation of Thorup's Linear Time Varying the number of vertices Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights start with n = 4000 and increase it in steps of 4000 until n = 40000 about m = 5n edges again edge weights 1 ≤ w ≤ 100000 again leave out the naive implementation of Dijkstra's algorithm and focus on the faster one nd out which n is required for Thorup to catch up with Dijkstra Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 131. Performance Implementation of Thorup's Linear Time Varying the number of vertices: Results Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Figure: Running times for 4000 ≤ n ≤ 40000, m = 5n. Conclusion
  • 132. Performance Implementation of Thorup's Linear Time Varying the number of edges per vertex Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction x the number of vertices n = 20000 start with m = 3n edges and increase it in steps of 3n until m = 24n edge weights 1 ≤ w ≤ 100000 again Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 133. Implementation Performance of Thorup's Linear Time Varying the number of edges per vertex: Results Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Figure: Running times for n = 20000, 3n ≤ m ≤ 24n. Conclusion
  • 134. Performance Implementation of Thorup's Linear Time Varying the maximum edge weight Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs x the number of vertices n = 20000 x the number of edges m = 5n start by choosing all edge weights 1 ≤ w ≤ 5 and increase the maximum edge weight in steps of 5 until 1 ≤ w ≤ 100 Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 135. Performance Implementation of Thorup's Linear Time Varying the maximum edge weight: Results Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation Figure: Running times for n = 20000, m = 5n, and maximum edge weights between 5 and 100. details Performance Conclusion
  • 136. Implementation Performance of Thorup's Linear Time Varying the maximum edge weight: Results Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights maximum edge weight 256 1024 16384 Dijkstra (Fibonacci heap) 212 209 212 219 Thorup (MST) Thorup (other DS) Thorup (visit) 148 153 461 153 171 423 145 156 430 168 140 403 Nick Prühs 262144 Table: Running times for n = 20000, m = 5n and maximum edge weights 28 , 210 , 214 and 218 . Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 137. Performance Implementation of Thorup's Linear Time Repetitive queries Algorithm for Undirected Single-Source Shortest Paths nd out whether Thorup's algorithm can catch up with the one by Dijkstra making repetive queries with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 138. Performance Implementation of Thorup's Linear Time Repetitive queries Algorithm for Undirected Single-Source Shortest Paths nd out whether Thorup's algorithm can catch up with the one by Dijkstra making repetive queries at the rst query, all required data structures are computed once this is the initial lead Dijkstra's algorithm has over the one by Thorup with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 139. Performance Implementation of Thorup's Linear Time Repetitive queries Algorithm for Undirected Single-Source Shortest Paths nd out whether Thorup's algorithm can catch up with the one by Dijkstra making repetive queries at the rst query, all required data structures are computed once this is the initial lead Dijkstra's algorithm has over the one by Thorup clean up between two queries: 1. Reset the set S of visited vertices. 2. Clear all buckets. 3. Reset the unvisited data structure U , making it contain only the root of T . with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 140. Performance Implementation of Thorup's Linear Time Repetitive queries Algorithm for Undirected Single-Source Shortest Paths nd out whether Thorup's algorithm can catch up with the one by Dijkstra making repetive queries at the rst query, all required data structures are computed once this is the initial lead Dijkstra's algorithm has over the one by Thorup clean up between two queries: 1. Reset the set S of visited vertices. 2. Clear all buckets. 3. Reset the unvisited data structure U , making it contain only the root of T . still takes signicantly less time than before the rst query with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 141. Performance Implementation of Thorup's Linear Time Repetitive queries Algorithm for Undirected Single-Source test instance: the road network of New York City number of vertices n = 264, 346 number of edges m = 733, 846 (about m = 3n) Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 142. Performance Implementation of Thorup's Linear Time Repetitive queries Algorithm for Undirected Single-Source test instance: the road network of New York City number of vertices n = 264, 346 number of edges m = 733, 846 (about m = 3n) source: 9th DIMACS Implementation Challenge Shortest Paths [Dem06] Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 143. Performance Implementation of Thorup's Linear Time Repetitive queries Algorithm for Undirected Single-Source test instance: the road network of New York City number of vertices n = 264, 346 number of edges m = 733, 846 (about m = 3n) source: 9th DIMACS Implementation Challenge Shortest Paths [Dem06] Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm nd the shortest paths from the vertices with indices 0 to 9 to all other ones Overview accumulate the resulting running times Bucketing structure B msb-Minimum spanning tree M Component tree T Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 144. Performance Implementation of Thorup's Linear Time Repetitive queries Algorithm for Undirected Single-Source test instance: the road network of New York City number of vertices n = 264, 346 number of edges m = 733, 846 (about m = 3n) source: 9th DIMACS Implementation Challenge Shortest Paths [Dem06] Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm nd the shortest paths from the vertices with indices 0 to 9 to all other ones Overview accumulate the resulting running times Bucketing structure B the initialization of Thorup's algorithm takes about 2100 ms and is added to the rst accumulated time the time required for cleaning up all data structures is always about 200 ms and is added to the accumulated time of the query the clean-up has been done before msb-Minimum spanning tree M Component tree T Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 145. Performance Implementation of Thorup's Linear Time Repetitive queries: Results Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Figure: Accumulated running times for ten queries on the road network of New York City. Performance Conclusion
  • 146. Implementation of Thorup's Introduction Linear Time Algorithm for Undirected Single-Source Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Conclusion Performance Conclusion
  • 147. Conclusion Implementation of Thorup's Linear Time Algorithm for Undirected Single-Source Thorup's algorithm does not require comparison-based sorting and is today's theoretically fastest SSSP algorithm, . . . Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 148. Conclusion Implementation of Thorup's Linear Time Algorithm for Undirected Single-Source Thorup's algorithm does not require comparison-based sorting and is today's theoretically fastest SSSP algorithm, . . . . . . but our implementation of the algorithm is still signicantly slower than our implementation of Dijkstra's algorithm using a Fibonacci heap Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 149. Conclusion Implementation of Thorup's Linear Time Algorithm for Undirected Single-Source Thorup's algorithm does not require comparison-based sorting and is today's theoretically fastest SSSP algorithm, . . . . . . but our implementation of the algorithm is still signicantly slower than our implementation of Dijkstra's algorithm using a Fibonacci heap possbile reasons are: an inecient implementation a word length which is still too small for realizing the full potential of Thorup's algorithm Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 150. Conclusion Implementation of Thorup's Linear Time Algorithm for Undirected Single-Source Thorup's algorithm does not require comparison-based sorting and is today's theoretically fastest SSSP algorithm, . . . . . . but our implementation of the algorithm is still signicantly slower than our implementation of Dijkstra's algorithm using a Fibonacci heap possbile reasons are: an inecient implementation a word length which is still too small for realizing the full potential of Thorup's algorithm these observations essentially equal the conclusion made by Yasuhito Asano and Hiroshi Imai [AI00] Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 151. Conclusion Implementation of Thorup's Linear Time Future work Algorithm for Undirected Single-Source Shortest Paths implement the strictly linear time parts of Thorup's algorithm: the linear time algorithm for constructing minimum spanning trees [FW90] the linear time union-nd [GT85] structure the linear time split-ndmin structure [Tho99] with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 152. Conclusion Implementation of Thorup's Linear Time Future work Algorithm for Undirected Single-Source Shortest Paths implement the strictly linear time parts of Thorup's algorithm: the linear time algorithm for constructing minimum spanning trees [FW90] the linear time union-nd [GT85] structure the linear time split-ndmin structure [Tho99] see how well Thorup's algorithm does compared to fast all shortest paths algorithms with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 153. Conclusion Implementation of Thorup's Linear Time Future work Algorithm for Undirected Single-Source Shortest Paths implement the strictly linear time parts of Thorup's algorithm: the linear time algorithm for constructing minimum spanning trees [FW90] the linear time union-nd [GT85] structure the linear time split-ndmin structure [Tho99] see how well Thorup's algorithm does compared to fast all shortest paths algorithms see if his component tree can be useful for other applications with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 154. Conclusion Implementation of Thorup's Linear Time Future work Algorithm for Undirected Single-Source Shortest Paths implement the strictly linear time parts of Thorup's algorithm: the linear time algorithm for constructing minimum spanning trees [FW90] the linear time union-nd [GT85] structure the linear time split-ndmin structure [Tho99] see how well Thorup's algorithm does compared to fast all shortest paths algorithms see if his component tree can be useful for other applications run the algorithm on signicantly larger graphs and check whether it is as attractive for repetitive queries as expected, as soon as we are able to with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 155. Conclusion Implementation of Thorup's Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Thank you for your attention! Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 156. Yasuhito Asano and Hiroshi Imai. Practical eciency of the linear-time algorithm for the single source shortest path problem. Journal of the Operations Research, 43:431447, 2000. Camil Demetrescu. 9th dimacs implementation challenge - shortest paths. http://www.dis.uniroma1.it/~challenge9/ download.shtml, 2006. Edsger W. Dijkstra. A note on two problems in connection with graphs. Numer. Math., 1:269271, 1959. Michael L. Fredman and Robert Endre Tarjan. Fibonacci heaps and their uses in improved network optimization algorithms. In FOCS, pages 338346. IEEE, 1984. Michael L. Fredman and Dan E. Willard. Implementation of Thorup's Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 157. Trans-dichotomous algorithms for minimum spanning trees and shortest paths. In FOCS, volume II, pages 719725. IEEE, 1990. Harold N. Gabow. A scaling algorithm for weighted matching on general graphs. In FOCS, pages 90100. IEEE, 1985. Harold N. Gabow and Robert Endre Tarjan. A linear-time algorithm for a special case of disjoint set union. J. Comput. Syst. Sci., 30(2):209221, 1985. Joseph B. Kruskal. On the shortest spanning subtree of a graph and the traveling salesman problem. Proc. Am. Math. Soc, 7:4850, 1956. Robert Endre Tarjan. Eciency of a good but not linear set union algorithm. J. ACM, 22(2):215225, 1975. Implementation of Thorup's Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion
  • 158. Mikkel Thorup. Undirected single-source shortest paths with positive integer weights in linear time. J. ACM, 46(3):362394, 1999. Implementation of Thorup's Linear Time Algorithm for Undirected Single-Source Shortest Paths with Positive Integer Weights Nick Prühs Introduction Thorup's algorithm Overview msb-Minimum spanning tree M Component tree T Bucketing structure B Unvisited data structure U Visiting components and vertices Implementation details Performance Conclusion