Interface LowestCommonAncestorOffline
-
public interface LowestCommonAncestorOffline
An algorithm for computing the lowest common ancestor (LCA) of two vertices in a tree, offline.Given a rooted tree, the lowest common ancestor (LCA) of two vertices
u
andv
is the lowest vertex (farthest to root) that has bothu
andv
as descendants. The offline version of this problem is given a tree and a set of pairs of vertices, find the LCA of each pair. There are also the static and online versions of this problem.Use
newInstance()
to get a default implementation of this interface. A builder obtained vianewBuilder()
may support different options to obtain different implementations.- Author:
- Barak Ugav
- See Also:
LowestCommonAncestorStatic
,LowestCommonAncestorDynamic
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
LowestCommonAncestorOffline.Builder
A builder forLowestCommonAncestorOffline
objects.static interface
LowestCommonAncestorOffline.IQueries
Queries container forLowestCommonAncestorOffline
computations forIntGraph
.static interface
LowestCommonAncestorOffline.IResult
Result of aLowestCommonAncestorOffline
computation forIntGraph
.static interface
LowestCommonAncestorOffline.Queries<V,E>
Queries container forLowestCommonAncestorOffline
computations.static interface
LowestCommonAncestorOffline.Result<V,E>
Result of aLowestCommonAncestorOffline
computation.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description <V,E>
LowestCommonAncestorOffline.Result<V,E>findLCAs(Graph<V,E> tree, V root, LowestCommonAncestorOffline.Queries<V,E> queries)
Find the lowest common ancestors of the given queries.static LowestCommonAncestorOffline.Builder
newBuilder()
Create a new offline LCA algorithm builder.static LowestCommonAncestorOffline
newInstance()
Create a new offline LCA algorithm object.
-
-
-
Method Detail
-
findLCAs
<V,E> LowestCommonAncestorOffline.Result<V,E> findLCAs(Graph<V,E> tree, V root, LowestCommonAncestorOffline.Queries<V,E> queries)
Find the lowest common ancestors of the given queries.If
g
isIntGraph
, the returned object isLowestCommonAncestorOffline.IResult
.- Type Parameters:
V
- the vertices typeE
- the edges type- Parameters:
tree
- the treeroot
- the root of the treequeries
- the queries- Returns:
- the lowest common ancestors of the given queries
-
newInstance
static LowestCommonAncestorOffline newInstance()
Create a new offline LCA algorithm object.This is the recommended way to instantiate a new
LowestCommonAncestorOffline
object. TheLowestCommonAncestorOffline.Builder
might support different options to obtain different implementations.- Returns:
- a default implementation of
LowestCommonAncestorOffline
-
newBuilder
static LowestCommonAncestorOffline.Builder newBuilder()
Create a new offline LCA algorithm builder.Use
newInstance()
for a default implementation.- Returns:
- a new builder that can build
LowestCommonAncestorOffline
objects
-
-