N
- Node parameter typeE
- Edge parameter type@Beta public final class ImmutableNetwork<N,E> extends AbstractNetwork<N,E>
Network
whose elements and structural relationships will never change. Instances of
this class may be obtained with copyOf(Network)
.
This class generally provides all of the same guarantees as ImmutableCollection
(despite not extending ImmutableCollection
itself), including guaranteed thread-safety.
Modifier and Type | Field and Description |
---|---|
protected com.google.common.graph.MapIteratorCache<E,N> |
edgeToReferenceNode |
protected com.google.common.graph.MapIteratorCache<N,com.google.common.graph.NetworkConnections<N,E>> |
nodeConnections |
Modifier and Type | Method and Description |
---|---|
Set<N> |
adjacentNodes(Object 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).
|
ImmutableGraph<N> |
asGraph()
Returns a live view of this network as a
Graph . |
protected com.google.common.graph.NetworkConnections<N,E> |
checkedConnections(Object node) |
protected N |
checkedReferenceNode(Object edge) |
protected boolean |
containsEdge(Object edge) |
protected boolean |
containsNode(Object node) |
static <N,E> ImmutableNetwork<N,E> |
copyOf(ImmutableNetwork<N,E> network)
Deprecated.
no need to use this
|
static <N,E> ImmutableNetwork<N,E> |
copyOf(Network<N,E> network)
Returns an immutable copy of
network . |
ElementOrder<E> |
edgeOrder()
Returns the order of iteration for the elements of
Network.edges() . |
Set<E> |
edges()
Returns all edges in this network, in the order specified by
Network.edgeOrder() . |
Set<E> |
edgesConnecting(Object nodeU,
Object nodeV)
Returns the set of edges directly connecting
nodeU to nodeV . |
Set<E> |
incidentEdges(Object node)
Returns the edges whose
incident nodes in this network include
node . |
EndpointPair<N> |
incidentNodes(Object edge)
Returns the nodes which are the endpoints of
edge in this network. |
Set<E> |
inEdges(Object 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() . |
Set<N> |
nodes()
Returns all nodes in this network, in the order specified by
Network.nodeOrder() . |
Set<E> |
outEdges(Object node)
Returns all edges in this network which can be traversed in the direction (if any) of the edge
starting from
node . |
Set<N> |
predecessors(Object 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. |
Set<N> |
successors(Object 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. |
adjacentEdges, degree, inDegree, outDegree, toString
protected final com.google.common.graph.MapIteratorCache<N,com.google.common.graph.NetworkConnections<N,E>> nodeConnections
protected final com.google.common.graph.MapIteratorCache<E,N> edgeToReferenceNode
public static <N,E> ImmutableNetwork<N,E> copyOf(Network<N,E> network)
network
.@Deprecated public static <N,E> ImmutableNetwork<N,E> copyOf(ImmutableNetwork<N,E> network)
public ImmutableGraph<N> asGraph()
Network
Graph
. The resulting Graph
will have
an edge connecting node A to node B iff this Network
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, the Network.degree(Object)
of a node
in the Graph
view may be less than the degree of the same node in this Network
.
public Set<N> nodes()
Network
Network.nodeOrder()
.public 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
UnsupportedOperationException
.public boolean allowsSelfLoops()
Network
UnsupportedOperationException
.public ElementOrder<N> nodeOrder()
Network
Network.nodes()
.public ElementOrder<E> edgeOrder()
Network
Network.edges()
.public Set<E> incidentEdges(Object node)
Network
incident nodes
in this network include
node
.public EndpointPair<N> incidentNodes(Object edge)
Network
edge
in this network.public Set<N> adjacentNodes(Object node)
Network
node
in this network.public Set<E> edgesConnecting(Object nodeU, Object 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.
public Set<E> inEdges(Object 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 Set<E> outEdges(Object 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 Set<N> predecessors(Object 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 Set<N> successors(Object 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)
.
protected final com.google.common.graph.NetworkConnections<N,E> checkedConnections(Object node)
protected final N checkedReferenceNode(Object edge)
protected final boolean containsNode(@Nullable Object node)
protected final boolean containsEdge(@Nullable Object edge)
Copyright © 2010-2016. All Rights Reserved.