Package com.google.common.graph
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
 
 @Beta public abstract class AbstractGraph<N> extends java.lang.Object implements Graph<N> This class provides a skeletal implementation ofGraph. It is recommended to extend this class rather than implementGraphdirectly.- Since:
- 20.0
- Author:
- James Sexton
 
- 
- 
Constructor SummaryConstructors Constructor Description AbstractGraph()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description intdegree(N node)protected longedgeCount()Returns the number of edges in this graph; used to calculate the size ofGraph.edges().java.util.Set<EndpointPair<N>>edges()An implementation ofBaseGraph.edges()defined in terms ofGraph.nodes()andSuccessorsFunction.successors(Object).booleanequals(java.lang.Object obj)Returnstrueiffobjectis aGraphthat has the same elements and the same structural relationships as those in this graph.booleanhasEdgeConnecting(EndpointPair<N> endpoints)booleanhasEdgeConnecting(N nodeU, N nodeV)inthashCode()Returns the hash code for this graph.ElementOrder<N>incidentEdgeOrder()java.util.Set<EndpointPair<N>>incidentEdges(N node)intinDegree(N node)protected booleanisOrderingCompatible(EndpointPair<?> endpoints)Returnstrueiffendpoints' ordering is compatible with the directionality of this graph.protected <T> java.util.Set<T>nodeInvalidatableSet(java.util.Set<T> set, N node)protected <T> java.util.Set<T>nodePairInvalidatableSet(java.util.Set<T> set, N nodeU, N nodeV)intoutDegree(N node)java.lang.StringtoString()Returns a string representation of this graph.protected voidvalidateEndpoints(EndpointPair<?> endpoints)ThrowsIllegalArgumentExceptionif the ordering ofendpointsis not compatible with the directionality of this graph.- 
Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface com.google.common.graph.GraphadjacentNodes, allowsSelfLoops, degree, edges, hasEdgeConnecting, hasEdgeConnecting, incidentEdgeOrder, incidentEdges, inDegree, isDirected, nodeOrder, nodes, outDegree, predecessors, successors
 
- 
 
- 
- 
- 
Constructor Detail- 
AbstractGraphpublic AbstractGraph() 
 
- 
 - 
Method Detail- 
equalspublic final boolean equals(@CheckForNull java.lang.Object obj) Description copied from interface:GraphReturnstrueiffobjectis aGraphthat 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 directednessdo 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 
 - 
hashCodepublic final int hashCode() Description copied from interface:GraphReturns 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().
 - 
toStringpublic java.lang.String toString() Returns a string representation of this graph.- Overrides:
- toStringin class- java.lang.Object
 
 - 
edgeCountprotected 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.
 - 
edgespublic java.util.Set<EndpointPair<N>> edges() An implementation ofBaseGraph.edges()defined in terms ofGraph.nodes()andSuccessorsFunction.successors(Object).
 - 
incidentEdgeOrderpublic ElementOrder<N> incidentEdgeOrder() 
 - 
incidentEdgespublic java.util.Set<EndpointPair<N>> incidentEdges(N node) 
 - 
degreepublic int degree(N node) 
 - 
inDegreepublic int inDegree(N node) 
 - 
outDegreepublic int outDegree(N node) 
 - 
hasEdgeConnectingpublic boolean hasEdgeConnecting(N nodeU, N nodeV)
 - 
hasEdgeConnectingpublic boolean hasEdgeConnecting(EndpointPair<N> endpoints) 
 - 
validateEndpointsprotected final void validateEndpoints(EndpointPair<?> endpoints) ThrowsIllegalArgumentExceptionif the ordering ofendpointsis not compatible with the directionality of this graph.
 - 
isOrderingCompatibleprotected final boolean isOrderingCompatible(EndpointPair<?> endpoints) Returnstrueiffendpoints' ordering is compatible with the directionality of this graph.
 - 
nodeInvalidatableSetprotected final <T> java.util.Set<T> nodeInvalidatableSet(java.util.Set<T> set, N node)
 - 
nodePairInvalidatableSetprotected final <T> java.util.Set<T> nodePairInvalidatableSet(java.util.Set<T> set, N nodeU, N nodeV)
 
- 
 
-