abstract class ForwardingGraph<N> extends AbstractGraph<N>
Graph
implementations to be backed by ValueGraph
s. This is not
currently planned to be released as a general-purpose forwarding class.Constructor and Description |
---|
ForwardingGraph() |
Modifier and Type | Method and Description |
---|---|
java.util.Set<N> |
adjacentNodes(java.lang.Object node)
Returns the nodes which have an incident edge in common with
node in this graph. |
boolean |
allowsSelfLoops()
Returns true if this graph allows self-loops (edges that connect a node to itself).
|
int |
degree(java.lang.Object node)
Returns the count of
node 's incident edges, counting self-loops twice (equivalently,
the number of times an edge touches node ). |
protected abstract Graph<N> |
delegate() |
java.util.Set<EndpointPair<N>> |
edges()
A reasonable default implementation of
Graph.edges() defined in terms of Graph.nodes() and Graph.successors(Object) . |
int |
inDegree(java.lang.Object node)
Returns the count of
node 's incoming edges (equal to predecessors(node).size() )
in a directed graph. |
boolean |
isDirected()
Returns true if the edges in this graph are directed.
|
ElementOrder<N> |
nodeOrder()
Returns the order of iteration for the elements of
Graph.nodes() . |
java.util.Set<N> |
nodes()
Returns all nodes in this graph, in the order specified by
Graph.nodeOrder() . |
int |
outDegree(java.lang.Object node)
Returns the count of
node 's outgoing edges (equal to successors(node).size() )
in a directed graph. |
java.util.Set<N> |
predecessors(java.lang.Object node)
Returns all nodes in this graph adjacent to
node which can be reached by traversing
node 's incoming edges against the direction (if any) of the edge. |
java.util.Set<N> |
successors(java.lang.Object node)
Returns all nodes in this graph adjacent to
node which can be reached by traversing
node 's outgoing edges in the direction (if any) of the edge. |
edgeCount, toString
public java.util.Set<N> nodes()
Graph
Graph.nodeOrder()
.public java.util.Set<EndpointPair<N>> edges()
AbstractGraph
Graph.edges()
defined in terms of Graph.nodes()
and Graph.successors(Object)
.public boolean isDirected()
Graph
source node
to a target node
, while
undirected edges connect a pair of nodes to each other.public boolean allowsSelfLoops()
Graph
UnsupportedOperationException
.public ElementOrder<N> nodeOrder()
Graph
Graph.nodes()
.public java.util.Set<N> adjacentNodes(java.lang.Object node)
Graph
node
in this graph.public java.util.Set<N> predecessors(java.lang.Object node)
Graph
node
which can be reached by traversing
node
's incoming edges against the direction (if any) of the edge.
In an undirected graph, this is equivalent to Graph.adjacentNodes(Object)
.
public java.util.Set<N> successors(java.lang.Object node)
Graph
node
which can be reached by traversing
node
's outgoing edges in the direction (if any) of the edge.
In an undirected graph, this is equivalent to Graph.adjacentNodes(Object)
.
This is not the same as "all nodes reachable from node
by following outgoing
edges". For that functionality, see Graphs.reachableNodes(Graph, Object)
.
public int degree(java.lang.Object node)
Graph
node
's incident edges, counting self-loops twice (equivalently,
the number of times an edge touches node
).
For directed graphs, this is equal to inDegree(node) + outDegree(node)
.
For undirected graphs, this is equal to adjacentNodes(node).size()
+ (1 if node
has an incident self-loop, 0 otherwise).
If the count is greater than Integer.MAX_VALUE
, returns Integer.MAX_VALUE
.
public int inDegree(java.lang.Object node)
Graph
node
's incoming edges (equal to predecessors(node).size()
)
in a directed graph. In an undirected graph, returns the Graph.degree(Object)
.
If the count is greater than Integer.MAX_VALUE
, returns Integer.MAX_VALUE
.
public int outDegree(java.lang.Object node)
Graph
node
's outgoing edges (equal to successors(node).size()
)
in a directed graph. In an undirected graph, returns the Graph.degree(Object)
.
If the count is greater than Integer.MAX_VALUE
, returns Integer.MAX_VALUE
.