Universal Optimality of Dijkstra via Beyond-Worst-Case Heaps

Bernhard Haeupler,Richard Hladík,Václav Rozhoň,Robert Tarjan,Jakub Tětek
2024-10-28
Abstract:This paper proves that Dijkstra's shortest-path algorithm is universally optimal in both its running time and number of comparisons when combined with a sufficiently efficient heap data structure. Universal optimality is a powerful beyond-worst-case performance guarantee for graph algorithms that informally states that a single algorithm performs as well as possible for every single graph topology. We give the first application of this notion to any sequential algorithm. We design a new heap data structure with a working-set property guaranteeing that the heap takes advantage of locality in heap operations. Our heap matches the optimal (worst-case) bounds of Fibonacci heaps but also provides the beyond-worst-case guarantee that the cost of extracting the minimum element is merely logarithmic in the number of elements inserted after it instead of logarithmic in the number of all elements in the heap. This makes the extraction of recently added elements cheaper. We prove that this working-set property guarantees universal optimality for the problem of ordering vertices by their distance from the source vertex: The sequence of heap operations generated by any run of Dijkstra's algorithm on a fixed graph possesses enough locality that one can couple the number of comparisons performed by any heap with our working-set bound to the minimum number of comparisons required to solve the distance ordering problem on this graph for a worst-case choice of arc lengths.
Data Structures and Algorithms
What problem does this paper attempt to address?
The problem this paper attempts to address is to demonstrate that Dijkstra's shortest path algorithm, when combined with a sufficiently efficient heap data structure, possesses universal optimality not only in terms of running time but also in terms of the number of comparisons. Universal optimality is a performance guarantee that goes beyond the worst-case scenario, informally indicating that an algorithm can achieve optimal performance on every type of graph topology. This is the first time this concept has been applied to a standard algorithm in the sequential computation model. Specifically, the paper designs a new heap data structure that has the working-set property, which can exploit the locality of heap operations. This new heap data structure matches the optimal bounds of Fibonacci heaps in the worst case while providing guarantees beyond the worst case. That is, the cost of extracting the minimum element is logarithmic in the number of elements inserted after it, rather than logarithmic in the total number of elements in the heap. This results in a lower extraction cost for recently inserted elements. With this new heap data structure, the paper proves that the sequence of heap operations generated during the execution of Dijkstra's algorithm on any fixed graph has sufficient locality. This allows coupling the number of comparisons of any heap with its working-set bounds, achieving the minimum number of comparisons required to solve the distance ordering problem. Additionally, the paper proposes a variant of Dijkstra's algorithm that is universally optimal in both time complexity and the number of comparisons. It also proves that several natural priority queue implementations (such as the standard Fibonacci heap or splay trees) cannot make Dijkstra's algorithm achieve universal optimality.