Package org.graph4j.util
Class EdgeSet
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<Edge>,Collection<Edge>,Set<Edge>
A set of edges in a graph. This is actually an extension of
HashSet<Edge>.- Author:
- Cristian Frăsinaru
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new, empty set of edges.Constructs a new, empty set of edges, with a specified initial capacity.EdgeSet(Graph graph, Collection<Edge> edges) Constructs a new set containing the elements in the specified collection.Constructs a new set containing the elements in the specified array. -
Method Summary
Methods inherited from class java.util.HashSet
add, clear, clone, contains, isEmpty, iterator, newHashSet, remove, size, spliterator, toArray, toArrayMethods inherited from class java.util.AbstractSet
equals, hashCode, removeAllMethods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Field Details
-
graph
-
-
Constructor Details
-
EdgeSet
Constructs a new, empty set of edges.- Parameters:
graph- the graph the edges belong to.
-
EdgeSet
Constructs a new, empty set of edges, with a specified initial capacity.- Parameters:
graph- the graph the edges belong to.initialCapacity- the initial capacity of this collection.
-
EdgeSet
Constructs a new set containing the elements in the specified collection.- Parameters:
graph- the graph the edges belong to.edges- the collection of edges whose elements are to be placed into this set.
-
EdgeSet
Constructs a new set containing the elements in the specified array.- Parameters:
graph- the graph the edges belong to.edges- the array of edges whose elements are to be placed into this set.
-
-
Method Details
-
vertexSet
Returns the vertices representing endpoints of the edges in this collection.- Returns:
- the vertices representing endpoints of the edges in this collection.
-
add
public boolean add(int v, int u) Adds the edge (v,u) to this set if it is not already present.- Parameters:
v- the source endpoint of the edge.u- the target endpoint of the edge.- Returns:
trueif the set did not already contain the specified edge,falseotherwise.
-
weight
public double weight()Computes the sum of the weights associated with each edge in the collection.- Returns:
- the sum of all weights of the edges in the collection, including duplicates.
-