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 ofGraph.edges()
.Set
<EndpointPair<N>> edges()
An implementation ofBaseGraph.edges()
defined in terms ofGraph.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 a live view of 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) 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
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 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()
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 a live view of the edges in this graph whose endpoints includenode
.This is equal to the union of incoming and outgoing edges.
If
node
is removed from the graph after this method is called, theSet
view
returned by this method will be invalidated, and will throwIllegalStateException
if it is accessed in any way, with the following exceptions:view.equals(view)
evaluates totrue
(but any other `equals()` expression involvingview
will throw)hashCode()
does not throw- if
node
is re-added to the graph after having been removed,view
's behavior is undefined
- 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 ofinvalid reference
Collection#contains(Object)
edges().contains(endpoints)
.- Specified by:
hasEdgeConnecting
in interfaceBaseGraph<N>
-
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
-