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 nodein common withedge.adjacentNodes(N node) Returns a live view of the nodes which have an incident edge in common withnodein this graph.booleanReturns true if this network allows parallel edges.booleanReturns true if this network allows self-loops (edges that connect a node to itself).intReturns 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 connectsnodeUtonodeV, 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, ornullif no such edge exists.edgeConnectingOrNull(N nodeU, N nodeV) Returns the single edge that directly connectsnodeUtonodeV, if one is present, ornullif 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 connectnodeUtonodeV.booleanhasEdgeConnecting(EndpointPair<N> endpoints) Returns true if there is an edge that directly connectsendpoints(in the order, if any, specified byendpoints).booleanhasEdgeConnecting(N nodeU, N nodeV) Returns true if there is an edge that directly connectsnodeUtonodeV.incidentEdges(N node) Returns a live view of the edges whoseincident nodesin this network includenode.incidentNodes(E edge) Returns the nodes which are the endpoints ofedgein this network.intReturns the count ofnode'sincoming edgesin 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.booleanReturns 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().intReturns the count ofnode'soutgoing edgesin 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 tonodewhich 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 tonodewhich 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:NetworkReturns all nodes in this network, in the order specified byNetwork.nodeOrder(). -
edges
Description copied from interface:NetworkReturns all edges in this network, in the order specified byNetwork.edgeOrder(). -
isDirected
public boolean isDirected()Description copied from interface:NetworkReturns true if the edges in this network are directed. Directed edges connect asource nodeto atarget node, while undirected edges connect a pair of nodes to each other. -
allowsParallelEdges
public boolean allowsParallelEdges()Description copied from interface:NetworkReturns 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:NetworkReturns 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:NetworkReturns the order of iteration for the elements ofNetwork.nodes(). -
edgeOrder
Description copied from interface:NetworkReturns the order of iteration for the elements ofNetwork.edges(). -
adjacentNodes
Description copied from interface:NetworkReturns a live view of the nodes which have an incident edge in common withnodein this graph.This is equal to the union of
Network.predecessors(Object)andNetwork.successors(Object).If
nodeis removed from the network after this method is called, theSetviewreturned by this method will be invalidated, and will throwIllegalStateExceptionif it is accessed in any way, with the following exceptions:view.equals(view)evaluates totrue(but any other `equals()` expression involvingviewwill throw)hashCode()does not throw- if
nodeis re-added to the network after having been removed,view's behavior is undefined
-
predecessors
Description copied from interface:NetworkReturns a live view of all nodes in this network adjacent tonodewhich 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
nodeis 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:NetworkReturns a live view of all nodes in this network adjacent tonodewhich 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
nodeby following outgoing edges". For that functionality, seeGraphs.reachableNodes(Graph, Object).If
nodeis removed from the network after this method is called, theSetviewreturned by this method will be invalidated, and will throwIllegalStateExceptionif it is accessed in any way, with the following exceptions:view.equals(view)evaluates totrue(but any other `equals()` expression involvingviewwill throw)hashCode()does not throw- if
nodeis re-added to the network after having been removed,view's behavior is undefined
-
incidentEdges
Description copied from interface:NetworkReturns a live view of the edges whoseincident nodesin this network includenode.This is equal to the union of
Network.inEdges(Object)andNetwork.outEdges(Object).If
nodeis removed from the network after this method is called, theSetviewreturned by this method will be invalidated, and will throwIllegalStateExceptionif it is accessed in any way, with the following exceptions:view.equals(view)evaluates totrue(but any other `equals()` expression involvingviewwill throw)hashCode()does not throw- if
nodeis re-added to the network after having been removed,view's behavior is undefined
-
inEdges
Description copied from interface:NetworkReturns 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
nodeis removed from the network after this method is called, theSetviewreturned by this method will be invalidated, and will throwIllegalStateExceptionif it is accessed in any way, with the following exceptions:view.equals(view)evaluates totrue(but any other `equals()` expression involvingviewwill throw)hashCode()does not throw- if
nodeis re-added to the network after having been removed,view's behavior is undefined
-
outEdges
Description copied from interface:NetworkReturns 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
nodeis removed from the network after this method is called, theSetviewreturned by this method will be invalidated, and will throwIllegalStateExceptionif it is accessed in any way, with the following exceptions:view.equals(view)evaluates totrue(but any other `equals()` expression involvingviewwill throw)hashCode()does not throw- if
nodeis re-added to the network after having been removed,view's behavior is undefined
-
incidentNodes
Description copied from interface:NetworkReturns the nodes which are the endpoints ofedgein this network. -
adjacentEdges
Description copied from interface:NetworkReturns a live view of the edges which have anincident nodein common withedge. An edge is not considered adjacent to itself.If
edgeis removed from the network after this method is called, theSetviewreturned by this method will be invalidated, and will throwIllegalStateExceptionif it is accessed in any way, with the following exceptions:view.equals(view)evaluates totrue(but any other `equals()` expression involvingviewwill throw)hashCode()does not throw- if
edgeis re-added to the network after having been removed,view's behavior is undefined
- Specified by:
adjacentEdgesin interfaceNetwork<N,E> - Overrides:
adjacentEdgesin classAbstractNetwork<N,E>
-
degree
Description copied from interface:NetworkReturns 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:NetworkReturns the count ofnode'sincoming edgesin 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:NetworkReturns the count ofnode'soutgoing edgesin 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:NetworkReturns a live view of the set of edges that each directly connectnodeUtonodeV.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
nodeUornodeVare removed from the network after this method is called, theSetviewreturned by this method will be invalidated, and will throwIllegalStateExceptionif it is accessed in any way, with the following exceptions:view.equals(view)evaluates totrue(but any other `equals()` expression involvingviewwill throw)hashCode()does not throw- if
nodeUornodeVare re-added to the network after having been removed,view's behavior is undefined
- Specified by:
edgesConnectingin interfaceNetwork<N,E> - Overrides:
edgesConnectingin classAbstractNetwork<N,E>
-
edgesConnecting
Description copied from interface:NetworkReturns 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,
endpointsmust be ordered.If either element of
endpointsis removed from the network after this method is called, theSetviewreturned by this method will be invalidated, and will throwIllegalStateExceptionif it is accessed in any way, with the following exceptions:view.equals(view)evaluates totrue(but any other `equals()` expression involvingviewwill 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:
edgesConnectingin interfaceNetwork<N,E> - Overrides:
edgesConnectingin classAbstractNetwork<N,E>
-
edgeConnecting
Description copied from interface:NetworkReturns the single edge that directly connectsnodeUtonodeV, if one is present, orOptional.empty()if no such edge exists.In an undirected network, this is equal to
edgeConnecting(nodeV, nodeU).- Specified by:
edgeConnectingin interfaceNetwork<N,E> - Overrides:
edgeConnectingin classAbstractNetwork<N,E>
-
edgeConnecting
Description copied from interface:NetworkReturns 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:
edgeConnectingin interfaceNetwork<N,E> - Overrides:
edgeConnectingin classAbstractNetwork<N,E>
-
edgeConnectingOrNull
Description copied from interface:NetworkReturns the single edge that directly connectsnodeUtonodeV, if one is present, ornullif no such edge exists.In an undirected network, this is equal to
edgeConnectingOrNull(nodeV, nodeU).- Specified by:
edgeConnectingOrNullin interfaceNetwork<N,E> - Overrides:
edgeConnectingOrNullin classAbstractNetwork<N,E>
-
edgeConnectingOrNull
Description copied from interface:NetworkReturns the single edge that directly connectsendpoints(in the order, if any, specified byendpoints), if one is present, ornullif no such edge exists.If this network is directed, the endpoints must be ordered.
- Specified by:
edgeConnectingOrNullin interfaceNetwork<N,E> - Overrides:
edgeConnectingOrNullin classAbstractNetwork<N,E>
-
hasEdgeConnecting
Description copied from interface:NetworkReturns true if there is an edge that directly connectsnodeUtonodeV. 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:
hasEdgeConnectingin interfaceNetwork<N,E> - Overrides:
hasEdgeConnectingin classAbstractNetwork<N,E>
-
hasEdgeConnecting
Description copied from interface:NetworkReturns 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:
hasEdgeConnectingin interfaceNetwork<N,E> - Overrides:
hasEdgeConnectingin classAbstractNetwork<N,E>
-