@Beta @Immutable(containerOf="N") public abstract class EndpointPair<N> extends Object implements 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 | Method and Description |
---|---|
N |
adjacentNode(Object node)
Returns the node that is adjacent to
node along the origin edge. |
abstract boolean |
equals(@Nullable 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()
|
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. |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
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.public abstract N source()
EndpointPair
isOrdered()
, returns the node which is the source.UnsupportedOperationException
- if this EndpointPair
is not orderedpublic abstract N target()
EndpointPair
isOrdered()
, returns the node which is the target.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(Object node)
node
along the origin edge.IllegalArgumentException
- if this EndpointPair
does not contain node
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()
public abstract boolean equals(@Nullable Object obj)
EndpointPair
s are equal if their source()
and target()
are equal. Two unordered EndpointPair
s are equal if they contain the same nodes. An
ordered EndpointPair
is never equal to an unordered EndpointPair
.equals
in class Object
obj
- the reference object with which to compare.true
if this object is the same as the obj
argument; false
otherwise.Object.hashCode()
,
HashMap
public 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 Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
Copyright © 2010–2018. All rights reserved.