N - Node parameter typeE - Edge parameter typeclass StandardNetwork<N,E> extends AbstractNetwork<N,E>
Network that supports the options supplied by NetworkBuilder.
This class maintains a map of nodes to NetworkConnections. This class also maintains a
map of edges to reference nodes. The reference node is defined to be the edge's source node on
directed graphs, and an arbitrary endpoint of the edge on undirected graphs.
Collection-returning accessors return unmodifiable views: the view returned will reflect changes to the graph (if the graph is mutable) but may not be modified by the user.
The time complexity of all collection-returning accessors is O(1), since views are returned.
| Modifier and Type | Field and Description |
|---|---|
private boolean |
allowsParallelEdges |
private boolean |
allowsSelfLoops |
private ElementOrder<E> |
edgeOrder |
(package private) MapIteratorCache<E,N> |
edgeToReferenceNode |
private boolean |
isDirected |
(package private) MapIteratorCache<N,NetworkConnections<N,E>> |
nodeConnections |
private ElementOrder<N> |
nodeOrder |
| Constructor and Description |
|---|
StandardNetwork(NetworkBuilder<? super N,? super E> builder)
Constructs a graph with the properties specified in
builder. |
StandardNetwork(NetworkBuilder<? super N,? super E> builder,
java.util.Map<N,NetworkConnections<N,E>> nodeConnections,
java.util.Map<E,N> edgeToReferenceNode)
Constructs a graph with the properties specified in
builder, initialized with the given
node and edge maps. |
| Modifier and Type | Method and Description |
|---|---|
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).
|
(package private) NetworkConnections<N,E> |
checkedConnections(N node) |
(package private) N |
checkedReferenceNode(E edge) |
(package private) boolean |
containsEdge(E edge) |
(package private) boolean |
containsNode(N node) |
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(N nodeU,
N nodeV)
Returns the set of edges that each directly connect
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. |
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(). |
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. |
adjacentEdges, asGraph, degree, edgeConnecting, edgeConnecting, edgeConnectingOrNull, edgeConnectingOrNull, edgesConnecting, equals, hasEdgeConnecting, hasEdgeConnecting, hashCode, inDegree, isOrderingCompatible, outDegree, toString, validateEndpointsprivate final boolean isDirected
private final boolean allowsParallelEdges
private final boolean allowsSelfLoops
private final ElementOrder<N> nodeOrder
private final ElementOrder<E> edgeOrder
final MapIteratorCache<N,NetworkConnections<N,E>> nodeConnections
final MapIteratorCache<E,N> edgeToReferenceNode
StandardNetwork(NetworkBuilder<? super N,? super E> builder)
builder.StandardNetwork(NetworkBuilder<? super N,? super E> builder, java.util.Map<N,NetworkConnections<N,E>> nodeConnections, java.util.Map<E,N> edgeToReferenceNode)
builder, initialized with the given
node and edge maps.public java.util.Set<N> nodes()
NetworkNetwork.nodeOrder().public java.util.Set<E> edges()
NetworkNetwork.edgeOrder().public boolean isDirected()
Networksource node to a target node, while
undirected edges connect a pair of nodes to each other.public boolean allowsParallelEdges()
NetworkIllegalArgumentException.public boolean allowsSelfLoops()
NetworkIllegalArgumentException.public ElementOrder<N> nodeOrder()
NetworkNetwork.nodes().public ElementOrder<E> edgeOrder()
NetworkNetwork.edges().public java.util.Set<E> incidentEdges(N node)
Networkincident nodes in this network include
node.
This is equal to the union of Network.inEdges(Object) and Network.outEdges(Object).
public EndpointPair<N> incidentNodes(E edge)
Networkedge in this network.public java.util.Set<N> adjacentNodes(N node)
Networknode in this network.
This is equal to the union of Network.predecessors(Object) and Network.successors(Object).
public java.util.Set<E> edgesConnecting(N nodeU, N nodeV)
NetworknodeU 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> inEdges(N node)
Networknode.
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)
Networknode.
In a directed network, an outgoing edge's EndpointPair.source() equals node.
In an undirected network, this is equivalent to Network.incidentEdges(Object).
public java.util.Set<N> predecessors(N node)
Networknode 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)
Networknode 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).
final NetworkConnections<N,E> checkedConnections(N node)
final boolean containsNode(N node)
final boolean containsEdge(E edge)