Faster Algorithms for Incremental Topological Ordering

  • Bernhard Haeupler
  • Telikepalli Kavitha
  • Rogers Mathew
  • Siddhartha Sen
  • Robert E. Tarjan
Part of the Lecture Notes in Computer Science book series (LNCS, volume 5125)

Abstract

We present two online algorithms for maintaining a topological order of a directed acyclic graph as arcs are added, and detecting a cycle when one is created. Our first algorithm takes O(m1/2) amortized time per arc and our second algorithm takes O(n2.5/m) amortized time per arc, where n is the number of vertices and m is the total number of arcs. For sparse graphs, our O(m1/2) bound improves the best previous bound by a factor of logn and is tight to within a constant factor for a natural class of algorithms that includes all the existing ones. Our main insight is that the two-way search method of previous algorithms does not require an ordered search, but can be more general, allowing us to avoid the use of heaps (priority queues). Instead, the deterministic version of our algorithm uses (approximate) median-finding; the randomized version of our algorithm uses uniform random sampling. For dense graphs, our O(n2.5/m) bound improves the best previously published bound by a factor of n1/4 and a recent bound obtained independently of our work by a factor of logn. Our main insight is that graph search is wasteful when the graph is dense and can be avoided by searching the topological order space instead. Our algorithms extend to the maintenance of strong components, in the same asymptotic time bounds.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Ajwani, D., Friedrich, T., Meyer, U.: An O(n 2.75) algorithm for online topological ordering. In: Arge, L., Freivalds, R. (eds.) SWAT 2006. LNCS, vol. 4059, pp. 53–64. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  2. 2.
    Alpern, B., Hoover, R., Rosen, B.K., Sweeney, P.F., Zadeck, F.K.: Incremental evaluation of computational circuits. In: SODA 1990, pp. 32–42 (1990)Google Scholar
  3. 3.
    Belik, F.: An efficient deadlock avoidance technique. IEEE Trans. on Comput. 39(7) (1990)Google Scholar
  4. 4.
    Bender, M.A., Cole, R., Demaine, E.D., Farach-Colton, M., Zito, J.: Two simplified algorithms for maintaining order in a list. In: Möhring, R.H., Raman, R. (eds.) ESA 2002. LNCS, vol. 2461, pp. 152–164. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  5. 5.
    Blum, M., Floyd, R.W., Pratt, V., Rivest, R.L., Tarjan, R.E.: Time bounds for selection. J. of Comput. and Syst. Sci. 7(4), 448–461 (1973)MathSciNetCrossRefMATHGoogle Scholar
  6. 6.
    Dietz, P.F., Sleator, D.D.: Two algorithms for maintaining order in a list. In: STOC 1987, pp. 365–372 (1987)Google Scholar
  7. 7.
    Haeupler, B., Sen, S., Tarjan, R.E.: Incremental topological ordering and strong component maintenance (2008)Google Scholar
  8. 8.
    Han, Y., Thorup, M.: Integer sorting in O(n \(\sqrt{\log \log n}\)) expected time and linear space. In: FOCS 2002, pp. 135–144 (2002)Google Scholar
  9. 9.
    Harary, F., Norman, R.Z., Cartwright, D.: Structural Models : An Introduction to the Theory of Directed Graphs. John Wiley & Sons, Chichester (1965)MATHGoogle Scholar
  10. 10.
    Katriel, I.: On algorithms for online topological ordering and sorting. Technical Report MPI-I-2004-1-003, Max-Planck-Institut für Informatik, Saarbrücken, Germany (2004)Google Scholar
  11. 11.
    Katriel, I., Bodlaender, H.L.: Online topological ordering. ACM Trans. on Algor. 2(3), 364–379 (2006)MathSciNetCrossRefMATHGoogle Scholar
  12. 12.
    Kavitha, T., Mathew, R.: Faster algorithms for online topological ordering (2007)Google Scholar
  13. 13.
    Knuth, D.E.: The Art of Computer Programming. Fundamental Algorithms, vol. 1. Addison-Wesley, Reading (1973)MATHGoogle Scholar
  14. 14.
    Knuth, D.E., Szwarcfiter, J.L.: A structured program to generate all topological sorting arrangements. Inf. Proc. Lett. 2(6), 153–157 (1974)CrossRefMATHGoogle Scholar
  15. 15.
    Liu, H.-F., Chao, K.-M.: A tight analysis of the Katriel-Bodlaender algorithm for online topological ordering. Theor. Comput. Sci. 389(1-2), 182–189 (2007)MathSciNetCrossRefMATHGoogle Scholar
  16. 16.
    Liu, H.-F., Chao, K.-M.: An Õ(n 2.5)-time algorithm for online topological ordering (2008)Google Scholar
  17. 17.
    Marchetti-Spaccamela, A., Nanni, U., Rohnert, H.: On-line graph algorithms for incremental compilation. In: van Leeuwen, J. (ed.) WG 1993. LNCS, vol. 790, pp. 70–86. Springer, Heidelberg (1994)CrossRefGoogle Scholar
  18. 18.
    Marchetti-Spaccamela, A., Nanni, U., Rohnert, H.: Maintaining a topological order under edge insertions. Inf. Proc. Lett. 59(1), 53–58 (1996)MathSciNetCrossRefMATHGoogle Scholar
  19. 19.
    Omohundro, S.M., Lim, C.-C., Bilmes, J.: The Sather language compiler/debugger implementation. Technical Report TR-92-017, International Computer Science Institute, Berkeley (1992)Google Scholar
  20. 20.
    Pearce, D.J., Kelly, P.H.J.: A dynamic topological sort algorithm for directed acyclic graphs. J. of Exp. Algorithmics 11, 1–7 (2006)MathSciNetMATHGoogle Scholar
  21. 21.
    Pearce, D.J., Kelly, P.H.J., Hankin, C.: Online cycle detection and difference propagation for pointer analysis. In: SCAM 2003, pp. 3–12 (2003)Google Scholar
  22. 22.
    Ramalingam, G., Reps, T.W.: On the computational complexity of incremental algorithms. Technical Report CS-TR-1991-1033, University of Wisconsin-Madison (1991)Google Scholar
  23. 23.
    Ramalingam, G., Reps, T.W.: On competitive on-line algorithms for the dynamic priority-ordering problem. Inf. Proc. Lett. 51(3), 155–161 (1994)MathSciNetCrossRefMATHGoogle Scholar
  24. 24.
    Roditty, L., Zwick, U.: Improved dynamic reachability algorithms for directed graphs. In: FOCS 2002, pp. 679–688 (2002)Google Scholar
  25. 25.
    Roditty, L., Zwick, U.: A fully dynamic reachability algorithm for directed graphs with an almost linear update time. In: STOC 2004, pp. 184–191 (2004)Google Scholar
  26. 26.
    Schönhage, A., Paterson, M., Pippenger, N.: Finding the median. J. of Comput. and Syst. Sci. 13(2), 184–199 (1976)MathSciNetCrossRefMATHGoogle Scholar
  27. 27.
    Shmueli, O.: Dynamic cycle detection. Information Processing Letters 17(4), 185–188 (1983)MathSciNetCrossRefMATHGoogle Scholar
  28. 28.
    Tarjan, R.E.: Depth-first search and linear graph algorithms. SIAM J. on Comput. 1(2), 146–160 (1972)MathSciNetCrossRefMATHGoogle Scholar
  29. 29.
    Thorup, M.: Integer priority queues with decrease key in constant time and the single source shortest paths problem. J. of Comput. Syst. Sci. 69(3), 330–353 (2004)MathSciNetCrossRefMATHGoogle Scholar
  30. 30.
    van Emde Boas, P.: Preserving order in a forest in less than logarithmic time and linear space. Inf. Proc. Lett. 6(3), 80–82 (1977)CrossRefMATHGoogle Scholar
  31. 31.
    van Emde Boas, P., Kaas, R., Zijlstra, E.: Design and implementation of an efficient priority queue. Mathematical Systems Theory 10, 99–127 (1977)MathSciNetCrossRefMATHGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2008

Authors and Affiliations

  • Bernhard Haeupler
    • 1
  • Telikepalli Kavitha
    • 2
  • Rogers Mathew
    • 2
  • Siddhartha Sen
    • 1
  • Robert E. Tarjan
    • 1
    • 3
  1. 1.Princeton UniversityPrinceton
  2. 2.Indian Institute of ScienceBangaloreIndia
  3. 3.HP LaboratoriesPalo Alto

Personalised recommendations