A Dynamic Algorithm for Topologically Sorting Directed Acyclic Graphs

  • David J. Pearce
  • Paul H. J. Kelly
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3059)

Abstract

We consider how to maintain the topological order of a directed acyclic graph (DAG) in the presence of edge insertions and deletions. We present a new algorithm and, although this has marginally inferior time complexity compared with the best previously known result, we find that its simplicity leads to better performance in practice. In addition, we provide an empirical comparison against three alternatives over a large number of random DAG’s. The results show our algorithm is the best for sparse graphs and, surprisingly, that an alternative with poor theoretical complexity performs marginally better on dense graphs.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Alpern, B., Hoover, R., Rosen, B.K., Sweeney, P.F., Zadeck, F.K.: Incremental evaluation of computational circuits. In: Proc. 1st Annual ACM-SIAM Symposium on Discrete Algorithms, pp. 32–42 (1990)Google Scholar
  2. 2.
    Baswana, S., Hariharan, R., Sen, S.: Improved algorithms for maintaining transitive closure and all-pairs shortest paths in digraphs under edge deletions. In: Proc. ACM Symposium on Theory of Computing (2002)Google Scholar
  3. 3.
    Berman, A.M.: Lower And Upper Bounds For Incremental Algorithms. PhD thesis, New Brunswick, New Jersey (1992)Google Scholar
  4. 4.
    Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C.: Introduction to Algorithms. MIT Press, Cambridge (2001)MATHGoogle Scholar
  5. 5.
    Demetrescu, C., Frigioni, D., Marchetti-Spaccamela, A., Nanni, U.: Maintaining shortest paths in digraphs with arbitrary arc weights: An experimental study. In: Proc. Workshop on Algorithm Engineering. LNCS, pp. 218–229 (2000)Google Scholar
  6. 6.
    Demetrescu, C., Italiano, G.F.: Fully dynamic transitive closure: breaking through the O(n2) barrier. In: Proc. IEEE Symposium on Foundations of Computer Science, pp. 381–389 (2000)Google Scholar
  7. 7.
    Dietz, P., Sleator, D.: Two algorithms for maintaining order in a list. In: Proc. ACM Symposium on Theory of Computing, pp. 365–372 (1987)Google Scholar
  8. 8.
    Djidjev, H., Pantziou, G.E., Zaroliagis, C.D.: Improved algorithms for dynamic shortest paths. Algorithmica 28(4), 367–389 (2000)MATHCrossRefMathSciNetGoogle Scholar
  9. 9.
    Frigioni, D., Marchetti-Spaccamela, A., Nanni, U.: Fully dynamic shortest paths and negative cycle detection on digraphs with arbitrary arc weights. In: Proc. European Symposium on Algorithms, pp. 320–331 (1998)Google Scholar
  10. 10.
    Ioannidis, Y., Ramakrishnan, R., Winger, L.: Transitive closure algorithms based on graph traversal. ACM Transactions on Database Systems 18(3), 512–576 (1993)CrossRefGoogle Scholar
  11. 11.
    Italiano, G.F., Eppstein, D., Galil, Z.: Dynamic graph algorithms. In: Algorithms and Theory of Computation Handbook, CRC Press, Boca Raton (1999)Google Scholar
  12. 12.
    Karp, R.M.: The transitive closure of a random digraph. Random Structures & Algorithms 1(1), 73–94 (1990)MATHCrossRefMathSciNetGoogle Scholar
  13. 13.
    Katriel, I.: On algorithms for online topological ordering and sorting. Research Report MPI-I-2004-1-003, Max-Planck-Institut für Informatik (2004)Google Scholar
  14. 14.
    King, V., Sagert, G.: A fully dynamic algorithm for maintaining the transitive closure. In: Proc. ACM Symposium on Theory of Computing, pp. 492–498 (1999)Google Scholar
  15. 15.
    Marchetti-Spaccamela, A., Nanni, U., Rohnert, H.: Maintaining a topological order under edge insertions. Information Processing Letters 59(1), 53–58 (1996)MATHCrossRefMathSciNetGoogle Scholar
  16. 16.
    Pearce, D.J.: Some directed graph algorithms and their application to pointer analysis. PhD thesis, Imperial College, London (2004) (work in progress)Google Scholar
  17. 17.
    Pearce, D.J., Kelly, P.H.J., Hankin, C.: Online cycle detection and difference propagation for pointer analysis. In: Proc. IEEE workshop on Source Code Analysis and Manipulation (2003)Google Scholar
  18. 18.
    Ramalingam, G. (ed.): Bounded Incremental Computation. LNCS, vol. 1089. Springer, Heidelberg (1996)MATHGoogle Scholar
  19. 19.
    Ramalingam, G., Reps, T.: On competitive on-line algorithms for the dynamic priority-ordering problem. Information Processing Letters 51(3), 155–161 (1994)MATHCrossRefMathSciNetGoogle Scholar
  20. 20.
    Reps, T.: Optimal-time incremental semantic analysis for syntax-directed editors. In: Proc. Symp. on Principles of Programming Languages, pp. 169–176 (1982)Google Scholar
  21. 21.
    Zhou, J., Müller, M.: Depth-first discovery algorithm for incremental topological sorting of directed acyclic graphs. Information Processing Letters 88(4), 195–200 (2003)MATHCrossRefMathSciNetGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2004

Authors and Affiliations

  • David J. Pearce
    • 1
  • Paul H. J. Kelly
    • 1
  1. 1.Department of ComputingImperial CollegeLondonUK

Personalised recommendations