public class LowestCommonAncestorFinder<N,E>
extends java.lang.Object
The LCA of a set of nodes is the node that is an ancestor to all of them but has the smallest
value of heightFn
. In a non-tree, There may be multiple LCAs for a given set of search
nodes. In a cyclic graph, the LCAs may not be well defined.
Modifier and Type | Class and Description |
---|---|
static interface |
LowestCommonAncestorFinder.Factory<N,E>
An abstraction for the
LowestCommonAncestorFinder::new . |
static interface |
LowestCommonAncestorFinder.HeightFunction<N>
A function that maps each node in a
DiGraph into an int defining a topological
sort of all nodes. |
Constructor and Description |
---|
LowestCommonAncestorFinder(DiGraph<N,E> graph,
LowestCommonAncestorFinder.HeightFunction<N> heightFn) |
Modifier and Type | Method and Description |
---|---|
com.google.common.collect.ImmutableSet<N> |
findAll(java.util.Set<N> roots)
Execute a search on all the elements of
roots . |
public LowestCommonAncestorFinder(DiGraph<N,E> graph, LowestCommonAncestorFinder.HeightFunction<N> heightFn)
Copyright © 2009-2020 Google. All Rights Reserved.