Class AbstractBaseGraph<N>
- Type Parameters:
N- Node parameter type
- All Implemented Interfaces:
BaseGraph<N>,PredecessorsFunction<N>,SuccessorsFunction<N>
- Direct Known Subclasses:
AbstractGraph,AbstractValueGraph
BaseGraph.
The methods implemented in this class should not be overridden unless the subclass admits a more efficient implementation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the count ofnode's incident edges, counting self-loops twice (equivalently, the number of times an edge touchesnode).protected longReturns the number of edges in this graph; used to calculate the size ofedges().Set<EndpointPair<N>>edges()An implementation ofBaseGraph.edges()defined in terms ofBaseGraph.nodes()andBaseGraph.successors(Object).booleanhasEdgeConnecting(EndpointPair<N> endpoints) Returns true if there is an edge that directly connectsendpoints(in the order, if any, specified byendpoints).booleanhasEdgeConnecting(N nodeU, N nodeV) Returns true if there is an edge that directly connectsnodeUtonodeV.Returns anElementOrderthat specifies the order of iteration for the elements ofBaseGraph.edges(),BaseGraph.adjacentNodes(Object),BaseGraph.predecessors(Object),BaseGraph.successors(Object)andBaseGraph.incidentEdges(Object).Set<EndpointPair<N>>incidentEdges(N node) Returns the edges in this graph whose endpoints includenode.intReturns the count ofnode's incoming edges (equal topredecessors(node).size()) in a directed graph.protected final booleanisOrderingCompatible(EndpointPair<?> endpoints) intReturns the count ofnode's outgoing edges (equal tosuccessors(node).size()) in a directed graph.protected final voidvalidateEndpoints(EndpointPair<?> endpoints) ThrowsIllegalArgumentExceptionif the ordering ofendpointsis not compatible with the directionality of this graph.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.google.common.graph.BaseGraph
adjacentNodes, allowsSelfLoops, isDirected, nodeOrder, nodes, predecessors, successors
-
Constructor Details
-
AbstractBaseGraph
AbstractBaseGraph()
-
-
Method Details
-
edgeCount
protected long edgeCount()Returns the number of edges in this graph; used to calculate the size ofedges(). 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 ofBaseGraph.nodes()andBaseGraph.successors(Object). -
incidentEdgeOrder
Description copied from interface:BaseGraphReturns anElementOrderthat specifies the order of iteration for the elements ofBaseGraph.edges(),BaseGraph.adjacentNodes(Object),BaseGraph.predecessors(Object),BaseGraph.successors(Object)andBaseGraph.incidentEdges(Object).- Specified by:
incidentEdgeOrderin interfaceBaseGraph<N>
-
incidentEdges
Description copied from interface:BaseGraphReturns the edges in this graph whose endpoints includenode.This is equal to the union of incoming and outgoing edges.
- Specified by:
incidentEdgesin interfaceBaseGraph<N>
-
degree
Description copied from interface:BaseGraphReturns the count ofnode's incident edges, counting self-loops twice (equivalently, the number of times an edge touchesnode).For directed graphs, this is equal to
inDegree(node) + outDegree(node).For undirected graphs, this is equal to
incidentEdges(node).size()+ (number of self-loops incident tonode).If the count is greater than
Integer.MAX_VALUE, returnsInteger.MAX_VALUE. -
inDegree
Description copied from interface:BaseGraphReturns the count ofnode's incoming edges (equal topredecessors(node).size()) in a directed graph. In an undirected graph, returns theBaseGraph.degree(Object).If the count is greater than
Integer.MAX_VALUE, returnsInteger.MAX_VALUE. -
outDegree
Description copied from interface:BaseGraphReturns the count ofnode's outgoing edges (equal tosuccessors(node).size()) in a directed graph. In an undirected graph, returns theBaseGraph.degree(Object).If the count is greater than
Integer.MAX_VALUE, returnsInteger.MAX_VALUE. -
hasEdgeConnecting
Description copied from interface:BaseGraphReturns true if there is an edge that directly connectsnodeUtonodeV. This is equivalent tonodes().contains(nodeU) && successors(nodeU).contains(nodeV).In an undirected graph, this is equal to
hasEdgeConnecting(nodeV, nodeU).- Specified by:
hasEdgeConnectingin interfaceBaseGraph<N>
-
hasEdgeConnecting
Description copied from interface:BaseGraphReturns true if there is an edge that directly connectsendpoints(in the order, if any, specified byendpoints). This is equivalent toedges().contains(endpoints).Unlike the other
EndpointPair-accepting methods, this method does not throw if the endpoints are unordered; it simply returns false. This is for consistency with the behavior ofCollection#contains(Object)(which does not generally throw if the object cannot be present in the collection), and the desire to have this method's behavior be compatible withedges().contains(endpoints).- Specified by:
hasEdgeConnectingin interfaceBaseGraph<N>
-
validateEndpoints
ThrowsIllegalArgumentExceptionif the ordering ofendpointsis not compatible with the directionality of this graph. -
isOrderingCompatible
-