SingleSource Shortest Paths SSSP: Dijkstras Algorithm - PowerPoint PPT Presentation

1 / 31
About This Presentation
Title:

SingleSource Shortest Paths SSSP: Dijkstras Algorithm

Description:

... Source Shortest Paths (SSSP): Dijkstra's Algorithm. Find the shortest paths ... Dijkstra's algorithm (serial) The number of steps : n-1 ... Dijkstra's algorithm ... – PowerPoint PPT presentation

Number of Views:132
Avg rating:3.0/5.0
Slides: 32
Provided by: engi57
Category:

less

Transcript and Presenter's Notes

Title: SingleSource Shortest Paths SSSP: Dijkstras Algorithm


1
Single-Source Shortest Paths (SSSP) Dijkstras
Algorithm
  • Find the shortest paths from a vertex s to all
    other vertices
  • Solve SSSP for graphs with non-negative weights
  • Greedy method incrementally find the shortest
    paths from s to the other vertices by choosing a
    closest vertex

2
G original graph
A the weighted adjacency matrix for G
a
b
c
d
a
a
1
3
b
5
A
b
c
c
1
d
2
d
3
Select the source
Lv the least weight from s to v
a
b
c
d
a
a
1
3
b
A
5
b
c
c
Source
update
d
1
2
d
L
4
Step 1 select the next vertex and edge
a
b
c
d
a
a
1
3
b
A
5
b
c
c
d
1
2
d
L
Pick a minimum weighted edge from the source b ?
minLa,Lc,Ld1
5
a
b
c
d
a
a
1
3
b
A
5
b
c
c
d
1
2
update
d
3
L
minLa,LdAd,a min1, 81
minLc,LdAd,c min5,33
6
Step 2 select the next vertex and edge
a
b
c
d
a
a
1
3
b
A
5
b
c
c
d
1
2
d
L
Pick a minimum weighted edge from the source b ?
minLa,Lc1
7
a
b
c
d
a
a
1
3
b
A
5
b
c
c
update
d
1
2
d
L
minLc,LaAa,c min3,43
8
Step 3 select the next vertex and edge
a
b
c
d
a
a
1
3
b
A
5
b
c
c
d
1
2
d
L
Pick a minimum weighted edge from the source b ?
minLc3
9
Final Shortest Paths
a
b
c
d
a
a
1
3
b
A
5
b
c
c
d
1
2
d
L
10
Time complexity of Dijkstras algorithm (serial)
  • The number of steps n-1
  • Finding a minimum weighted edge in the array L in
    each step O(n)
  • The total complexity ?(n2)

11
Parallel Formulation of Dijkstras algorithm
a
b
c
d
  • Partition the adjacency matrix A and the distance
    array L into among p processors
  • Each processor handles n/p vertices.
  • Example) n 4, p 2, n/p4/2 2

a
a
b
b
c
c
d
d
processor 0
processor 1
12
Select the source
a
b
c
d
a
a
a
b
b
1
3
c
c
5
b
update
c
d
d
source
1
2
d
processor 0
processor 1
13
Step 1 select the next vertex and edge
  • Find the minimum in L by using all-to-one
    reduction
  • Store it (the next vertex) in processor 0
  • Processor 0 broadcast the next vertex to all
    other processors by using one-to-all broadcast

14
processor 0
processor 1
a
b
c
d
a
min11
min5,11
1
Ld1
3
all-to-one reduction
5
Processor 0 picks a vertex d
b
c
Processor 0 broadcasts d
1
2
d
Ld1
one-to-all broadcast
15
processor 0
processor 1
a
b
c
d
a
a
a
b
b
1
3
c
c
5
b
d
d
c
1
update
2
3
d
minLa,LdAd,a min1, 81
minLc,LdAd,c min5,33
16
Step 2 select the next vertex and edge
processor 0
processor 1
a
b
c
d
a
min11
min33
1
3
Lc3
5
all-to-one reduction
b
Processor 0 picks a vertex a
c
Processor 0 broadcasts a
1
2
d
La1
one-to-all broadcast
17
processor 0
processor 1
a
b
c
d
a
a
a
1
b
b
3
c
c
5
b
c
d
d
1
2
d
minLc,LaAa,c min3,43
18
Step 3 select the next vertex and edge
processor 0
processor 1
a
b
c
d
a
1
min ?
min33
3
Lc3
5
all-to-one reduction
b
c
Processor 0 picks a vertex c
Processor 0 broadcasts c
1
2
d
Lc3
one-to-all broadcast
19
processor 0
processor 1
Final shortest paths
a
b
c
d
a
a
a
1
b
b
3
c
c
5
b
c
d
d
1
2
d
20
Time complexity of Dijkstras algorithm
(parallel)
  • The number of steps ?(n)
  • Finding a minimum weighted edge in the array L in
    each step
  • The total complexity

computation
communication
21
Speedup and Efficiency
  • Speedup
  • Efficiency

22
Cost-optimal
  • For a cost-optical parallel formulation,
  • the cost of solving SSSP in parallel grows at
    he same rate as does the cost of the serial
    algorithm

23
All-Pairs Shortest Paths (ASP)
  • Find the shortest paths between all pairs of
    vertices
  • Dijkstras Algorithm
  • solve ASP for graphs with non-negative weights
  • Floyds algorithm
  • solve ASP for graphs with non-negative weights
  • solve ASP for graphs with negative weights
    provided there is no negative-weight cycles

24
Dijkstras all-pairs shortest path algorithm
  • Serial algorithm
  • Parallel Formulations
  • Source-partitioned
  • Source-parallel

25
Dijkstras Algorithm (serial)
  • for each vertex, use Dijkstras single-source
    shortest path algorithm
  • takes O(n3) time

a
a
a
a
1
1
1
1
3
3
3
3
5
5
5
5
b
b
b
b
c
c
c
c
1
1
1
1
2
2
2
2
d
d
d
d
26
Source-Partitioned Formulation (parallel)
  • Assign each vertex to a processor
  • Each processor executes the single-source
    shortest path algorithm

a
a
a
a
1
1
1
1
3
3
3
3
5
5
5
5
b
b
b
b
c
c
c
c
1
1
1
1
2
2
2
2
d
d
d
d
p0
p1
p2
p3
27
Source-Partitioned Speedup and Efficiency
  • The parallel run time
  • Speedup
  • Efficiency if p ?(n)

28
Source-Parallel Formulation (parallel)
  • Assign each vertex to a set of processors
  • p/n processors, p gt n
  • The set of p/n processors executes the
    single-source shortest path algorithm
  • example) p 8, n 4, each group has p/n 2
    processors, where n is the number of vertices

p0
p1
p2
p3
p4
p5
p6
p7
group 1
group 2
group 3
group 4
29
Dijkstras single-source shortest paths
performed by two processors p2, p3.
source
a
a
a
a
1
1
1
1
source
3
3
3
3
5
5
5
5
b
b
b
b
c
c
c
c
source
1
1
1
1
2
2
2
2
d
d
d
d
source
group 1
group 2
group 3
group 4
p0
p1
p2
p3
p4
p5
p6
p7
30
Source-Parallel Time complexity
  • The parallel run time
  • Assume that in the parallel formulation of
    Djikstras single source shortest path
    algorithm, the number of processor is m.
  • The time complexity is
  • In source-parallel formulation, m p/n

m p/n
31
Source-Parallel Speedup and Efficiency
  • Speedup
  • Efficiency
  • For cost-optimal
Write a Comment
User Comments (0)
About PowerShow.com