Class VertexSet

All Implemented Interfaces:
Iterable<Integer>
Direct Known Subclasses:
Block, Clique, StableSet

public class VertexSet extends VertexCollection
A set of vertices of a graph. No duplicates are allowed.
Author:
Cristian Frăsinaru
  • Field Details

  • Constructor Details

    • VertexSet

      protected VertexSet()
    • VertexSet

      public VertexSet(Graph graph)
    • VertexSet

      public VertexSet(Graph graph, int initialCapacity)
    • VertexSet

      public VertexSet(Graph graph, int[] vertices)
    • VertexSet

      public VertexSet(VertexSet other)
  • Method Details

    • add

      public boolean add(int v)
      Description copied from class: VertexCollection
      Adds the vertex in the collection.
      Overrides:
      add in class VertexCollection
      Parameters:
      v - a vertex number
      Returns:
      true, if the collection changed as a result of this call
    • addDirectly

      protected boolean addDirectly(int v)
    • addAll

      public final void addAll(int... vertices)
      Overrides:
      addAll in class VertexCollection
      Parameters:
      vertices - an array of vertex numbers.
    • remove

      public boolean remove(int v)
      Description copied from class: VertexCollection
      Removes a vertex from the collection.
      Overrides:
      remove in class VertexCollection
      Parameters:
      v - a vertex number
      Returns:
      true, if the collection changed as a result of this call
    • removeFromPos

      protected void removeFromPos(int pos)
      Overrides:
      removeFromPos in class VertexCollection
    • clear

      public void clear()
      Description copied from class: VertexCollection
      Removes all of the elements from this collection. The collection will be empty after this method returns.
      Overrides:
      clear in class VertexCollection
    • indexOf

      protected int indexOf(int v)
      Overrides:
      indexOf in class VertexCollection
    • contains

      public boolean contains(int v)
      Overrides:
      contains in class VertexCollection
      Parameters:
      v - a vertex number.
      Returns:
      true, if this collection contains the vertex v.
    • pop

      public int pop()
      Returns and removes an element from the set, usually the last one added.
      Returns:
      an element from the set.
    • peek

      public int peek()
      Returns an element from the set, uauslly the last one added.
      Returns:
      an element from the set.
    • intersection

      public VertexSet intersection(VertexSet other)
      Parameters:
      other - another vertex set.
      Returns:
      a new set containing vertices belonging to both this and the other set.
    • intersection

      public VertexSet intersection(int... other)
      It is assumed that the other argument does not contain duplicates.
      Parameters:
      other - an array of vertex numbers, without duplicates.
      Returns:
      a new set containing vertices belonging to this set and the other array.
    • union

      public VertexSet union(int... other)
      Parameters:
      other - an array of vertex numbers.
      Returns:
      a new set containing vertices belonging to this set or the other array.
    • union

      public VertexSet union(VertexSet other)
      Parameters:
      other - a set of vertex numbers.
      Returns:
      a new set containing vertices belonging to this set or the other.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class VertexCollection
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class VertexCollection