Package org.graph4j.util
Class VertexSet
java.lang.Object
org.graph4j.util.VertexCollection
org.graph4j.util.VertexSet
A set of vertices of a graph. No duplicates are allowed.
- Author:
- Cristian Frăsinaru
-
Field Summary
FieldsFields inherited from class org.graph4j.util.VertexCollection
bitset, DEFAULT_CAPACITY, first, graph, numVertices, vertices -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(int v) Adds the vertex in the collection.final voidaddAll(int... vertices) protected booleanaddDirectly(int v) voidclear()Removes all of the elements from this collection.booleancontains(int v) booleaninthashCode()protected intindexOf(int v) intersection(int... other) It is assumed that the other argument does not contain duplicates.intersection(VertexSet other) intpeek()Returns an element from the set, uauslly the last one added.intpop()Returns and removes an element from the set, usually the last one added.booleanremove(int v) Removes a vertex from the collection.protected voidremoveFromPos(int pos) union(int... other) Methods inherited from class org.graph4j.util.VertexCollection
computeVerticesWeight, getGraph, grow, indexOf, isClique, isEmpty, isStableSet, iterator, numVertices, removeAll, removeLast, retainAll, size, toString, union, vertexToString, verticesMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
posMap
-
-
Constructor Details
-
VertexSet
protected VertexSet() -
VertexSet
-
VertexSet
-
VertexSet
-
VertexSet
-
-
Method Details
-
add
public boolean add(int v) Description copied from class:VertexCollectionAdds the vertex in the collection.- Overrides:
addin classVertexCollection- 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:
addAllin classVertexCollection- Parameters:
vertices- an array of vertex numbers.
-
remove
public boolean remove(int v) Description copied from class:VertexCollectionRemoves a vertex from the collection.- Overrides:
removein classVertexCollection- Parameters:
v- a vertex number- Returns:
- true, if the collection changed as a result of this call
-
removeFromPos
protected void removeFromPos(int pos) - Overrides:
removeFromPosin classVertexCollection
-
clear
public void clear()Description copied from class:VertexCollectionRemoves all of the elements from this collection. The collection will be empty after this method returns.- Overrides:
clearin classVertexCollection
-
indexOf
protected int indexOf(int v) - Overrides:
indexOfin classVertexCollection
-
contains
public boolean contains(int v) - Overrides:
containsin classVertexCollection- 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
- Parameters:
other- another vertex set.- Returns:
- a new set containing vertices belonging to both this and the other set.
-
intersection
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
- Parameters:
other- an array of vertex numbers.- Returns:
- a new set containing vertices belonging to this set or the other array.
-
union
- 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:
hashCodein classVertexCollection
-
equals
- Overrides:
equalsin classVertexCollection
-