N
- Node parameter typeV
- Value parameter type@Beta public abstract class AbstractValueGraph<N,V> extends AbstractBaseGraph<N> implements ValueGraph<N,V>
ValueGraph
. It is recommended to extend
this class rather than implement ValueGraph
directly.
The methods implemented in this class should not be overridden unless the subclass admits a more efficient implementation.
Constructor and Description |
---|
AbstractValueGraph() |
Modifier and Type | Method and Description |
---|---|
Graph<N> |
asGraph()
Returns a live view of this graph as a
Graph . |
java.util.Optional<V> |
edgeValue(N nodeU,
N nodeV)
Returns the value of the edge connecting
nodeU to nodeV , if one is present;
otherwise, returns Optional.empty() . |
private static <N,V> java.util.Map<EndpointPair<N>,V> |
edgeValueMap(ValueGraph<N,V> graph) |
boolean |
equals(java.lang.Object obj)
Returns
true iff object is a ValueGraph that has the same elements and
the same structural relationships as those in this graph. |
int |
hashCode()
Returns the hash code for this graph.
|
java.lang.String |
toString()
Returns a string representation of this graph.
|
degree, edgeCount, edges, hasEdgeConnecting, incidentEdges, inDegree, outDegree
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
adjacentNodes, allowsSelfLoops, degree, edges, edgeValueOrDefault, hasEdgeConnecting, incidentEdges, inDegree, isDirected, nodeOrder, nodes, outDegree, predecessors, successors
public Graph<N> asGraph()
ValueGraph
Graph
. The resulting Graph
will have an
edge connecting node A to node B if this ValueGraph
has an edge connecting A to B.asGraph
in interface ValueGraph<N,V>
public java.util.Optional<V> edgeValue(N nodeU, N nodeV)
ValueGraph
nodeU
to nodeV
, if one is present;
otherwise, returns Optional.empty()
.
In an undirected graph, this is equal to edgeValue(nodeV, nodeU)
.
edgeValue
in interface ValueGraph<N,V>
public final boolean equals(java.lang.Object obj)
ValueGraph
true
iff object
is a ValueGraph
that has the same elements and
the same structural relationships as those in this graph.
Thus, two value graphs A and B are equal if all of the following are true:
directedness
.
node sets
.
edge sets
.
value
of a given edge is the same in both A and B.
Graph properties besides directedness
do not affect equality.
For example, two graphs may be considered equal even if one allows self-loops and the other
doesn't. Additionally, the order in which nodes or edges are added to the graph, and the order
in which they are iterated over, are irrelevant.
A reference implementation of this is provided by equals(Object)
.
equals
in interface ValueGraph<N,V>
equals
in class java.lang.Object
public final int hashCode()
ValueGraph
edges
to the associated edge value
.
A reference implementation of this is provided by hashCode()
.
hashCode
in interface ValueGraph<N,V>
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
private static <N,V> java.util.Map<EndpointPair<N>,V> edgeValueMap(ValueGraph<N,V> graph)