Class ImmutableNetwork<N,E>
- Type Parameters:
N
- Node parameter typeE
- Edge parameter type
- All Implemented Interfaces:
Network<N,
E>, PredecessorsFunction<N>, SuccessorsFunction<N>
Network
whose elements and structural relationships will never change. Instances of
this class may be obtained with copyOf(Network)
.
See the Guava User's Guide's discussion
of the Immutable*
types for more information on the properties and guarantees
provided by this class.
- Since:
- 20.0
- Author:
- James Sexton, Joshua O'Madadhain, Omar Darwish, Jens Nyman
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A builder for creatingImmutableNetwork
instances, especiallystatic final
networks. -
Method Summary
Modifier and TypeMethodDescriptionadjacentNodes
(N node) boolean
Returns true if this network allows parallel edges.boolean
asGraph()
Returns a live view of this network as aGraph
.static <N,
E> ImmutableNetwork <N, E> copyOf
(ImmutableNetwork<N, E> network) Deprecated.no need to use thisstatic <N,
E> ImmutableNetwork <N, E> Returns an immutable copy ofnetwork
.Returns the order of iteration for the elements ofNetwork.edges()
.edges()
Returns all edges in this network, in the order specified byNetwork.edgeOrder()
.edgesConnecting
(N nodeU, N nodeV) Returns a live view of the set of edges that each directly connectnodeU
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.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
nodes()
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 all nodes in this graph adjacent tonode
which can be reached by traversingnode
's incoming edges against the direction (if any) of the edge.successors
(N node) Returns all nodes in this graph adjacent tonode
which can be reached by traversingnode
's outgoing edges in the direction (if any) of the edge.Methods inherited from class AbstractNetwork
adjacentEdges, degree, edgeConnecting, edgeConnecting, edgeConnectingOrNull, edgeConnectingOrNull, edgeInvalidatableSet, edgesConnecting, equals, hasEdgeConnecting, hasEdgeConnecting, hashCode, inDegree, isOrderingCompatible, nodeInvalidatableSet, nodePairInvalidatableSet, outDegree, toString, validateEndpoints
-
Method Details
-
copyOf
Returns an immutable copy ofnetwork
. -
copyOf
@InlineMe(replacement="checkNotNull(network)", staticImports="com.google.common.base.Preconditions.checkNotNull") @Deprecated public static <N,E> ImmutableNetwork<N,E> copyOf(ImmutableNetwork<N, E> network) Deprecated.no need to use thisSimply returns its argument. -
asGraph
Description copied from interface:Network
Returns a live view of this network as aGraph
. The resultingGraph
will have an edge connecting node A to node B if thisNetwork
has an edge connecting A to B.If this network
allows parallel edges
, parallel edges will be treated as if collapsed into a single edge. For example, theNetwork.degree(Object)
of a node in theGraph
view may be less than the degree of the same node in thisNetwork
. -
nodes
-
edges
Description copied from interface:Network
Returns all edges in this network, in the order specified byNetwork.edgeOrder()
. -
isDirected
public boolean isDirected() -
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() -
nodeOrder
-
edgeOrder
Description copied from interface:Network
Returns the order of iteration for the elements ofNetwork.edges()
. -
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 otherequals()
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. -
adjacentNodes
-
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 otherequals()
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>
-
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 otherequals()
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 otherequals()
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:PredecessorsFunction
Returns all nodes in this graph adjacent tonode
which can be reached by traversingnode
's incoming edges against the direction (if any) of the edge.Some algorithms that operate on a
PredecessorsFunction
may produce undesired results if the returnedIterable
contains duplicate elements. Implementations of such algorithms should document their behavior in the presence of duplicates.The elements of the returned
Iterable
must each be:- Non-null
- Usable as
Map
keys (see the Guava User Guide's section on graph elements for details)
-
successors
Description copied from interface:SuccessorsFunction
Returns all nodes in this graph adjacent tonode
which can be reached by traversingnode
's outgoing edges in the direction (if any) of the edge.This is not the same as "all nodes reachable from
node
by following outgoing edges". For that functionality, seeGraphs.reachableNodes(Graph, Object)
.Some algorithms that operate on a
SuccessorsFunction
may produce undesired results if the returnedIterable
contains duplicate elements. Implementations of such algorithms should document their behavior in the presence of duplicates.The elements of the returned
Iterable
must each be:- Non-null
- Usable as
Map
keys (see the Guava User Guide's section on graph elements for details)
-