Class ForwardingNetwork<N,E>
- All Implemented Interfaces:
Network<N,
,E> PredecessorsFunction<N>
,SuccessorsFunction<N>
- Direct Known Subclasses:
Graphs.TransposedNetwork
Network
implementations to be backed by a provided delegate. This is not
currently planned to be released as a general-purpose forwarding class.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadjacentEdges
(E edge) Returns a live view of the edges which have anincident node
in common withedge
.adjacentNodes
(N node) Returns a live view of the nodes which have an incident edge in common withnode
in this graph.boolean
Returns true if this network allows parallel edges.boolean
Returns true if this network allows self-loops (edges that connect a node to itself).int
Returns the count ofnode
'sincident edges
, counting self-loops twice (equivalently, the number of times an edge touchesnode
).delegate()
edgeConnecting
(EndpointPair<N> endpoints) Returns the single edge that directly connectsendpoints
(in the order, if any, specified byendpoints
), if one is present, orOptional.empty()
if no such edge exists.edgeConnecting
(N nodeU, N nodeV) Returns the single edge that directly connectsnodeU
tonodeV
, if one is present, orOptional.empty()
if no such edge exists.edgeConnectingOrNull
(EndpointPair<N> endpoints) Returns the single edge that directly connectsendpoints
(in the order, if any, specified byendpoints
), if one is present, ornull
if no such edge exists.edgeConnectingOrNull
(N nodeU, N nodeV) Returns the single edge that directly connectsnodeU
tonodeV
, if one is present, ornull
if no such edge exists.Returns the order of iteration for the elements ofNetwork.edges()
.edges()
Returns all edges in this network, in the order specified byNetwork.edgeOrder()
.edgesConnecting
(EndpointPair<N> endpoints) Returns a live view of the set of edges that each directly connectendpoints
(in the order, if any, specified byendpoints
).edgesConnecting
(N nodeU, N nodeV) Returns a live view of the set of edges that each directly connectnodeU
tonodeV
.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
.incidentEdges
(N node) Returns a live view of the edges whoseincident nodes
in this network includenode
.incidentNodes
(E edge) Returns the nodes which are the endpoints ofedge
in this network.int
Returns the count ofnode
'sincoming edges
in a directed network.Returns a live view of all edges in this network which can be traversed in the direction (if any) of the edge to end atnode
.boolean
Returns true if the edges in this network are directed.Returns the order of iteration for the elements ofNetwork.nodes()
.nodes()
Returns all nodes in this network, in the order specified byNetwork.nodeOrder()
.int
Returns the count ofnode
'soutgoing edges
in a directed network.Returns a live view of all edges in this network which can be traversed in the direction (if any) of the edge starting fromnode
.predecessors
(N node) Returns a live view of all nodes in this network adjacent tonode
which can be reached by traversingnode
's incoming edges against the direction (if any) of the edge.successors
(N node) Returns a live view of all nodes in this network adjacent tonode
which can be reached by traversingnode
's outgoing edges in the direction (if any) of the edge.Methods inherited from class com.google.common.graph.AbstractNetwork
asGraph, edgeInvalidatableSet, equals, hashCode, isOrderingCompatible, nodeInvalidatableSet, nodePairInvalidatableSet, toString, validateEndpoints
-
Constructor Details
-
ForwardingNetwork
ForwardingNetwork()
-
-
Method Details
-
delegate
-
nodes
Description copied from interface:Network
Returns all nodes in this network, in the order specified byNetwork.nodeOrder()
. -
edges
Description copied from interface:Network
Returns all edges in this network, in the order specified byNetwork.edgeOrder()
. -
isDirected
public boolean isDirected()Description copied from interface:Network
Returns true if the edges in this network are directed. Directed edges connect asource node
to atarget node
, while undirected edges connect a pair of nodes to each other. -
allowsParallelEdges
public boolean allowsParallelEdges()Description copied from interface:Network
Returns true if this network allows parallel edges. Attempting to add a parallel edge to a network that does not allow them will throw anIllegalArgumentException
. -
allowsSelfLoops
public boolean allowsSelfLoops()Description copied from interface:Network
Returns true if this network allows self-loops (edges that connect a node to itself). Attempting to add a self-loop to a network that does not allow them will throw anIllegalArgumentException
. -
nodeOrder
Description copied from interface:Network
Returns the order of iteration for the elements ofNetwork.nodes()
. -
edgeOrder
Description copied from interface:Network
Returns the order of iteration for the elements ofNetwork.edges()
. -
adjacentNodes
Description copied from interface:Network
Returns a live view of the nodes which have an incident edge in common withnode
in this graph.This is equal to the union of
Network.predecessors(Object)
andNetwork.successors(Object)
.If
node
is removed from the network 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 network after having been removed,view
's behavior is undefined
-
predecessors
Description copied from interface:Network
Returns a live view of all nodes in this network adjacent tonode
which can be reached by traversingnode
's incoming edges against the direction (if any) of the edge.In an undirected network, this is equivalent to
Network.adjacentNodes(Object)
.If
node
is removed from the network after this method is called, the `Set` returned by this method will be invalidated, and will throw `IllegalStateException` if it is accessed in any way. -
successors
Description copied from interface:Network
Returns a live view of all nodes in this network adjacent tonode
which can be reached by traversingnode
'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, seeGraphs.reachableNodes(Graph, Object)
.If
node
is removed from the network 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 network after having been removed,view
's behavior is undefined
-
incidentEdges
Description copied from interface:Network
Returns a live view of the edges whoseincident nodes
in this network includenode
.This is equal to the union of
Network.inEdges(Object)
andNetwork.outEdges(Object)
.If
node
is removed from the network 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 network after having been removed,view
's behavior is undefined
-
inEdges
Description copied from interface:Network
Returns a live view of all edges in this network which can be traversed in the direction (if any) of the edge to end atnode
.In a directed network, an incoming edge's
EndpointPair.target()
equalsnode
.In an undirected network, this is equivalent to
Network.incidentEdges(Object)
.If
node
is removed from the network 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 network after having been removed,view
's behavior is undefined
-
outEdges
Description copied from interface:Network
Returns a live view of all edges in this network which can be traversed in the direction (if any) of the edge starting fromnode
.In a directed network, an outgoing edge's
EndpointPair.source()
equalsnode
.In an undirected network, this is equivalent to
Network.incidentEdges(Object)
.If
node
is removed from the network 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 network after having been removed,view
's behavior is undefined
-
incidentNodes
Description copied from interface:Network
Returns the nodes which are the endpoints ofedge
in this network. -
adjacentEdges
Description copied from interface:Network
Returns a live view of the edges which have anincident node
in common withedge
. An edge is not considered adjacent to itself.If
edge
is removed from the network 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
edge
is re-added to the network after having been removed,view
's behavior is undefined
- Specified by:
adjacentEdges
in interfaceNetwork<N,
E> - Overrides:
adjacentEdges
in classAbstractNetwork<N,
E>
-
degree
Description copied from interface:Network
Returns the count ofnode
'sincident edges
, counting self-loops twice (equivalently, the number of times an edge touchesnode
).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 tonode
).If the count is greater than
Integer.MAX_VALUE
, returnsInteger.MAX_VALUE
. -
inDegree
Description copied from interface:Network
Returns the count ofnode
'sincoming edges
in a directed network. In an undirected network, returns theNetwork.degree(Object)
.If the count is greater than
Integer.MAX_VALUE
, returnsInteger.MAX_VALUE
. -
outDegree
Description copied from interface:Network
Returns the count ofnode
'soutgoing edges
in a directed network. In an undirected network, returns theNetwork.degree(Object)
.If the count is greater than
Integer.MAX_VALUE
, returnsInteger.MAX_VALUE
. -
edgesConnecting
Description copied from interface:Network
Returns a live view of the set of edges that each directly connectnodeU
tonodeV
.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 notallow parallel edges
, the resulting set will contain at most one edge (equivalent toedgeConnecting(nodeU, nodeV).asSet()
).If either
nodeU
ornodeV
are removed from the network 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
nodeU
ornodeV
are re-added to the network after having been removed,view
's behavior is undefined
- Specified by:
edgesConnecting
in interfaceNetwork<N,
E> - Overrides:
edgesConnecting
in classAbstractNetwork<N,
E>
-
edgesConnecting
Description copied from interface:Network
Returns a live view of the set of edges that each directly connectendpoints
(in the order, if any, specified byendpoints
).The resulting set of edges will be parallel (i.e. have equal
Network.incidentNodes(Object)
). If this network does notallow parallel edges
, the resulting set will contain at most one edge (equivalent toedgeConnecting(endpoints).asSet()
).If this network is directed,
endpoints
must be ordered.If either element of
endpoints
is removed from the network 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 either endpoint is re-added to the network after having been removed,
view
's behavior is undefined
- Specified by:
edgesConnecting
in interfaceNetwork<N,
E> - Overrides:
edgesConnecting
in classAbstractNetwork<N,
E>
-
edgeConnecting
Description copied from interface:Network
Returns the single edge that directly connectsnodeU
tonodeV
, if one is present, orOptional.empty()
if no such edge exists.In an undirected network, this is equal to
edgeConnecting(nodeV, nodeU)
.- Specified by:
edgeConnecting
in interfaceNetwork<N,
E> - Overrides:
edgeConnecting
in classAbstractNetwork<N,
E>
-
edgeConnecting
Description copied from interface:Network
Returns the single edge that directly connectsendpoints
(in the order, if any, specified byendpoints
), if one is present, orOptional.empty()
if no such edge exists.If this network is directed, the endpoints must be ordered.
- Specified by:
edgeConnecting
in interfaceNetwork<N,
E> - Overrides:
edgeConnecting
in classAbstractNetwork<N,
E>
-
edgeConnectingOrNull
Description copied from interface:Network
Returns the single edge that directly connectsnodeU
tonodeV
, if one is present, ornull
if no such edge exists.In an undirected network, this is equal to
edgeConnectingOrNull(nodeV, nodeU)
.- Specified by:
edgeConnectingOrNull
in interfaceNetwork<N,
E> - Overrides:
edgeConnectingOrNull
in classAbstractNetwork<N,
E>
-
edgeConnectingOrNull
Description copied from interface:Network
Returns the single edge that directly connectsendpoints
(in the order, if any, specified byendpoints
), if one is present, ornull
if no such edge exists.If this network is directed, the endpoints must be ordered.
- Specified by:
edgeConnectingOrNull
in interfaceNetwork<N,
E> - Overrides:
edgeConnectingOrNull
in classAbstractNetwork<N,
E>
-
hasEdgeConnecting
Description copied from interface:Network
Returns true if there is an edge that directly connectsnodeU
tonodeV
. This is equivalent tonodes().contains(nodeU) && successors(nodeU).contains(nodeV)
, and toedgeConnectingOrNull(nodeU, nodeV) != null
.In an undirected network, this is equal to
hasEdgeConnecting(nodeV, nodeU)
.- Specified by:
hasEdgeConnecting
in interfaceNetwork<N,
E> - Overrides:
hasEdgeConnecting
in classAbstractNetwork<N,
E>
-
hasEdgeConnecting
Description copied from interface:Network
Returns true if there is an edge that directly connectsendpoints
(in the order, if any, specified byendpoints
).Unlike the other
EndpointPair
-accepting methods, this method does not throw if the endpoints are unordered and the network is directed; it simply returnsfalse
. This is for consistency withGraph.hasEdgeConnecting(EndpointPair)
andValueGraph.hasEdgeConnecting(EndpointPair)
.- Specified by:
hasEdgeConnecting
in interfaceNetwork<N,
E> - Overrides:
hasEdgeConnecting
in classAbstractNetwork<N,
E>
-