Finding least common ancestors in directed acyclic graphs

One of the fundamental algorithmic problems on trees is how to find the least common ancestor (LCA) of a given pair of nodes. The LCA of nodes u and v in a tree is an ancestor of u and v that is located farthest from the root. The LCA problem is stated as follows: Given a rooted tree T, how can we preprocess T to answer LCA queries quickly on any pair of nodes? The LCA problem has been studied intensively both because it is inherently beautiful and because fast algorithms for the LCA problem can be used to solve other algorithmic problems. However, many similar combinatorial problems cannot be solved using the tree LCA algorithmic machinery because the ancestor queries are on more complicated directed structures. Examples of such combinatorial problems include preprocessing arbitrarily (unrooted) directed trees [NU94], computing the LCA on lattices (used to represent inheritance graphs) [AKBLN89], and finding modular coverings in inheritance graphs [DH87, HHS95]. In this paper we introduce a natural extension to all of these LCA problems. We develop algorithms for efficiently answering least common ancestor queries on directed acyclic graphs (DAGs). An LCA w of nodes u and v in a DAG is an ancestor of both u and v where w has no descendants that are ancestors of both u and v. (See Definitions 2.1 and 2.2.) We present an o(n 3) preprocessing algorithm for answering least common ancestor queries on DAGs in constant time. We then initiate an experimental study of new and existing LCA algorithms on rooted trees and DAGs. Least common ancestor queries on general DAGs appear in a variety of applications, including the following:

[1]  Michael A. Bender,et al.  The LCA Problem Revisited , 2000, LATIN.

[2]  Gideon Yuval,et al.  An Algorithm for Finding All Shortest Paths Using N^(2.81) Infinite-Precision Multiplications , 1976, Inf. Process. Lett..

[3]  Lhouari Nourine,et al.  Tree Structure for Distributive Lattices and its Applications , 1996, Theor. Comput. Sci..

[4]  Richard Cole,et al.  Dynamic LCA queries on trees , 1999, SODA '99.

[5]  D. S. Parker Partial Order Programming. , 1989 .

[6]  Don Coppersmith,et al.  Matrix multiplication via arithmetic progressions , 1987, STOC.

[7]  Edith Cohen,et al.  All-pairs small-stretch paths , 1997, SODA '97.

[8]  Raimund Seidel,et al.  On the all-pairs-shortest-path problem , 1992, STOC '92.

[9]  Roland Ducournau,et al.  On Some Algorithms for Multiple Inheritance in Object-Oriented Programming , 1987, ECOOP.

[10]  TarjanRobert Endre Applications of Path Compression on Balanced Trees , 1979 .

[11]  Noga Alon,et al.  On the Exponent of the All Pairs Shortest Path Problem , 1991, J. Comput. Syst. Sci..

[12]  Uri Zwick,et al.  All pairs shortest paths in weighted directed graphs-exact and almost exact algorithms , 1998, Proceedings 39th Annual Symposium on Foundations of Computer Science (Cat. No.98CB36280).

[13]  Uzi Vishkin,et al.  Finding Level-Ancestors in Trees , 1994, J. Comput. Syst. Sci..

[14]  A A Schäffer,et al.  Avoiding recomputation in linkage analysis. , 1994, Human heredity.

[15]  Robert E. Tarjan,et al.  Fast Algorithms for Finding Nearest Common Ancestors , 1984, SIAM J. Comput..

[16]  Biing-Feng Wang,et al.  The Lowest Common Ancestor Problem on a Tree with an Unfixed Root , 1999, Inf. Sci..

[17]  Michael L. Fredman,et al.  New Bounds on the Complexity of the Shortest Path Problem , 1976, SIAM J. Comput..

[18]  Uzi Vishkin,et al.  On Finding Lowest Common Ancestors: Simplification and Parallelization , 1988, AWOC.

[19]  Uzi Vishkin,et al.  Optimal Doubly Logarithmic Parallel Algorithms Based on Finding All Nearest Smaller Values , 1993, J. Algorithms.

[20]  Zhaofang Wen New Algorithms for the LCA Problem and the Binary Tree Reconstruction Problem , 1994, Inf. Process. Lett..

[21]  James Demmel,et al.  Optimizing matrix multiply using PHiPAC: a portable, high-performance, ANSI C coding methodology , 1997, ICS '97.

[22]  Uzi Vishkin,et al.  Recursive Star-Tree Parallel Data Structure , 1993, SIAM J. Comput..

[23]  Matti Nykänen,et al.  Finding Lowest Common Ancestors in Arbitrarily Directed Trees , 1994, Inf. Process. Lett..

[24]  James Demmel,et al.  Using PHiPAC to speed error back-propagation learning , 1997, 1997 IEEE International Conference on Acoustics, Speech, and Signal Processing.

[25]  Patrick Lincoln,et al.  Efficient implementation of lattice operations , 1989, TOPL.

[26]  David Robson,et al.  Smalltalk-80: The Language and Its Implementation , 1983 .