All-Pairs Ancestor Problems in Weighted Dags

  • Matthias Baumgart
  • Stefan Eckhardt
  • Jan Griebsch
  • Sven Kosub
  • Johannes Nowak
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4614)


This work studies (lowest) common ancestor problems in (weighted) directed acyclic graphs. We improve previous algorithms for the all-pairs representative LCA problem to O(n 2.575) by using fast rectangular matrix multiplication. We prove a first non-trivial upper bound of O( min {n 2 m, n 3.575 }) for the all-pairs all lowest common ancestors problem. Furthermore, classes of dags are identified for which the problem can be solved considerably faster. Our algorithms scale with the maximal number of LCAs for one pair and—based on the famous Dilworth’s theorem—with the size of a maximum antichain (i.e., width) of the dag. We extend and generalize previous results on computing shortest ancestral distances. It is shown that finding shortest distance common ancestors in weighted dags is not harder than computing all-pairs shortest distances, up to a polylogarithmic factor. Finally, we present a solution for the general all-pairs shortest distance LCA problem based on computing all-pairs all LCAs.


Transitive Closure Border Gateway Protocol Lower Common Ancestor Lower Common Ancestor Maximum Antichain 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Aho, A., Hopcroft, J., Ullman, J.: On finding lowest common ancestors in trees. SIAM J. Comput. 5(1), 115–132 (1976)zbMATHCrossRefMathSciNetGoogle Scholar
  2. 2.
    Aït-Kaci, H., Boyer, R., Lincoln, P., Nasr, R.: Efficient implementation of lattice operations. ACM Trans. Program. Lang. Syst. 11(1), 115–146 (1989)CrossRefGoogle Scholar
  3. 3.
    Alon, N., Naor, M.: Derandomization, witnesses for boolean matrix multiplication and construction of perfect hash functions. Algorithmica 16(4–5), 434–449 (1996)zbMATHCrossRefMathSciNetGoogle Scholar
  4. 4.
    Baumgart, M., Eckhardt, S., Griebsch, J., Kosub, S., Nowak, J.: All-pairs common-ancestor problems in weighted dags. Technical Report TUM-I0606, Institut für Informatik, TU München (April 2006)Google Scholar
  5. 5.
    Benczúr, A., Förster, J., Király, Z.: Dilworth’s theorem and its application for path systems of a cycle - implementation and analysis. In: Nešetřil, J. (ed.) ESA 1999. LNCS, vol. 1643, pp. 498–509. Springer, Heidelberg (1999)Google Scholar
  6. 6.
    Bender, M., Pemmasani, G., Skiena, S., Sumazin, P.: Finding least common ancestors in directed acyclic graphs. In: SODA 2001. Proc. 12th Annual Symposium on Discrete Algorithms, pp. 845–854 (2001)Google Scholar
  7. 7.
    Bender, M., Farach-Colton, M., Pemmasani, G., Skiena, S., Sumazin, P.: Lowest common ancestors in trees and directed acyclic graphs. J. Algorithms 57(2), 75–94 (2005)zbMATHCrossRefMathSciNetGoogle Scholar
  8. 8.
    Berkman, O., Vishkin, U.: Finding level-ancestors in trees. J. Comput. Syst. Sci. 48(2), 214–230 (1994)zbMATHCrossRefMathSciNetGoogle Scholar
  9. 9.
    Cole, R., Hariharan, R.: Dynamic LCA queries on trees. SIAM J. Comput. 34(4), 894–923 (2005)zbMATHCrossRefMathSciNetGoogle Scholar
  10. 10.
    Coppersmith, D., Winograd, S.: Matrix multiplication via arithmetic progressions. J. Symbolic Computation 9(3), 251–280 (1990)zbMATHCrossRefMathSciNetGoogle Scholar
  11. 11.
    Coppersmith, D.: Rectangular matrix multiplication revisited. J. Complexity 13(1), 42–49 (1997)zbMATHCrossRefMathSciNetGoogle Scholar
  12. 12.
    Czumaj, A., Kowaluk, M., Lingas, A.: Faster algorithms for finding lowest common ancestors in directed acyclic graphs. Electronic Colloquium on Computational Complexity (ECCC), TR06-111 (2006)Google Scholar
  13. 13.
    Gao, L.: On inferring autonomous system relationships in the Internet. IEEE/ACM Trans. Networking 9(6), 733–745 (2001)CrossRefGoogle Scholar
  14. 14.
    Harel, D., Tarjan, R.: Fast algorithms for finding nearest common ancestors. SIAM J. Comput. 13(2), 338–355 (1984)zbMATHCrossRefMathSciNetGoogle Scholar
  15. 15.
    Kowaluk, M., Lingas, A.: LCA queries in directed acyclic graphs. In: Caires, L., Italiano, G.F., Monteiro, L., Palamidessi, C., Yung, M. (eds.) ICALP 2005. LNCS, vol. 3580, pp. 241–248. Springer, Heidelberg (2005)Google Scholar
  16. 16.
    Moret, B., Nakhleh, L., Warnow, T., Linder, C., Tholse, A., Padolina, A., Sun, J., Timme, R.: Phylogenetic networks: Modeling, reconstructibility, and accuracy. IEEE/ACM Trans. Comput. Biology Bioinform. 1(1), 13–23 (2004)CrossRefGoogle Scholar
  17. 17.
    Nakhleh, L., Wang, L.: Phylogenetic networks: Properties and relationship to trees and clusters. In: Priami, C., Zelikovsky, A. (eds.) Transactions on Computational Systems Biology II. LNCS (LNBI), vol. 3680, pp. 82–99. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  18. 18.
    Nykänen, M., Ukkonen, E.: Finding lowest common ancestors in arbitrarily directed trees. Inf. Process. Lett. 50(1), 307–310 (1994)zbMATHCrossRefGoogle Scholar
  19. 19.
    Schieber, B., Vishkin, U.: On finding lowest common ancestors: Simplification and parallelization. SIAM J. Comput. 17(6), 1253–1262 (1988)zbMATHCrossRefMathSciNetGoogle Scholar
  20. 20.
    Seidel, R.: On the all-pairs-shortest-path problem in unweighted undirected graphs. J. Comput. Syst. Sci. 51(3), 400–403 (1995)CrossRefMathSciNetGoogle Scholar
  21. 21.
    Tarjan, R.: Applications of path compression on balanced trees. J. ACM 26(4), 690–715 (1979)zbMATHMathSciNetGoogle Scholar
  22. 22.
    Wang, B., Tsai, J., Chuang, Y.: The lowest common ancestor problem on a tree with an unfixed root. Inf. Sci. 119(1–2), 125–130 (1999)zbMATHCrossRefMathSciNetGoogle Scholar
  23. 23.
    Wen, Z.: New algorithms for the LCA problem and the binary tree reconstruction problem. Inf. Process. Lett. 51(1), 11–16 (1994)zbMATHCrossRefGoogle Scholar
  24. 24.
    Zwick, U.: All pairs shortest paths using bridging sets and rectangular matrix multiplication. J. ACM 49(3), 289–317 (2002)MathSciNetGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2007

Authors and Affiliations

  • Matthias Baumgart
    • 1
  • Stefan Eckhardt
    • 1
  • Jan Griebsch
    • 1
  • Sven Kosub
    • 1
  • Johannes Nowak
    • 1
  1. 1.Fakultät für Informatik, Technische Universität München, Boltzmannstraße 3, D-85748 Garching bei MünchenGermany

Personalised recommendations