Skip to main content
Log in

Space-Efficient DFS and Applications to Connectivity Problems: Simpler, Leaner, Faster

  • Published:
Algorithmica Aims and scope Submit manuscript

Abstract

The problem of space-efficient depth-first search (DFS) is reconsidered. A particularly simple and fast algorithm is presented that, on a directed or undirected input graph \(G=(V,E)\) with n vertices and m edges, carries out a DFS in \(O(n+m)\) time with \(n+\sum _{v\in V_{\ge 3}}\lceil \log _2(d_v-1)\rceil +O(\log n)\le n+m+O(\log n)\) bits of working memory, where \(d_v\) is the (total) degree of v, for each \(v\in V\), and \(V_{\ge 3}=\{v\in V\mid d_v\ge 3\}\). A slightly more complicated variant of the algorithm works in the same time with at most \(n+({4/5})m+O(\log n)\) bits. It is also shown that a DFS can be carried out in a graph with n vertices and m edges in \(O(n+m+\min \{n,m\}\log ^*\!n)\) time with O(n) bits or in \(O(n+m)\) time with either \(O(n\log \log (4+{m/n}))\) bits or, for arbitrary integer \(k\ge 1\), \(O(n\log ^{(k)}\! n)\) bits. These results among them subsume or improve most earlier results on space-efficient DFS. Some of the new time and space bounds are shown to extend to applications of DFS such as the computation of cut vertices, bridges, biconnected components and 2-edge-connected components in undirected graphs.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1

Similar content being viewed by others

References

  1. Aho, A.V., Hopcroft, J.E., Ullman, J.D.: Data Structures and Algorithms. Addison-Wesley, Reading, Massachusetts (1983)

    MATH  Google Scholar 

  2. Asano, T., Izumi, T., Kiyomi, M., Konagaya M., Ono, H., Otachi, Y., Schweitzer, P., Tarui, J., Uehara, R.: Depth-first search using \(O(n)\) bits. In: Proceedings of the 25th International Symposium on Algorithms and Computation (ISAAC 2014), volume 8889 of LNCS, pp. 553–564. Springer (2014)

  3. Banerjee, N., Chakraborty, S., Raman, V., Satti, S.R.: Space efficient linear time algorithms for BFS, DFS and applications. Theory Comput. Syst. 62(8), 1736–1762 (2018)

    Article  MathSciNet  Google Scholar 

  4. Baumann, T., Hagerup, T.: Rank-select indices without tears. In: Proceedings of the 16th International Symposium on Algorithms and Data Structures (WADS 2019), volume 11646 of LNCS, pp. 85–98. Springer (2019)

  5. Chakraborty, S., Raman, V., Satti, S.R.: Biconnectivity, \(s t\)-numbering and other applications of DFS using \(O(n)\) bits. J. Comput. Syst. Sci. 90, 63–79 (2017)

    Article  MathSciNet  Google Scholar 

  6. Choudhari, J., Gupta, M., Sharma, S.: Nearly optimal space efficient algorithm for depth first search. Computing Research Repository (CoRR), arXiv:1810.07259 [cs.DS] (2018)

  7. Clark, D.: Compact Pat Trees. Ph.D. thesis, University of Waterloo (1996)

  8. Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C.: Introduction to Algorithms, 3rd edn. The MIT Press, Cambridge (2009)

    MATH  Google Scholar 

  9. Dodis, Y., Pǎtraşcu, M., Thorup, M.: Changing base without losing space. In: Proceedings of the 42nd ACM Symposium on Theory of Computing (STOC 2010), pp. 593–602. ACM (2010)

  10. Elmasry, A., Hagerup, T., Kammer, F.: Space-efficient basic graph algorithms. In: Proceedings of the 32nd International Symposium on Theoretical Aspects of Computer Science (STACS 2015), volume 30 of LIPIcs, pp. 288–301. Schloss Dagstuhl–Leibniz–Zentrum für Informatik (2015)

  11. Gabow, H.N.: Path-based depth-first search for strong and biconnected components. Inf. Process. Lett. 74(3–4), 107–114 (2000)

    Article  MathSciNet  Google Scholar 

  12. Golynski, A.: Optimal lower bounds for rank and select indexes. Theor. Comput. Sci. 387(3), 348–359 (2007)

    Article  MathSciNet  Google Scholar 

  13. Hagerup, T.: An optimal choice dictionary. Computing Research Repository (CoRR), arXiv:1711.00808 [cs.DS] (2017)

  14. Hagerup, T.: Space-efficient DFS and applications: Simpler, leaner, faster. Computing Research Repository (CoRR), arXiv:1805.11864 [cs.DS] (2018)

  15. Hagerup, T., Kammer, F.: Succinct choice dictionaries. Computing Research Repository (CoRR), arXiv:1604.06058 [cs.DS] (2016)

  16. Hagerup, T., Kammer, F., Laudahn, M.: Space-efficient Euler partition and bipartite edge coloring. Theor. Comput. Sci. 754, 16–34 (2019)

    Article  MathSciNet  Google Scholar 

  17. Kammer, F., Kratsch, D., Laudahn, M.: Space-efficient biconnected components and recognition of outerplanar graphs. In: Proceedings of the 41st International Symposium on Mathematical Foundations of Computer Science (MFCS 2016), volume 58 of LIPIcs, pp. 56:1–56:14. Schloss Dagstuhl–Leibniz–Zentrum für Informatik (2016)

  18. Raman, R., Raman, V., Satti, S.R.: Succinct indexable dictionaries with applications to encoding \(k\)-ary trees, prefix sums and multisets. ACM Trans. Algorithms 3(4), 43:1–43:25 (2007)

  19. Savitch, W.J.: Relationships between nondeterministic and deterministic tape complexities. J. Comput. Syst. Sci. 4(2), 177–192 (1970)

    Article  MathSciNet  Google Scholar 

  20. Schmidt, J.M.: A simple test on 2-vertex- and 2-edge-connectivity. Inf. Process. Lett. 113(7), 241–244 (2013)

    Article  MathSciNet  Google Scholar 

  21. Tarjan, R.: Depth-first search and linear graph algorithms. SIAM J. Comput. 1(2), 146–160 (1972)

    Article  MathSciNet  Google Scholar 

  22. Vigna, S.: Broadword implementation of rank/select queries. In: Proceedings of the 7th International Workshop on Experimental Algorithms (WEA 2008), volume 5038 of LNCS, pp. 154–168. Springer (2008)

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Torben Hagerup.

Additional information

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Hagerup, T. Space-Efficient DFS and Applications to Connectivity Problems: Simpler, Leaner, Faster. Algorithmica 82, 1033–1056 (2020). https://doi.org/10.1007/s00453-019-00629-x

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s00453-019-00629-x

Keywords

Navigation