Practical performance comparison of all-pairs shortest path - - PowerPoint PPT Presentation

β–Ά
practical performance comparison of all pairs shortest
SMART_READER_LITE
LIVE PREVIEW

Practical performance comparison of all-pairs shortest path - - PowerPoint PPT Presentation

Practical performance comparison of all-pairs shortest path algorithms Andrej Brodnik Marko Grgurovi University of Primorska University of Primorska University of Ljubljana Problem Directed graphs. Non-negative edge lengths. Find


slide-1
SLIDE 1

Practical performance comparison

  • f all-pairs shortest path algorithms

Andrej Brodnik

University of Primorska University of Ljubljana

Marko Grgurovič

University of Primorska

slide-2
SLIDE 2

Problem

  • Directed graphs.
  • Non-negative edge lengths.
  • Find shortest paths between every pair of

vertices (APSP).

2

slide-3
SLIDE 3

Algorithms: Floyd-Warshall

  • Standard dynamic programming formulation.

FOR k=1 to n FOR i=1 to n FOR j=1 to n W[i,j] = MIN(W[i,j], W[i,k]+W[k,j]) ENDFOR ENDFOR ENDFOR

3

slide-4
SLIDE 4

Algorithms: Floyd-Warshall

  • Standard dynamic programming formulation.

FOR k=1 to n FOR i=1 to n IF (W[i,k] == ∞) continue; FOR j=1 to n W[i,j] = MIN(W[i,j], W[i,k]+W[k,j]); ENDFOR ENDFOR ENDFOR

4

slide-5
SLIDE 5

Algorithms: Dijkstra

  • A single-source algorithm.
  • Visits vertices in increasing distance from

source.

  • Solves APSP as separate single-source

problems.

  • Use priority queues (PQ) for best result.

5

slide-6
SLIDE 6

Algorithms: Dijkstra

  • Let a candidate (shortest) path be any path

satisfying some condition C.

  • Dijkstra-like algorithms will push candidate

paths into a PQ and pop to retrieve the next shortest path.

  • E.g. (Dijkstra) extend a path 𝜌 with (u,v) if:

– 𝜌 is empty – 𝜌 is a known shortest path

6

slide-7
SLIDE 7

Algorithms: Hidden Paths

[Karger et al., ’94]

  • Modifies Dijkstra to solve APSP.
  • Use a single large PQ and discover paths in

increasing distance from any source.

  • Key idea: extend a path 𝜌 with (u,v) if:

– 𝜌 is empty – 𝜌 and {(u,v)} are known shortest paths.

7

slide-8
SLIDE 8

Algorithms: Hidden Paths

  • Running time is 𝑃 π‘›βˆ—π‘œ + π‘œ2 lg π‘œ
  • π‘›βˆ— is the number of essential edges.

– Any non-essential edge can be removed from G, and the APSP solution will be the same. – π‘›βˆ— = 𝑃 π‘œ lg π‘œ in expectation and whp in complete graphs with random weights. [Hassin & Zemel, ’85]

8

slide-9
SLIDE 9

Algorithms: Uniform Paths

[Demetrescu et al., ’04]

  • Very similar to Hidden Paths.
  • Stricter condition: extend a path 𝜌 with (u,v) if:

– 𝜌 is empty – Every proper subpath of 𝜌 + (u,v) is a shortest path.

  • |UP| = number of paths whose proper subpaths

are shortest paths.

  • Runs in 𝑃 𝑉𝑄 + π‘œ2 lg π‘œ
  • |UP| = 𝑃 π‘œ2 in expectation and whp in complete graphs

with random weights. [Peres et al., ’10]

9

slide-10
SLIDE 10

Algorithms: Propagation

[Brodnik & G., ’12]

  • General idea: each vertex is allowed to

examine the (sorted by distance) shortest path lists of its neighbors, but nothing else!

  • At each step of the algorithm, one shortest

path for each vertex is discovered (in increasing distance from source).

10

slide-11
SLIDE 11

11

𝑀 𝑀, 0 | $ 𝑣 π‘₯ π‘Ÿ π‘Ÿ, 0 | $ 𝑣, 0 | $ π‘₯, 0 | $ 1 5 3 1

  • Consider vertex 𝑀.
  • Red = pointers (blue = out. edges for 𝑀)
  • A pointer is moved right if the element

pointed to is not viable (shorter path known).

Algorithms: Propagation

slide-12
SLIDE 12

12

  • i=1, running

Cand: (u,5) Cand: (w,3)

Algorithms: Propagation

𝑀 𝑀, 0 | $ 𝑣 π‘₯ π‘Ÿ π‘Ÿ, 0 | $ 𝑣, 0 | $ π‘₯, 0 | $ 1 5 3 1

slide-13
SLIDE 13

13

  • i=1, running

Cand: (u,5) Cand: (w,3)

Algorithms: Propagation

𝑀 𝑀, 0 | $ 𝑣 π‘₯ π‘Ÿ π‘Ÿ, 0 | $ 𝑣, 0 | $ π‘₯, 0 | $ 1 5 3 1

slide-14
SLIDE 14

14

  • i=1, finished

Algorithms: Propagation

𝑀 𝑣 π‘₯ π‘Ÿ 1 5 3 1 𝑀, 0 | π‘₯, 3 | $ 𝑣, 0 | π‘Ÿ, 1 | $ π‘₯, 0 | 𝑣, 1 | $ π‘Ÿ, 0 | 𝑀, 2 | $

slide-15
SLIDE 15

15

𝑀 𝑣 π‘₯ π‘Ÿ 1 5 3 1 𝑀, 0 | π‘₯, 3 | $ 𝑣, 0 | π‘Ÿ, 1 | $ π‘₯, 0 | 𝑣, 1 | $ π‘Ÿ, 0 | 𝑀, 2 | $

  • i=2, running

Cand: (u,5) Not viable.

Algorithms: Propagation

slide-16
SLIDE 16

16

𝑀 𝑣 π‘₯ π‘Ÿ 1 5 3 1 𝑀, 0 | π‘₯, 3 | $ 𝑣, 0 | π‘Ÿ, 1 | $ π‘₯, 0 | 𝑣, 1 | $ π‘Ÿ, 0 | 𝑀, 2 | $

Algorithms: Propagation

  • i=2, running

Cand: (u,5) Cand: (u,4)

slide-17
SLIDE 17

17

𝑀 𝑣 π‘₯ π‘Ÿ 1 5 3 1 𝑀, 0 | π‘₯, 3 | $ 𝑣, 0 | π‘Ÿ, 1 | $ π‘₯, 0 | 𝑣, 1 | $ π‘Ÿ, 0 | 𝑀, 2 | $

Algorithms: Propagation

  • i=2, running

Cand: (u,5) Cand: (u,4)

slide-18
SLIDE 18

Algorithms: Propagation

18

𝑀, 0 | π‘₯, 3 |(𝑣, 4)$ π‘Ÿ, 0 | 𝑀, 2 |(π‘₯, 5)$ 𝑣, 0 | π‘Ÿ, 1 |(𝑀, 3)$ π‘₯, 0 | 𝑣, 1 |(π‘Ÿ, 2)$

  • i=2, finished

𝑀 𝑣 π‘₯ π‘Ÿ 1 5 3 1

slide-19
SLIDE 19

Algorithms: Propagation

19

𝑀 … … … … … … … … . 𝑣 π‘₯ … |(π‘€π‘™βˆ’2, πœ€π‘™βˆ’2)|(π‘€π‘™βˆ’1, πœ€π‘™βˆ’1)|$

  • What about when the k-th shortest path

depends on a neighbors k-th shortest path?

… |(π‘€π‘™βˆ’2, πœ€π‘™βˆ’2)|(π‘€π‘™βˆ’1, πœ€π‘™βˆ’1)|$

slide-20
SLIDE 20

Algorithms: Propagation

20

𝑀 … … … … … … … … . 𝑣 π‘₯ … |(π‘€π‘™βˆ’2, πœ€π‘™βˆ’2)|(π‘€π‘™βˆ’1, πœ€π‘™βˆ’1)|$

  • What about when the k-th shortest path

depends on a neighbors k-th shortest path?

… |(π‘€π‘™βˆ’2, πœ€π‘™βˆ’2)|(π‘€π‘™βˆ’1, πœ€π‘™βˆ’1)|$ Not viable. Not viable.

slide-21
SLIDE 21

Algorithms: Propagation

21

𝑀 … … … … … … … … . 𝑣 π‘₯ … |(π‘€π‘™βˆ’2, πœ€π‘™βˆ’2)|(π‘€π‘™βˆ’1, πœ€π‘™βˆ’1)|$

  • What about when the k-th shortest path

depends on a neighbors k-th shortest path?

… |(π‘€π‘™βˆ’2, πœ€π‘™βˆ’2)|(π‘€π‘™βˆ’1, πœ€π‘™βˆ’1)|$ Not viable.

  • Cand. found
slide-22
SLIDE 22

Algorithms: Propagation

22

𝑀 … … … … … … … … . 𝑣 π‘₯ … |(π‘€π‘™βˆ’2, πœ€π‘™βˆ’2)|(π‘€π‘™βˆ’1, πœ€π‘™βˆ’1)|$

  • What about when the k-th shortest path

depends on a neighbors k-th shortest path?

… |(π‘€π‘™βˆ’2, πœ€π‘™βˆ’2)|(π‘€π‘™βˆ’1, πœ€π‘™βˆ’1)|$

  • Cand. found

???

slide-23
SLIDE 23

Algorithms: Propagation

  • Require (any) single-source algorithm to be

provided.

  • Use provided algorithm to solve the tricky

cases when they occur via reduction (on a pruned graph).

  • Overall, algorithm runs in 𝑃(π‘œπ‘ˆ

𝑑 π‘›βˆ—, π‘œ +

𝑛 lg π‘œ) where π‘ˆ

𝑑 𝑛, π‘œ is the running time of

the provided alg.

23

slide-24
SLIDE 24

Experiments

  • Implemented in C++.
  • Ran on an i7-3930K@3.20GHz with 64GB RAM
  • n Ubuntu 12.04.5 LTS.
  • Using pairing heaps for PQ from the Boost

library.

  • Generate random graphs from 512-16k

vertices with varying densities and consider:

– Unweighted – Uniform random weights in (0,1)

24

slide-25
SLIDE 25

25

slide-26
SLIDE 26

26

slide-27
SLIDE 27

Thanks for your attention!

slide-28
SLIDE 28

Questions