Successfully reported this slideshow.

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

6

Share

1 of 158
1 of 158

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

6

Share

Download to read offline

Mikkel Thorup found the first deterministic algorithm to solve the classic single-source shortest paths problem for undirected graphs with positive integer weights in linear time and space. The algorithm requires a hierarchical bucketing structure for identifying the order the vertices have to be visited in without breaking this time bound, thus avoiding the sorting bottleneck of the algorithm proposed by Dijkstra in 1959.

Mikkel Thorup found the first deterministic algorithm to solve the classic single-source shortest paths problem for undirected graphs with positive integer weights in linear time and space. The algorithm requires a hierarchical bucketing structure for identifying the order the vertices have to be visited in without breaking this time bound, thus avoiding the sorting bottleneck of the algorithm proposed by Dijkstra in 1959.

More Related Content

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

  1. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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

×