public abstract class EndpointPair<N>
extends java.lang.Object
implements java.lang.Iterable<N>
EndpointPair
of a directed edge is an ordered pair of nodes (source() and target()). The
EndpointPair of an undirected edge is an unordered pair of nodes (nodeU() and
nodeV()).
The edge is a self-loop if, and only if, the two endpoints are equal.
| Modifier and Type | Class and Description |
|---|---|
private static class |
EndpointPair.Ordered<N> |
private static class |
EndpointPair.Unordered<N> |
| Modifier | Constructor and Description |
|---|---|
private |
EndpointPair(N nodeU,
N nodeV) |
| Modifier and Type | Method and Description |
|---|---|
N |
adjacentNode(N node)
Returns the node that is adjacent to
node along the origin edge. |
abstract boolean |
equals(java.lang.Object obj)
|
abstract int |
hashCode()
The hashcode of an ordered
EndpointPair is equal to Objects.hashCode(source(),
target()). |
abstract boolean |
isOrdered()
Returns
true if this EndpointPair is an ordered pair (i.e. |
UnmodifiableIterator<N> |
iterator()
|
N |
nodeU()
If this
EndpointPair isOrdered() returns the source(); otherwise,
returns an arbitrary (but consistent) endpoint of the origin edge. |
N |
nodeV()
|
(package private) static <N> EndpointPair<N> |
of(Graph<?> graph,
N nodeU,
N nodeV)
Returns an
EndpointPair representing the endpoints of an edge in graph. |
(package private) static <N> EndpointPair<N> |
of(Network<?,?> network,
N nodeU,
N nodeV)
Returns an
EndpointPair representing the endpoints of an edge in network. |
static <N> EndpointPair<N> |
ordered(N source,
N target)
Returns an
EndpointPair representing the endpoints of a directed edge. |
abstract N |
source()
If this
EndpointPair isOrdered(), returns the node which is the source. |
abstract N |
target()
If this
EndpointPair isOrdered(), returns the node which is the target. |
static <N> EndpointPair<N> |
unordered(N nodeU,
N nodeV)
Returns an
EndpointPair representing the endpoints of an undirected edge. |
public static <N> EndpointPair<N> ordered(N source, N target)
EndpointPair representing the endpoints of a directed edge.public static <N> EndpointPair<N> unordered(N nodeU, N nodeV)
EndpointPair representing the endpoints of an undirected edge.static <N> EndpointPair<N> of(Graph<?> graph, N nodeU, N nodeV)
EndpointPair representing the endpoints of an edge in graph.static <N> EndpointPair<N> of(Network<?,?> network, N nodeU, N nodeV)
EndpointPair representing the endpoints of an edge in network.public abstract N source()
EndpointPair isOrdered(), returns the node which is the source.java.lang.UnsupportedOperationException - if this EndpointPair is not orderedpublic abstract N target()
EndpointPair isOrdered(), returns the node which is the target.java.lang.UnsupportedOperationException - if this EndpointPair is not orderedpublic final N nodeU()
EndpointPair isOrdered() returns the source(); otherwise,
returns an arbitrary (but consistent) endpoint of the origin edge.public final N nodeV()
adjacent to nodeU() along the origin
edge. If this EndpointPair isOrdered(), this is equal to target().public final N adjacentNode(N node)
node along the origin edge.java.lang.IllegalArgumentException - if this EndpointPair does not contain nodeObject to N in 31.0)public abstract boolean isOrdered()
true if this EndpointPair is an ordered pair (i.e. represents the
endpoints of a directed edge).public final UnmodifiableIterator<N> iterator()
iterator in interface java.lang.Iterable<N>public abstract boolean equals(@CheckForNull
java.lang.Object obj)
EndpointPairs are equal if their source() and target()
are equal. Two unordered EndpointPairs are equal if they contain the same nodes. An
ordered EndpointPair is never equal to an unordered EndpointPair.equals in class java.lang.Objectpublic abstract int hashCode()
EndpointPair is equal to Objects.hashCode(source(),
target()). The hashcode of an unordered EndpointPair is equal to nodeU().hashCode() + nodeV().hashCode().hashCode in class java.lang.Object