Document Open Access Logo

A Streaming Algorithm for the Undirected Longest Path Problem

Authors Lasse Kliemann, Christian Schielke, Anand Srivastav

Thumbnail PDF


  • Filesize: 0.59 MB
  • 17 pages

Document Identifiers

Author Details

Lasse Kliemann
Christian Schielke
Anand Srivastav

Cite AsGet BibTex

Lasse Kliemann, Christian Schielke, and Anand Srivastav. A Streaming Algorithm for the Undirected Longest Path Problem. In 24th Annual European Symposium on Algorithms (ESA 2016). Leibniz International Proceedings in Informatics (LIPIcs), Volume 57, pp. 56:1-56:17, Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2016)


We present the first streaming algorithm for the longest path problem in undirected graphs. The input graph is given as a stream of edges and RAM is limited to only a linear number of edges at a time (linear in the number of vertices n). We prove a per-edge processing time of O(n), where a naive solution would have required Omega(n^2). Moreover, we give a concrete linear upper bound on the number of bits of RAM that are required. On a set of graphs with various structure, we experimentally compare our algorithm with three leading RAM algorithms: Warnsdorf (1823), Pohl-Warnsdorf (1967), and Pongrasz (2012). Although conducting only a small constant number of passes over the input, our algorithm delivers competitive results: with the exception of preferential attachment graphs, we deliver at least 71% of the solution of the best RAM algorithm. The same minimum relative performance of 71% is observed over all graph classes after removing the 10% worst cases. This comparison has strong meaning, since for each instance class there is one algorithm that on average delivers at least 84% of a Hamilton path. In some cases we deliver even better results than any of the RAM algorithms.
  • Streaming Algorithms
  • Undirected Longest Path Problem
  • Graph Algorithms
  • Combinatorial Optimization


  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    PDF Downloads


  1. Noga Alon, Raphael Yuster, and Uri Zwick. Color-coding. Journal of the ACM, 42(4):844-856, 1995. URL:
  2. Ziv Bar-Yossef, Ravi Kumar, and D. Sivakumar. Reductions in streaming algorithms, with an application to counting triangles in graphs. In Proceedings of the 13th Annual ACM-SIAM Symposium on Discrete Algorithms, San Francisco, CA, USA, January 2002 (SODA 2002), pages 623-632, 2002. URL:
  3. Albert-László Barabási and Réka Albert. Emergence of scaling in random networks. Science, 286(5439):509-512, 1999. URL:
  4. Cristina Bazgan, Miklos Santha, and Zsolt Tuza. On the approximation of finding a(nother) Hamiltonian cycle in cubic Hamiltonian graphs. Journal of Algorithms, 31(1):249-268, 1999. Conference version at STACS 1998. URL:
  5. Andreas Björklund. Determinant sums for undirected Hamiltonicity. SIAM Journal on Computing, 43(1):280-299, 2014. Conference version at FOCS 2010. URL:
  6. Andreas Björklund and Thore Husfeldt. Finding a path of superlogarithmic length. SIAM Journal on Computing, 32(6):1395-1402, 2003. URL:
  7. Andreas Björklund, Thore Husfeldt, Petteri Kaski, and Mikko Koivisto. Narrow sieves for parameterized paths and packings, 2010. URL:
  8. Andreas Björklund, Thore Husfeldt, and Sanjeev Khanna. Approximating longest directed paths and cycles. In Proceedings of the 31st International Colloquium on Automata, Languages and Programming, Turku, Finland, July 2004 (ICALP 2004), pages 222-233, 2004. URL:
  9. Hans L. Bodlaender. On linear time minor tests with depth-first search. Journal of Algorithms, 14:1-23, 1993. Conference version at WADS 1989. URL:
  10. R.W. Bulterman, F.W. van der Sommen, G. Zwaan, T. Verhoeff, A.J.M. van Gasteren, and W.H.J. Feijen. On computing a longest path in a tree. Information Processing Letters, 81(2):93-96, 2002. URL:
  11. Tomás Feder, Rajeev Motwani, and Carlos Subi. Approximating the longest cycle problem in sparse graphs. SIAM Journal on Computing, 31(5):1596-1607, 2002. URL:
  12. Joan Feigenbaum, Sampath Kannan, Andrew McGregor, Siddharath Suri, and Jian Zhang. On graph problems in a semi-streaming model. Theoretical Computer Science, 348:207-216, 2005. Conference version at ICALP 2004. URL:
  13. Joan Feigenbaum, Sampath Kannan, Andrew McGregor, Siddharath Suri, and Jian Zhang. Graph distances in the data-stream model. SIAM Journal on Computing, 38:1709–1727, 2008. URL:
  14. Harold N. Gabow. Finding paths and cycles of superpolylogarithmic length. SIAM Journal on Computing, 36(6):1648-1671, 2007. URL:
  15. Harold N. Gabow and Shuxin Nie. Finding long paths, cycles and circuits. In Proceedings of the 19th International Symposium on Algorithms and Computation, Gold Coast, Australia, December 2008 (ISAAC 2008), pages 752-753, 2008. URL:
  16. Venkatesan Guruswami and Krzysztof Onak. Superlinear lower bounds for multipass graph processing. Electronic Colloquium on Computational Complexity, 2014. Conference version at CCC 2013. URL:
  17. David Karger, Rajeev Motwani, and G.D.S. Ramkumar. On approximating the longest path in a graph. Algorithmica, 18:82-98, 1997. URL:
  18. Fatemeh Keshavarz-Kohjerdia, Alireza Bagherib, and Asghar Asgharian-Sardroudb. A linear-time algorithm for the longest path problem in rectangular grid graphs. Discrete Applied Mathematics, 160(3):210-217, 2012. URL:
  19. Ioannis Koutis. Faster algebraic algorithms for path and packing problems. In Proceedings of the 35th International Colloquium on Automata, Languages and Programming, Reykjavik, Iceland, July 2008 (ICALP 2008), pages 575-586, 2008. URL:
  20. Dmitri Krioukov, Fragkiskos Papadopoulos, Maksim Kitsak, Amin Vahdat, and Marián Boguñá. Hyperbolic geometry of complex networks. Physical Review E, 82, 2010. URL:
  21. Minko Markov, Mugurel Ionuţ Andreica, Krassimir Manev, and Nicolae Ţăpuş. A linear time algorithm for computing longest paths in cactus graphs. Serdica Journal of Computing, 6(3), 2012. URL:
  22. Burkhard Monien. How to find long paths efficiently. Annals of Discrete Mathematics, 25:239-254, 1985. URL:
  23. Muthu Muthukrishnan. Data streams: Algorithms and applications. Foundations and Trends in Theoretical Computer Science, 1(2):67 pages, 2005. URL:
  24. Ira Pohl. A method for finding Hamilton paths and knight’s tours. Communications of the ACM, 10(7):446-449, 1967. URL:
  25. Ira Pohl and Larry Stockmeyer. Pohl-Warnsdorf - revisited. In Proceedings of the International Conference on Intelligent Systems and Control, Honolulu, Hawaii, USA, August 2004 (ISC 2004), 2004. URL:
  26. Lajos L. Pongrácz. A greedy approximation algorithm for the longest path problem in undirected graphs, 2012. URL:
  27. Robert Sedgewick and Kevin Wayne. Algorithms. Addison-Wesley Professional, 2011. Google Scholar
  28. Ryuhei Uehara and Yushi Uno. On computing longest paths in small graph classes. International Journal of Foundations of Computer Science, 18(5), 2007. URL:
  29. Sundar Vishwanathan. An approximation algorithm for finding long paths in Hamiltonian graphs. Journal of Algorithms, 50(2):246–256, 2004. Conference version at SODA 2000. URL:
  30. Moritz von Looz, Christian L. Staudt, Henning Meyerhenke, and Roman Prutkin. Fast generation of complex networks with underlying hyperbolic geometry, 2015. URL:
  31. Duncan J. Watts and Steven H. Strogatz. Collective dynamics of ’small-world' networks. Nature, 393:440-442, 1998. URL:
  32. Ryan Williams. Finding paths of length k in O^*(2^k) time. Information Processing Letters, 109:315-318, 2009. URL:
Questions / Remarks / Feedback

Feedback for Dagstuhl Publishing

Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail