Lowest common ancestors in trees and directed acyclic graphs (original) (raw)

A scalable approach to computing representative lowest common ancestor in directed acyclic graphs

Theoretical Computer Science, 2013

LCA computation for vertex pairs in trees can be achieved in constant time after linear-time preprocessing. However, extension of these techniques to compute LCA for vertex-pairs in DAGs has been not possible due to the non-tree edges in a DAG. In this paper, we present an algorithm for computing the LCA for vertex pairs in a DAG which treats the DAG's spanning tree and its non-tree edges separately. Our approach enables us to tap the efficiency of existing LCA algorithms for trees. Furthermore, our algorithm decomposes the DAG into a set of component trees called clusters which significantly reduces the preprocessing necessary to incorporate non-tree edges in the LCA computation. Our algorithm seamlessly interpolates the performance graph between the best reported algorithms for trees and the best reported algorithms for DAGs depending on the incidence of non-tree edges in the DAG. Using the proposed techniques, it is possible to achieve nearlinear preprocessing and constant query time for sparse DAGs.

Finding lowest common ancestors in arbitrarily directed trees

Information Processing Letters, 1994

It is well known how to preprocess a rooted tree in linear time to yield the lowest common ancestor of any given pair of nodes in constant time. We generalize these algorithms for graphs called Arbitrarily Directed Trees, or

Fast Algorithms for Finding Nearest Common Ancestors

SIAM Journal on Computing, 1984

We consider the following problem: Given a collection of rooted trees, answer on-line queries of the form, "What is the nearest common ancester of vertices x and y?" We show that any pointer machine that solves this problem requires fl(log log n) time per query in the worst case, where n is the total number of vertices in the trees. On the other, hand, we present an algorithm for a random access machine with uniform cost measure (and a bound of O(log n) on the number of bits per word) that requires O(1) time per query and O(n) preprocessing time, assuming that the collection of trees is static. For a version of the problem in which the trees can change between queries, we obtain an almost-linear-time (and linear-space) algorithm.

An efficient transitive closure algorithm for cyclic digraphs

Information Processing Letters, 1994

We present a new transitive closure algorithm that is based on strong component detection. The new algorithm is more efficient than the previous transitive closure algorithms that are based on strong components detection, since it does not generate unnecessary partial successor sets and scans the input graph only once.

Shortest Path Algorithms Technique for Nearly Acyclic Graphs

—Dijkstra's algorithm solves the single-source shortest path problem on any directed graph in O(m+nlogn) worst-case time when a Fibonacci heap is used as the frontier set data structure. Here n is the number of vertices and m is the number of edges in the graph. If the graph is nearly acyclic, then other algorithms can achieve a time complexity lower than that of Dijkstra's algorithm. Abuaiadh and Kingston gave a single source shortest path algorithm for nearly acyclic graphs with O(m + nlogt) worst-case time complexity, where the new parameter t is the number of delete-min operations performed in priority queue manipulation. For nearly acyclic graphs, the value of t is expected to be small, allowing the algorithm to outperform Dijkstra's algorithm. Takaoka, using a different definition for acyclicity, gave an algorithm with O(m+nlogk) worst-case time complexity. In this algorithm, the new parameter k is the maximum cardinality of the strongly connected components in the graph. This paper with the refrence of Shane Saunders thesis presents several new shortest path algorithms that define trigger vertices, from which efficient computation of shortest paths through underlying acyclic structures in the graph is possible. If trigger vertices are defined as a set of precomputed feedback vertices, then the all-pairs shortest path problem can be solved in O(mn + nr2) worst-case time. This allows all-pairs to be solved in O(mn) worst-case time when a feedback vertex set smaller than the square root of the number of edges is known.

Shortest path queries in digraphs of small treewidth

Lecture Notes in Computer Science, 1995

We consider the problem of preprocessing an n-vertex digraph with real edge weights so that subsequent queries for the shortest path or distance between any two vertices can be efficiently answered. We give algorithms that depend on the treewidth of the input graph. When the treewidth is a constant, our algorithms can answer distance queries in O(α(n)) time after O(n) preprocessing. This improves upon previously known results for the same problem. We also give a dynamic algorithm which, after a change in an edge weight, updates the data structure in time O(n β ), for any constant 0 < β < 1. The above two algorithms are based on an algorithm of independent interest: computing a shortest path tree, or finding a negative cycle in linear time.

Shortest Paths in Digraphs of Small Treewidth. Part I: Sequential Algorithms

Algorithmica, 2000

We consider the problem of preprocessing an n-vertex digraph with real edge weights so that subsequent queries for the shortest path or distance between any two vertices can be e ciently answered. We give algorithms that depend on the treewidth of the input graph. When the treewidth is a constant, our algorithms can answer distance queries in O( (n)) time after O(n) preprocessing. This improves upon previously known results for the same problem. We also give a dynamic algorithm which, after a change in an edge weight, updates the data structure in time O(n ), for any constant 0 < < 1. Furthermore, an algorithm of independent interest is given: computing a shortest path tree, or nding a negative cycle in linear time.

Commentary - Methods to find all the edges on any of the shortest paths between two given nodes of a directed acyclic graph

Research Ideas and Outcomes

This article puts forth all the existing methods proposed by the various authors of the Stack Exchange community to find all the edges on any shortest path between two given nodes of a directed acyclic graph. For a directed acyclic graph with N number of nodes, an exponential number of paths are possible between any two given nodes and, thus, it is not feasible to compute every path and find the shortest ones in polynomial time to generate a set of all edges that contribute or make any of the shortest paths. The methods discussed in this article are not limited only to this specific use case, but have a much broader scope in graph theory, dynamic programming and counting problems. Generally, various other questions and answers, raised on the community portal having similar scope to those that the users specifically seek, do not receive sufficient hits and, hence, enough attention and votes for various reasons worth contemplating. Therefore, this article also aims to highlight the va...

The serial transitive closure problem for trees

1995

The serial transitive closure problem is the problem of, given a directed graph G and a list of edges, called closure edges, which are in the transitive closure of the graph, to generate all the closure edges from edges in G. We give a nearly linear upper bound on the number of steps in optimal solutions to the serial transitive closure problem for the case of graphs which are trees. "Nearly linear" means O(n · α(n)) where α is the inverse Ackermann function. This upper bound is optimal to within a constant factor.