Class AbstractGraph<N>
java.lang.Object
com.google.common.graph.AbstractGraph<N>
- Type Parameters:
N
- Node parameter type
- All Implemented Interfaces:
Graph<N>
,PredecessorsFunction<N>
,SuccessorsFunction<N>
- Direct Known Subclasses:
ImmutableGraph
This class provides a skeletal implementation of
Graph
. It is recommended to extend this
class rather than implement Graph
directly.- Since:
- 20.0
- Author:
- James Sexton
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
protected long
Returns the number of edges in this graph; used to calculate the size ofGraph.edges()
.Set
<EndpointPair<N>> edges()
An implementation ofBaseGraph.edges()
defined in terms ofGraph.nodes()
andSuccessorsFunction.successors(Object)
.final boolean
Returnstrue
iffobject
is aGraph
that has the same elements and the same structural relationships as those in this graph.boolean
hasEdgeConnecting
(EndpointPair<N> endpoints) boolean
hasEdgeConnecting
(N nodeU, N nodeV) final int
hashCode()
Returns the hash code for this graph.Set
<EndpointPair<N>> incidentEdges
(N node) int
protected final boolean
isOrderingCompatible
(EndpointPair<?> endpoints) Returnstrue
iffendpoints
' ordering is compatible with the directionality of this graph.protected final <T> Set
<T> nodeInvalidatableSet
(Set<T> set, N node) protected final <T> Set
<T> nodePairInvalidatableSet
(Set<T> set, N nodeU, N nodeV) int
toString()
Returns a string representation of this graph.protected final void
validateEndpoints
(EndpointPair<?> endpoints) ThrowsIllegalArgumentException
if the ordering ofendpoints
is not compatible with the directionality of this graph.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.google.common.graph.Graph
adjacentNodes, allowsSelfLoops, degree, edges, hasEdgeConnecting, hasEdgeConnecting, incidentEdgeOrder, incidentEdges, inDegree, isDirected, nodeOrder, nodes, outDegree, predecessors, successors
-
Constructor Details
-
AbstractGraph
public AbstractGraph()Constructor for use by subclasses.
-
-
Method Details
-
equals
Description copied from interface:Graph
Returnstrue
iffobject
is aGraph
that has the same elements and the same structural relationships as those in this graph.Thus, two 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
.
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
Description copied from interface:Graph
Returns the hash code for this graph. The hash code of a graph is defined as the hash code of the set returned byGraph.edges()
.A reference implementation of this is provided by
hashCode()
. -
toString
-
edgeCount
protected long edgeCount()Returns the number of edges in this graph; used to calculate the size ofGraph.edges()
. This implementation requires O(|N|) time. Classes extending this one may manually keep track of the number of edges as the graph is updated, and override this method for better performance. -
edges
An implementation ofBaseGraph.edges()
defined in terms ofGraph.nodes()
andSuccessorsFunction.successors(Object)
. -
incidentEdgeOrder
-
incidentEdges
-
degree
-
inDegree
-
outDegree
-
hasEdgeConnecting
-
hasEdgeConnecting
-
validateEndpoints
ThrowsIllegalArgumentException
if the ordering ofendpoints
is not compatible with the directionality of this graph. -
isOrderingCompatible
Returnstrue
iffendpoints
' ordering is compatible with the directionality of this graph. -
nodeInvalidatableSet
-
nodePairInvalidatableSet
-