Interface AutoRelation<W>

Type Parameters:
W - Type of the weights.
All Superinterfaces:
Relation<W>
All Known Implementing Classes:
FastUnweightedAutoRelation, FastWeightedAutoRelation

public interface AutoRelation<W>
extends Relation<W>
Interface for defining the relation of a set of objects with themselves.
  • Method Details

    • numSecond

      default int numSecond()
      Gets the total number of elements of the first item in the relation.
      Specified by:
      numSecond in interface Relation<W>
      Returns:
      The number of different elements of the first item in the relation.
    • numSecond

      default int numSecond​(int firstIdx)
      Gets the total number of elements of the second item related to a first item.
      Specified by:
      numSecond in interface Relation<W>
      Parameters:
      firstIdx - Identifier of the first item.
      Returns:
      the second item count.
    • getAllSecond

      default java.util.stream.Stream<java.lang.Integer> getAllSecond()
      Gets all the elements of the second type.
      Specified by:
      getAllSecond in interface Relation<W>
      Returns:
      a stream containing all the elements.
    • addSecondItem

      default boolean addSecondItem​(int secondIdx)
      Description copied from interface: Relation
      Adds a new second item to the relation (if it does not previously exist).
      Specified by:
      addSecondItem in interface Relation<W>
      Parameters:
      secondIdx - Identifier of the second item.
      Returns:
      true if everything went OK, false if it did previously exist, or something went wrong.
    • remove

      boolean remove​(int idx)
      Removes an element. The identifiers of all remaining elements will be reduced by 1.
      Parameters:
      idx - The identifier of the element.
      Returns:
      true if everything went OK, false otherwise.
    • getIsolated

      java.util.stream.IntStream getIsolated()
      Obtains the elements in an autorelation which are related to none.
      Returns:
      an int stream containing the indexes of the items which are related to none.
    • isIsolated

      default boolean isIsolated​(int idx)
      Checks whether an element is related to someone or not.
      Parameters:
      idx - The identifier of the element.
      Returns:
      true if the node is isolated, false otherwise.