practical performance comparison of all pairs shortest
play

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


  1. Practical performance comparison of all-pairs shortest path algorithms Andrej Brodnik Marko Grgurovič University of Primorska University of Primorska University of Ljubljana

  2. Problem • Directed graphs. • Non-negative edge lengths. • Find shortest paths between every pair of vertices (APSP). 2

  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

  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

  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

  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

  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

  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

  9. Algorithms: Uniform Paths [Demetrescu et a l., ’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

  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

  11. Algorithms: Propagation Consider vertex 𝑤 . • Red = pointers (blue = out. edges for 𝑤 ) • • A pointer is moved right if the element pointed to is not viable (shorter path known). 1 𝑟 𝑟, 0 | $ 5 𝑣 𝑤 𝑣, 0 | $ 𝑤, 0 | $ 3 1 𝑥 𝑥, 0 | $ 11

  12. Algorithms: Propagation • i=1, running 1 𝑟 𝑟, 0 | $ 5 𝑣 𝑤 Cand: (u,5) 𝑣, 0 | $ 𝑤, 0 | $ 3 1 𝑥 Cand: (w,3) 𝑥, 0 | $ 12

  13. Algorithms: Propagation • i=1, running 1 𝑟 𝑟, 0 | $ 5 𝑣 𝑤 Cand: (u,5) 𝑣, 0 | $ 𝑤, 0 | $ 3 1 𝑥 Cand: (w,3) 𝑥, 0 | $ 13

  14. Algorithms: Propagation • i=1, finished 1 𝑟 𝑟, 0 | 𝑤, 2 | $ 5 𝑣 𝑤 𝑣, 0 | 𝑟, 1 | $ 𝑤, 0 | 𝑥, 3 | $ 3 1 𝑥 𝑥, 0 | 𝑣, 1 | $ 14

  15. Algorithms: Propagation • i=2, running 1 𝑟 𝑟, 0 | 𝑤, 2 | $ 5 𝑣 𝑤 Cand: (u,5) 𝑣, 0 | 𝑟, 1 | $ 𝑤, 0 | 𝑥, 3 | $ 3 1 𝑥 Not viable. 𝑥, 0 | 𝑣, 1 | $ 15

  16. Algorithms: Propagation • i=2, running 1 𝑟 𝑟, 0 | 𝑤, 2 | $ 5 𝑣 𝑤 Cand: (u,5) 𝑣, 0 | 𝑟, 1 | $ 𝑤, 0 | 𝑥, 3 | $ 3 1 𝑥 Cand: (u,4) 𝑥, 0 | 𝑣, 1 | $ 16

  17. Algorithms: Propagation • i=2, running 1 𝑟 𝑟, 0 | 𝑤, 2 | $ 5 𝑣 𝑤 Cand: (u,5) 𝑣, 0 | 𝑟, 1 | $ 𝑤, 0 | 𝑥, 3 | $ 3 1 𝑥 Cand: (u,4) 𝑥, 0 | 𝑣, 1 | $ 17

  18. Algorithms: Propagation • i=2, finished 1 𝑟 𝑟, 0 | 𝑤, 2 | (𝑥, 5) $ 5 𝑣 𝑤 𝑣, 0 | 𝑟, 1 | (𝑤, 3) $ 𝑤, 0 | 𝑥, 3 | (𝑣, 4) $ 3 1 𝑥 𝑥, 0 | 𝑣, 1 | (𝑟, 2) $ 18

  19. Algorithms: Propagation • What about when the k -th shortest path depends on a neighbors k -th shortest path? 𝑣 𝑤 … | (𝑤 𝑙−2 , 𝜀 𝑙−2 ) | (𝑤 𝑙−1 , 𝜀 𝑙−1 ) |$ … … … … … … … … . 𝑥 … | (𝑤 𝑙−2 , 𝜀 𝑙−2 ) | (𝑤 𝑙−1 , 𝜀 𝑙−1 ) |$ 19

  20. Algorithms: Propagation • What about when the k -th shortest path depends on a neighbors k -th shortest path? Not viable. 𝑣 𝑤 … | (𝑤 𝑙−2 , 𝜀 𝑙−2 ) | (𝑤 𝑙−1 , 𝜀 𝑙−1 ) |$ … … … … … … … … . Not viable. 𝑥 … | (𝑤 𝑙−2 , 𝜀 𝑙−2 ) | (𝑤 𝑙−1 , 𝜀 𝑙−1 ) |$ 20

  21. Algorithms: Propagation • What about when the k -th shortest path depends on a neighbors k -th shortest path? Not viable. 𝑣 𝑤 … | (𝑤 𝑙−2 , 𝜀 𝑙−2 ) | (𝑤 𝑙−1 , 𝜀 𝑙−1 ) |$ … … … … … … … … . Cand. found 𝑥 … | (𝑤 𝑙−2 , 𝜀 𝑙−2 ) | (𝑤 𝑙−1 , 𝜀 𝑙−1 ) |$ 21

  22. Algorithms: Propagation • What about when the k -th shortest path depends on a neighbors k -th shortest path? ??? 𝑣 𝑤 … | (𝑤 𝑙−2 , 𝜀 𝑙−2 ) | (𝑤 𝑙−1 , 𝜀 𝑙−1 ) |$ … … … … … … … … . Cand. found 𝑥 … | (𝑤 𝑙−2 , 𝜀 𝑙−2 ) | (𝑤 𝑙−1 , 𝜀 𝑙−1 ) |$ 22

  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

  24. Experiments • Implemented in C++. • Ran on an i7-3930K@3.20GHz with 64GB RAM on 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

  25. 25

  26. 26

  27. Thanks for your attention!

  28. Questions

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend