Interface LowestCommonAncestorOffline.Queries<V,E>

Type Parameters:
V - the vertices type
E - the edges type
All Known Subinterfaces:
LowestCommonAncestorOffline.IQueries
Enclosing interface:
LowestCommonAncestorOffline

public static interface LowestCommonAncestorOffline.Queries<V,E>
Queries container for LowestCommonAncestorOffline computations.

Queries are added one by one to this container, and than the Queries object is passed to a LowestCommonAncestorOffline algorithm using LowestCommonAncestorOffline.findLowestCommonAncestors(Graph, Object, Queries).

Author:
Barak Ugav
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addQuery(V u, V v)
    Add a query for the lowest common ancestor of u and v.
    void
    Clear the container from all existing queries.
    getQuerySource(int idx)
    Get a query source by index.
    getQueryTarget(int idx)
    Get a query target by index.
    Create an empty queries container.
    int
    Get the number of queries in this container.
  • Method Details

    • newInstance

      static <V, E> LowestCommonAncestorOffline.Queries<V,E> newInstance(Graph<V,E> g)
      Create an empty queries container.
      Type Parameters:
      V - the vertices type
      E - the edges type
      Parameters:
      g - the graph
      Returns:
      a new queries container
    • addQuery

      void addQuery(V u, V v)
      Add a query for the lowest common ancestor of u and v.
      Parameters:
      u - the first vertex
      v - the second vertex
    • getQuerySource

      V getQuerySource(int idx)
      Get a query source by index.

      A query is composed of two vertices, the source and the target. This method return the source vertex of a query. Use getQueryTarget(int) to get the target vertex.

      Parameters:
      idx - index of the query. Must be in range [0, size())
      Returns:
      the first vertex of the query
      Throws:
      IndexOutOfBoundsException - if idx < 0 or idx >= size()
    • getQueryTarget

      V getQueryTarget(int idx)
      Get a query target by index.

      A query is composed of two vertices, the target and the source. This method return the target vertex of a query. Use getQueryTarget(int) to get the source vertex.

      Parameters:
      idx - index of the query. Must be in range [0, size())
      Returns:
      the second vertex of the query
      Throws:
      IndexOutOfBoundsException - if idx < 0 or idx >= size()
    • size

      int size()
      Get the number of queries in this container.
      Returns:
      the number of queries in this container
    • clear

      void clear()
      Clear the container from all existing queries.