org.eclipse.viatra.query.runtime.base.itc.alg.counting

## Class CountingTcRelation<V>

- java.lang.Object
- - org.eclipse.viatra.query.runtime.base.itc.alg.counting.CountingTcRelation<V>

- Type Parameters:
    `V` -
  All Implemented Interfaces:
    ITcRelation<V>

      public class CountingTcRelation<V>
      extends java.lang.Object
      implements ITcRelation<V>

  Transitive closure relation implementation for the Counting algorithm.

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `CountingTcRelation(boolean backwardIndexing)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `addTuple(V source, V target, int count)` Returns true if the tc relation did not contain previously such a tuple that is defined by (source,target), false otherwise (in this case count is incremented with the given count parameter).
    `protected void` | `clear()`
    `boolean` | `containsTuple(V source, V target)` Returns true if a (source, target) node is present in the transitive closure relation, false otherwise.
    `static <V> CountingTcRelation<V>` | `createFrom(IBiDirectionalGraphDataSource<V> gds)`
    `void` | `deleteTupleEnd(V deleted)`
    `boolean` | `equals(java.lang.Object obj)`
    `int` | `getCount(V source, V target)`
    `java.util.Set<V>` | `getTupleEnds(V source)` Returns the set of nodes that are reachable from the given node.
    `java.util.Set<V>` | `getTupleStarts()` Returns the starting nodes from a transitive closure relation.
    `java.util.Set<V>` | `getTupleStarts(V target)` Returns the set of nodes from which the target node is reachable, if already computed.
    `int` | `hashCode()`
    `protected boolean` | `isEmpty()`
    `java.lang.String` | `toString()`
    `protected void` | `union(CountingTcRelation<V> rA)`
    `boolean` | `updateTuple(V source, V target, boolean isInsertion)` Derivation count of the tuple (source,target) is incremented or decremented.

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### CountingTcRelation

          protected CountingTcRelation(boolean backwardIndexing)

  - ### Method Detail

    - #### isEmpty

          protected boolean isEmpty()

    - #### clear

          protected void clear()

    - #### union

          protected void union(CountingTcRelation<V> rA)

    - #### getCount

          public int getCount(V source,
                              V target)

    - #### addTuple

          public boolean addTuple(V source,
                                  V target,
                                  int count)

      Returns true if the tc relation did not contain previously such a tuple that is defined by (source,target), false otherwise (in this case count is incremented with the given count parameter).
      Parameters:
        `source` - the source of the tuple
        `target` - the target of the tuple
        `count` - the count of the tuple, must be positive
      Returns:
        true if the relation did not contain previously the tuple

    - #### updateTuple

          public boolean updateTuple(V source,
                                     V target,
                                     boolean isInsertion)

      Derivation count of the tuple (source,target) is incremented or decremented. Returns true iff updated to / from zero derivation count.
      Since:
        1.7

    - #### deleteTupleEnd

          public void deleteTupleEnd(V deleted)

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### getTupleEnds

          public java.util.Set<V> getTupleEnds(V source)

      Description copied from interface: `ITcRelation`
      Returns the set of nodes that are reachable from the given node.
      Specified by:
        `getTupleEnds` in interface `ITcRelation<V>`
      Parameters:
        `source` - the starting node
      Returns:
        the set of reachable nodes

    - #### getTupleStarts

          public java.util.Set<V> getTupleStarts(V target)

      Returns the set of nodes from which the target node is reachable, if already computed.
      Parameters:
        `target` - the target node
      Returns:
        the set of source nodes
      Throws:
        `java.lang.UnsupportedOperationException` - if backwards index not computed

    - #### getTupleStarts

          public java.util.Set<V> getTupleStarts()

      Description copied from interface: `ITcRelation`
      Returns the starting nodes from a transitive closure relation.
      Specified by:
        `getTupleStarts` in interface `ITcRelation<V>`
      Returns:
        the set of starting nodes

    - #### containsTuple

          public boolean containsTuple(V source,
                                       V target)

      Returns true if a (source, target) node is present in the transitive closure relation, false otherwise.
      Parameters:
        `source` - the source node
        `target` - the target node
      Returns:
        true if tuple is present, false otherwise

    - #### equals

          public boolean equals(java.lang.Object obj)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### createFrom

          public static <V> CountingTcRelation<V> createFrom(IBiDirectionalGraphDataSource<V> gds)