private static class Graphs.TransposedValueGraph<N,V> extends ForwardingValueGraph<N,V>
Modifier and Type | Field and Description |
---|---|
private ValueGraph<N,V> |
graph |
Constructor and Description |
---|
TransposedValueGraph(ValueGraph<N,V> graph) |
Modifier and Type | Method and Description |
---|---|
(package private) ValueGraph<N,V> |
delegate() |
java.util.Optional<V> |
edgeValue(EndpointPair<N> endpoints)
Returns the value of the edge that connects
endpoints (in the order, if any, specified
by endpoints ), if one is present; otherwise, returns Optional.empty() . |
java.util.Optional<V> |
edgeValue(N nodeU,
N nodeV)
Returns the value of the edge that connects
nodeU to nodeV (in the order, if
any, specified by endpoints ), if one is present; otherwise, returns Optional.empty() . |
V |
edgeValueOrDefault(EndpointPair<N> endpoints,
V defaultValue)
Returns the value of the edge that connects
endpoints (in the order, if any, specified
by endpoints ), if one is present; otherwise, returns defaultValue . |
V |
edgeValueOrDefault(N nodeU,
N nodeV,
V defaultValue)
Returns the value of the edge that connects
nodeU to nodeV , if one is present;
otherwise, returns defaultValue . |
boolean |
hasEdgeConnecting(EndpointPair<N> endpoints)
Returns true if there is an edge that directly connects
endpoints (in the order, if
any, specified by endpoints ). |
boolean |
hasEdgeConnecting(N nodeU,
N nodeV)
Returns true if there is an edge that directly connects
nodeU to nodeV . |
int |
inDegree(N node)
Returns the count of
node 's incoming edges (equal to predecessors(node).size() )
in a directed graph. |
int |
outDegree(N node)
Returns the count of
node 's outgoing edges (equal to successors(node).size() )
in a directed graph. |
java.util.Set<N> |
predecessors(N node)
Returns all nodes in this graph 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 graph adjacent to
node which can be reached by traversing
node 's outgoing edges in the direction (if any) of the edge. |
adjacentNodes, allowsSelfLoops, degree, edgeCount, incidentEdgeOrder, isDirected, nodeOrder, nodes
asGraph, equals, hashCode, toString
edges, incidentEdges, isOrderingCompatible, validateEndpoints
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
edges, incidentEdges
private final ValueGraph<N,V> graph
TransposedValueGraph(ValueGraph<N,V> graph)
ValueGraph<N,V> delegate()
delegate
in class ForwardingValueGraph<N,V>
public java.util.Set<N> predecessors(N node)
ValueGraph
node
which can be reached by traversing
node
's incoming edges against the direction (if any) of the edge.
In an undirected graph, this is equivalent to ValueGraph.adjacentNodes(Object)
.
predecessors
in interface BaseGraph<N>
predecessors
in interface PredecessorsFunction<N>
predecessors
in interface ValueGraph<N,V>
predecessors
in class ForwardingValueGraph<N,V>
public java.util.Set<N> successors(N node)
ValueGraph
node
which can be reached by traversing
node
's outgoing edges in the direction (if any) of the edge.
In an undirected graph, this is equivalent to ValueGraph.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)
.
successors
in interface BaseGraph<N>
successors
in interface SuccessorsFunction<N>
successors
in interface ValueGraph<N,V>
successors
in class ForwardingValueGraph<N,V>
public int inDegree(N node)
BaseGraph
node
's incoming edges (equal to predecessors(node).size()
)
in a directed graph. In an undirected graph, returns the BaseGraph.degree(Object)
.
If the count is greater than Integer.MAX_VALUE
, returns Integer.MAX_VALUE
.
public int outDegree(N node)
BaseGraph
node
's outgoing edges (equal to successors(node).size()
)
in a directed graph. In an undirected graph, returns the BaseGraph.degree(Object)
.
If the count is greater than Integer.MAX_VALUE
, returns Integer.MAX_VALUE
.
public boolean hasEdgeConnecting(N nodeU, N nodeV)
BaseGraph
nodeU
to nodeV
. This is
equivalent to nodes().contains(nodeU) && successors(nodeU).contains(nodeV)
.
In an undirected graph, this is equal to hasEdgeConnecting(nodeV, nodeU)
.
hasEdgeConnecting
in interface BaseGraph<N>
hasEdgeConnecting
in interface ValueGraph<N,V>
hasEdgeConnecting
in class ForwardingValueGraph<N,V>
public boolean hasEdgeConnecting(EndpointPair<N> endpoints)
BaseGraph
endpoints
(in the order, if
any, specified by endpoints
). This is equivalent to edges().contains(endpoints)
.
Unlike the other EndpointPair
-accepting methods, this method does not throw if the
endpoints are unordered; it simply returns false. This is for consistency with the behavior of
Collection#contains(Object)
(which does not generally throw if the object cannot be
present in the collection), and the desire to have this method's behavior be compatible with
edges().contains(endpoints)
.
hasEdgeConnecting
in interface BaseGraph<N>
hasEdgeConnecting
in interface ValueGraph<N,V>
hasEdgeConnecting
in class ForwardingValueGraph<N,V>
public java.util.Optional<V> edgeValue(N nodeU, N nodeV)
ValueGraph
nodeU
to nodeV
(in the order, if
any, specified by endpoints
), if one is present; otherwise, returns Optional.empty()
.edgeValue
in interface ValueGraph<N,V>
edgeValue
in class ForwardingValueGraph<N,V>
public java.util.Optional<V> edgeValue(EndpointPair<N> endpoints)
ValueGraph
endpoints
(in the order, if any, specified
by endpoints
), if one is present; otherwise, returns Optional.empty()
.
If this graph is directed, the endpoints must be ordered.
edgeValue
in interface ValueGraph<N,V>
edgeValue
in class ForwardingValueGraph<N,V>
@CheckForNull public V edgeValueOrDefault(N nodeU, N nodeV, @CheckForNull V defaultValue)
ValueGraph
nodeU
to nodeV
, if one is present;
otherwise, returns defaultValue
.
In an undirected graph, this is equal to edgeValueOrDefault(nodeV, nodeU,
defaultValue)
.
edgeValueOrDefault
in interface ValueGraph<N,V>
edgeValueOrDefault
in class ForwardingValueGraph<N,V>
@CheckForNull public V edgeValueOrDefault(EndpointPair<N> endpoints, @CheckForNull V defaultValue)
ValueGraph
endpoints
(in the order, if any, specified
by endpoints
), if one is present; otherwise, returns defaultValue
.
If this graph is directed, the endpoints must be ordered.
edgeValueOrDefault
in interface ValueGraph<N,V>
edgeValueOrDefault
in class ForwardingValueGraph<N,V>