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 TypeMethodDescriptionint
Returns the count ofnode
's incident edges, counting self-loops twice (equivalently, the number of times an edge touchesnode
).protected long
Returns 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)
.boolean
hasEdgeConnecting
(EndpointPair<N> endpoints) Returns true if there is an edge that directly connectsendpoints
(in the order, if any, specified byendpoints
).boolean
hasEdgeConnecting
(N nodeU, N nodeV) Returns true if there is an edge that directly connectsnodeU
tonodeV
.Returns anElementOrder
that 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
.int
Returns the count ofnode
's incoming edges (equal topredecessors(node).size()
) in a directed graph.protected final boolean
isOrderingCompatible
(EndpointPair<?> endpoints) int
Returns the count ofnode
's outgoing edges (equal tosuccessors(node).size()
) in a directed 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, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:BaseGraph
Returns anElementOrder
that specifies the order of iteration for the elements ofBaseGraph.edges()
,BaseGraph.adjacentNodes(Object)
,BaseGraph.predecessors(Object)
,BaseGraph.successors(Object)
andBaseGraph.incidentEdges(Object)
.- Specified by:
incidentEdgeOrder
in interfaceBaseGraph<N>
-
incidentEdges
Description copied from interface:BaseGraph
Returns the edges in this graph whose endpoints includenode
.This is equal to the union of incoming and outgoing edges.
- Specified by:
incidentEdges
in interfaceBaseGraph<N>
-
degree
Description copied from interface:BaseGraph
Returns 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:BaseGraph
Returns 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:BaseGraph
Returns 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:BaseGraph
Returns true if there is an edge that directly connectsnodeU
tonodeV
. This is equivalent tonodes().contains(nodeU) && successors(nodeU).contains(nodeV)
.In an undirected graph, this is equal to
hasEdgeConnecting(nodeV, nodeU)
.- Specified by:
hasEdgeConnecting
in interfaceBaseGraph<N>
-
hasEdgeConnecting
Description copied from interface:BaseGraph
Returns 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:
hasEdgeConnecting
in interfaceBaseGraph<N>
-
validateEndpoints
ThrowsIllegalArgumentException
if the ordering ofendpoints
is not compatible with the directionality of this graph. -
isOrderingCompatible
-