abstract class ForwardingNetwork<N,E> extends AbstractNetwork<N,E>
Network
implementations to be backed by a provided delegate. This is not
currently planned to be released as a general-purpose forwarding class.Constructor and Description |
---|
ForwardingNetwork() |
Modifier and Type | Method and Description |
---|---|
java.util.Set<E> |
adjacentEdges(E edge)
Returns the edges which have an
incident node in common with
edge . |
java.util.Set<N> |
adjacentNodes(N node)
Returns the nodes which have an incident edge in common with
node in this network. |
boolean |
allowsParallelEdges()
Returns true if this network allows parallel edges.
|
boolean |
allowsSelfLoops()
Returns true if this network allows self-loops (edges that connect a node to itself).
|
int |
degree(N node)
Returns the count of
node 's incident edges , counting
self-loops twice (equivalently, the number of times an edge touches node ). |
protected abstract Network<N,E> |
delegate() |
java.util.Optional<E> |
edgeConnecting(EndpointPair<N> endpoints)
Returns the single edge that directly connects
endpoints (in the order, if any,
specified by endpoints ), if one is present, or Optional.empty() if no such edge
exists. |
java.util.Optional<E> |
edgeConnecting(N nodeU,
N nodeV)
Returns the single edge that directly connects
nodeU to nodeV , if one is
present, or Optional.empty() if no such edge exists. |
E |
edgeConnectingOrNull(EndpointPair<N> endpoints)
Returns the single edge that directly connects
endpoints (in the order, if any,
specified by endpoints ), if one is present, or null if no such edge exists. |
E |
edgeConnectingOrNull(N nodeU,
N nodeV)
Returns the single edge that directly connects
nodeU to nodeV , if one is
present, or null if no such edge exists. |
ElementOrder<E> |
edgeOrder()
Returns the order of iteration for the elements of
Network.edges() . |
java.util.Set<E> |
edges()
Returns all edges in this network, in the order specified by
Network.edgeOrder() . |
java.util.Set<E> |
edgesConnecting(EndpointPair<N> endpoints)
Returns the set of edges that each directly connect
endpoints (in the order, if any,
specified by endpoints ). |
java.util.Set<E> |
edgesConnecting(N nodeU,
N nodeV)
Returns the set of edges that each directly connect
nodeU to nodeV . |
boolean |
hasEdgeConnecting(EndpointPair<N> endpoints)
Returns true if there is an edge that directly connects
endpoints (in the order, if
any, specified by endpoints ). |
boolean |
hasEdgeConnecting(N nodeU,
N nodeV)
Returns true if there is an edge that directly connects
nodeU to nodeV . |
java.util.Set<E> |
incidentEdges(N node)
Returns the edges whose
incident nodes in this network include
node . |
EndpointPair<N> |
incidentNodes(E edge)
Returns the nodes which are the endpoints of
edge in this network. |
int |
inDegree(N node)
Returns the count of
node 's incoming edges in a directed
network. |
java.util.Set<E> |
inEdges(N node)
Returns all edges in this network which can be traversed in the direction (if any) of the edge
to end at
node . |
boolean |
isDirected()
Returns true if the edges in this network are directed.
|
ElementOrder<N> |
nodeOrder()
Returns the order of iteration for the elements of
Network.nodes() . |
java.util.Set<N> |
nodes()
Returns all nodes in this network, in the order specified by
Network.nodeOrder() . |
int |
outDegree(N node)
Returns the count of
node 's outgoing edges in a directed
network. |
java.util.Set<E> |
outEdges(N node)
Returns all edges in this network which can be traversed in the direction (if any) of the edge
starting from
node . |
java.util.Set<N> |
predecessors(N node)
Returns all nodes in this network 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(N node)
Returns all nodes in this network adjacent to
node which can be reached by traversing
node 's outgoing edges in the direction (if any) of the edge. |
asGraph, equals, hashCode, isOrderingCompatible, toString, validateEndpoints
public java.util.Set<N> nodes()
Network
Network.nodeOrder()
.public java.util.Set<E> edges()
Network
Network.edgeOrder()
.public boolean isDirected()
Network
source node
to a target node
, while
undirected edges connect a pair of nodes to each other.public boolean allowsParallelEdges()
Network
IllegalArgumentException
.public boolean allowsSelfLoops()
Network
IllegalArgumentException
.public ElementOrder<N> nodeOrder()
Network
Network.nodes()
.public ElementOrder<E> edgeOrder()
Network
Network.edges()
.public java.util.Set<N> adjacentNodes(N node)
Network
node
in this network.
This is equal to the union of Network.predecessors(Object)
and Network.successors(Object)
.
public java.util.Set<N> predecessors(N node)
Network
node
which can be reached by traversing
node
's incoming edges against the direction (if any) of the edge.
In an undirected network, this is equivalent to Network.adjacentNodes(Object)
.
public java.util.Set<N> successors(N node)
Network
node
which can be reached by traversing
node
's outgoing edges in the direction (if any) of the edge.
In an undirected network, this is equivalent to Network.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 java.util.Set<E> incidentEdges(N node)
Network
incident nodes
in this network include
node
.
This is equal to the union of Network.inEdges(Object)
and Network.outEdges(Object)
.
public java.util.Set<E> inEdges(N node)
Network
node
.
In a directed network, an incoming edge's EndpointPair.target()
equals node
.
In an undirected network, this is equivalent to Network.incidentEdges(Object)
.
public java.util.Set<E> outEdges(N node)
Network
node
.
In a directed network, an outgoing edge's EndpointPair.source()
equals node
.
In an undirected network, this is equivalent to Network.incidentEdges(Object)
.
public EndpointPair<N> incidentNodes(E edge)
Network
edge
in this network.public java.util.Set<E> adjacentEdges(E edge)
Network
incident node
in common with
edge
. An edge is not considered adjacent to itself.adjacentEdges
in interface Network<N,E>
adjacentEdges
in class AbstractNetwork<N,E>
public int degree(N node)
Network
node
's incident edges
, counting
self-loops twice (equivalently, the number of times an edge touches node
).
For directed networks, this is equal to inDegree(node) + outDegree(node)
.
For undirected networks, this is equal to incidentEdges(node).size()
+ (number of
self-loops incident to node
).
If the count is greater than Integer.MAX_VALUE
, returns Integer.MAX_VALUE
.
public int inDegree(N node)
Network
node
's incoming edges
in a directed
network. In an undirected network, returns the Network.degree(Object)
.
If the count is greater than Integer.MAX_VALUE
, returns Integer.MAX_VALUE
.
public int outDegree(N node)
Network
node
's outgoing edges
in a directed
network. In an undirected network, returns the Network.degree(Object)
.
If the count is greater than Integer.MAX_VALUE
, returns Integer.MAX_VALUE
.
public java.util.Set<E> edgesConnecting(N nodeU, N nodeV)
Network
nodeU
to nodeV
.
In an undirected network, this is equal to edgesConnecting(nodeV, nodeU)
.
The resulting set of edges will be parallel (i.e. have equal Network.incidentNodes(Object)
.
If this network does not allow parallel edges
, the resulting set
will contain at most one edge (equivalent to edgeConnecting(nodeU, nodeV).asSet()
).
edgesConnecting
in interface Network<N,E>
edgesConnecting
in class AbstractNetwork<N,E>
public java.util.Set<E> edgesConnecting(EndpointPair<N> endpoints)
Network
endpoints
(in the order, if any,
specified by endpoints
).
The resulting set of edges will be parallel (i.e. have equal Network.incidentNodes(Object)
.
If this network does not allow parallel edges
, the resulting set
will contain at most one edge (equivalent to edgeConnecting(endpoints).asSet()
).
If this network is directed, endpoints
must be ordered.
edgesConnecting
in interface Network<N,E>
edgesConnecting
in class AbstractNetwork<N,E>
public java.util.Optional<E> edgeConnecting(N nodeU, N nodeV)
Network
nodeU
to nodeV
, if one is
present, or Optional.empty()
if no such edge exists.
In an undirected network, this is equal to edgeConnecting(nodeV, nodeU)
.
edgeConnecting
in interface Network<N,E>
edgeConnecting
in class AbstractNetwork<N,E>
public java.util.Optional<E> edgeConnecting(EndpointPair<N> endpoints)
Network
endpoints
(in the order, if any,
specified by endpoints
), if one is present, or Optional.empty()
if no such edge
exists.
If this graph is directed, the endpoints must be ordered.
edgeConnecting
in interface Network<N,E>
edgeConnecting
in class AbstractNetwork<N,E>
public E edgeConnectingOrNull(N nodeU, N nodeV)
Network
nodeU
to nodeV
, if one is
present, or null
if no such edge exists.
In an undirected network, this is equal to edgeConnectingOrNull(nodeV, nodeU)
.
edgeConnectingOrNull
in interface Network<N,E>
edgeConnectingOrNull
in class AbstractNetwork<N,E>
public E edgeConnectingOrNull(EndpointPair<N> endpoints)
Network
endpoints
(in the order, if any,
specified by endpoints
), if one is present, or null
if no such edge exists.
If this graph is directed, the endpoints must be ordered.
edgeConnectingOrNull
in interface Network<N,E>
edgeConnectingOrNull
in class AbstractNetwork<N,E>
public boolean hasEdgeConnecting(N nodeU, N nodeV)
Network
nodeU
to nodeV
. This is
equivalent to nodes().contains(nodeU) && successors(nodeU).contains(nodeV)
, and to
edgeConnectingOrNull(nodeU, nodeV) != null
.
In an undirected graph, this is equal to hasEdgeConnecting(nodeV, nodeU)
.
hasEdgeConnecting
in interface Network<N,E>
hasEdgeConnecting
in class AbstractNetwork<N,E>
public boolean hasEdgeConnecting(EndpointPair<N> endpoints)
Network
endpoints
(in the order, if
any, specified by endpoints
).
Unlike the other EndpointPair
-accepting methods, this method does not throw if the
endpoints are unordered and the graph is directed; it simply returns false
. This is for
consistency with Graph.hasEdgeConnecting(EndpointPair)
and ValueGraph.hasEdgeConnecting(EndpointPair)
.
hasEdgeConnecting
in interface Network<N,E>
hasEdgeConnecting
in class AbstractNetwork<N,E>