N
- Node parameter typeE
- Edge parameter typeclass ConfigurableNetwork<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 |
protected MapIteratorCache<E,N> |
edgeToReferenceNode |
private boolean |
isDirected |
protected MapIteratorCache<N,NetworkConnections<N,E>> |
nodeConnections |
private ElementOrder<N> |
nodeOrder |
Constructor and Description |
---|
ConfigurableNetwork(NetworkBuilder<? super N,? super E> builder)
Constructs a graph with the properties specified in
builder . |
ConfigurableNetwork(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).
|
protected NetworkConnections<N,E> |
checkedConnections(N node) |
protected N |
checkedReferenceNode(E edge) |
protected boolean |
containsEdge(E edge) |
protected 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, validateEndpoints
private final boolean isDirected
private final boolean allowsParallelEdges
private final boolean allowsSelfLoops
private final ElementOrder<N> nodeOrder
private final ElementOrder<E> edgeOrder
protected final MapIteratorCache<N,NetworkConnections<N,E>> nodeConnections
protected final MapIteratorCache<E,N> edgeToReferenceNode
ConfigurableNetwork(NetworkBuilder<? super N,? super E> builder)
builder
.ConfigurableNetwork(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()
Network
Network.nodeOrder()
.public java.util.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
IllegalArgumentException
.public boolean allowsSelfLoops()
Network
IllegalArgumentException
.public ElementOrder<N> nodeOrder()
Network
Network.nodes()
.public ElementOrder<E> edgeOrder()
Network
Network.edges()
.public java.util.Set<E> incidentEdges(N node)
Network
incident 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)
Network
edge
in this network.public java.util.Set<N> adjacentNodes(N node)
Network
node
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)
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 (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)
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 java.util.Set<E> outEdges(N 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 java.util.Set<N> predecessors(N 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 java.util.Set<N> successors(N 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 NetworkConnections<N,E> checkedConnections(N node)
protected final boolean containsNode(N node)
protected final boolean containsEdge(E edge)