Package com.google.common.graph
Class AbstractValueGraph<N,V>
java.lang.Object
com.google.common.graph.AbstractBaseGraph<N>
com.google.common.graph.AbstractValueGraph<N,V>
- Type Parameters:
N
- Node parameter typeV
- Value parameter type
- All Implemented Interfaces:
BaseGraph<N>
,PredecessorsFunction<N>
,SuccessorsFunction<N>
,ValueGraph<N,
V>
- Direct Known Subclasses:
ForwardingValueGraph
,StandardValueGraph
public abstract class AbstractValueGraph<N,V>
extends AbstractBaseGraph<N>
implements ValueGraph<N,V>
This class provides a skeletal implementation of
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.
- Since:
- 20.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasGraph()
Returns a live view of this graph as aGraph
.edgeValue
(EndpointPair<N> endpoints) Returns the value of the edge that connectsendpoints
(in the order, if any, specified byendpoints
), if one is present; otherwise, returnsOptional.empty()
.Returns the value of the edge that connectsnodeU
tonodeV
(in the order, if any, specified byendpoints
), if one is present; otherwise, returnsOptional.empty()
.private static <N,
V> Map <EndpointPair<N>, V> edgeValueMap
(ValueGraph<N, V> graph) final boolean
Returnstrue
iffobject
is aValueGraph
that has the same elements and the same structural relationships as those in this graph.final int
hashCode()
Returns the hash code for this graph.toString()
Returns a string representation of this graph.Methods inherited from class com.google.common.graph.AbstractBaseGraph
degree, edgeCount, edges, hasEdgeConnecting, hasEdgeConnecting, incidentEdgeOrder, incidentEdges, inDegree, isOrderingCompatible, nodeInvalidatableSet, nodePairInvalidatableSet, outDegree, validateEndpoints
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.google.common.graph.ValueGraph
adjacentNodes, allowsSelfLoops, degree, edges, edgeValueOrDefault, edgeValueOrDefault, hasEdgeConnecting, hasEdgeConnecting, incidentEdgeOrder, incidentEdges, inDegree, isDirected, nodeOrder, nodes, outDegree, predecessors, successors
-
Constructor Details
-
AbstractValueGraph
public AbstractValueGraph()
-
-
Method Details
-
asGraph
Description copied from interface:ValueGraph
Returns a live view of this graph as aGraph
. The resultingGraph
will have an edge connecting node A to node B if thisValueGraph
has an edge connecting A to B.- Specified by:
asGraph
in interfaceValueGraph<N,
V>
-
edgeValue
Description copied from interface:ValueGraph
Returns the value of the edge that connectsnodeU
tonodeV
(in the order, if any, specified byendpoints
), if one is present; otherwise, returnsOptional.empty()
.- Specified by:
edgeValue
in interfaceValueGraph<N,
V>
-
edgeValue
Description copied from interface:ValueGraph
Returns the value of the edge that connectsendpoints
(in the order, if any, specified byendpoints
), if one is present; otherwise, returnsOptional.empty()
.If this graph is directed, the endpoints must be ordered.
- Specified by:
edgeValue
in interfaceValueGraph<N,
V>
-
equals
Description copied from interface:ValueGraph
Returnstrue
iffobject
is aValueGraph
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:
- A and B have equal
directedness
. - A and B have equal
node sets
. - A and B have equal
edge sets
. - The
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)
. - A and B have equal
-
hashCode
public final int hashCode()Description copied from interface:ValueGraph
Returns the hash code for this graph. The hash code of a graph is defined as the hash code of a map from each of itsedges
to the associatededge value
.A reference implementation of this is provided by
hashCode()
. -
toString
Returns a string representation of this graph. -
edgeValueMap
-