# Two-level heaps: a new priority queue structure with applications to the single source shortest path problem

- 101 Downloads

## Abstract

The single source shortest paths problem with positive edge weights (SSSPP) is one of the more widely studied problems in operations research and theoretical computer science, on account of its wide applicability to practical situations. This problem was first solved in polynomial time by Dijkstra, who showed that by extracting vertices with the smallest distance from the source and relaxing its outgoing edges, the shortest path to each vertex is obtained. Variations of this general theme have led to a number of algorithms which work well in practice. At the heart of a Dijkstra implementation is the technique used to implement a priority queue. It is well known that using Dijkstra’s approach requires Ω(*n* log *n*) steps on a graph having *n* vertices, since it essentially sorts vertices based on their distances from the source. Accordingly, the fastest implementation of Dijkstra’s algorithm on a graph with *n* vertices and *m* edges should take Ω(*m* + *n* · log *n*) time, and consequently, the Dijkstra procedure for SSSPP using Fibonacci Heaps is optimal in the comparison-based model. In this paper, we introduce a new data structure to implement priority queues called two-level heap (TLH) and a new variant of Dijkstra’s algorithm called *Phased Dijkstra*. We contrast the performance of Dijkstra’s algorithm (both the simple and the phased variants) using a number of data structures to implement the priority queue and empirically establish that TLH are far superior to Fibonacci heaps on every graph family considered. It is to be noted that our profiling includes both sparse and dense graphs.

## Keywords

Single source shortest path Dijkstra’s algorithm Priority queues Two-level heaps Edge relaxation## Mathematics Subject Classification (2000)

68P05 68Q25 68R99 68W40## References

- 1.Ahuja RK, Mehlhorn K, Orlin JB, Tarjan RE (1990) Faster algorithms for the shortest path problem. J ACM 37(2): 213–223MATHCrossRefMathSciNetGoogle Scholar
- 2.Brodnik A, Carlsson S, Karlsson J, Ian Munro J (2001) Worst case constant time priority queue. In: Proceedings of the twelfth annual ACM-SIAM symposium on discrete algorithms (SODA-01), pp 523–528. ACM Press, New YorkGoogle Scholar
- 3.Chakrabarti D, Zhan Y, Faloutsos C (2004) R-MAT: a recursive model for graph mining. In: Proceedings of 4th SIAM international conference on data mining, FL, USAGoogle Scholar
- 4.Cherkassky BV, Goldberg AV, Radzik T (1996) Shortest paths algorithms: theory and experimental evaluation. Math Program 73: 129–174MathSciNetGoogle Scholar
- 5.Cormen TH, Leiserson CE, Rivest RL, Stein C (2001) Introduction to algorithms. MIT Press, USAMATHGoogle Scholar
- 6.Costa LA, Geiger D, Gupta A, Vlontozos J (1995) Dynamic programming for detecting, tracking and matching elastic contours. IEEE Trans Pattern Anal Mach Intell 17(3): 294–302CrossRefGoogle Scholar
- 7.Cox IJ, Rao SB, Zhong Y (1996) Ration regions: a technique for image segmentation. In: Proceedings of the international conference on pattern recognition, pp 557–564Google Scholar
- 8.Demetrescu C, Goldberg AV, Johnson D (2005) 9th DIMACS implementation challenge: shortest paths. http://www.dis.uniroma1.it/~challenge9/
- 9.Dijkstra EW (1959) A note on two problems in connexion with graphs. Numer Math 1: 269–271MATHCrossRefMathSciNetGoogle Scholar
- 10.Frederickson GN (1987) Fast algorithms for shortest paths in planar graphs, with applications. SIAM J Comput 16(6): 1004–1022MATHCrossRefMathSciNetGoogle Scholar
- 11.Goldberg AV (1996) Network optimization library. http://www.avglab.com/andrew/soft.html
- 12.Goldberg AV (2001) Shortest path algorithms: engineering aspects. In: ISAAC 2001: Proceedings 12th international symposium on algorithms and computation, pp 502–513. Springer, LondonGoogle Scholar
- 13.Johnson DB (1977) Efficient algorithms for shortest paths in sparse networks. J ACM 24(1): 1–13MATHCrossRefGoogle Scholar
- 14.LaMarca A, Ladner RE (1996) The influence of caches on the performance of heaps. ACM JEA 1(4). http://www.jea.acm.org/1996/LaMarcaInfluence/
- 15.Meyer U (2001) Single-source shortest-paths on arbitrary directed graphs in linear average-case time. In: Proceedings of the twelfth annual ACM-SIAM symposium on discrete algorithms (SODA-01), pp 797–806. ACM Press, New YorkGoogle Scholar
- 16.Oberhauser G, Simha R (1995) Fast data structures for shortest path routing: a comparative evaluation. In: Proceedings of IEEE conference communications, vol 95, pp 1597–1601, Seattle, WA, June 1995Google Scholar
- 17.Park J, Penner M, Prasanna VK (2002) Optimizing graph algorithms for improved cache performance. In: Proceedings of international parallel and distributed processing symposium (IPDPS 2002), Fort Lauderdale, FL, April 2002Google Scholar
- 18.Ramalingam G, Reps TW (1996) An incremental algorithm for a generalization of the shortest-path problem. J Algorithm 21(2): 267–305MATHCrossRefMathSciNetGoogle Scholar
- 19.Ramalingam G, Reps TW (1996) On the computational complexity of dynamic graph problems. Theor Comput Sci 158(1, 2): 233–277MATHCrossRefMathSciNetGoogle Scholar
- 20.Raman R (1997) Recent results in single-source shortest paths problem. SIGACT News 28: 81–87CrossRefGoogle Scholar
- 21.Raman R (1996) Priority queues: small, monotone and trans-dichotomous. In: ESA, pp 121–137Google Scholar
- 22.Sanders P (2000) Fast priority queues for cached memory. ACM JEA 5(7). http://www.jea.acm.org/2000/SandersPriority/
- 23.Subramani K, Kovalchick L (2005) A greedy strategy for detecting negative cost cycles in networks. Future Generat Comput Syst 21(4): 607–623CrossRefGoogle Scholar
- 24.Thorup M (1997) Undirected single source shortest path in linear time. In: Proceedings of the 38th annual symposium on foundations of computer science (FOCS-97), pp 12–21. IEEE Computer Society Press, Los Alamitos, October 20–22, 1997Google Scholar
- 25.Thorup M (1996) On RAM priority queues. In: Proceedings of the 7th annual ACM-SIAM symposium on discrete algorithms, SODA’96 (Atlanta, Georgia, January 28–30, 1996), pp 59–67. ACM SIGACT, SIAM, Society for Industrial and Applied Mathematics, Philadelphia, PAGoogle Scholar
- 26.Wang C, Ivancic F, Ganai MK, Gupta A (2005) Deciding separation logic formulae by sat and incremental negative cycle elimination. In: LPAR, pp 322–336Google Scholar