Package com.google.common.graph
Class EndpointPair<N>
- java.lang.Object
- 
- com.google.common.graph.EndpointPair<N>
 
- 
- All Implemented Interfaces:
- Iterable<N>
 
 @Beta @Immutable(containerOf="N") public abstract class EndpointPair<N> extends Object implements Iterable<N> An immutable pair representing the two endpoints of an edge in a graph. TheEndpointPairof a directed edge is an ordered pair of nodes (source()andtarget()). TheEndpointPairof an undirected edge is an unordered pair of nodes (nodeU()andnodeV()).The edge is a self-loop if, and only if, the two endpoints are equal. - Since:
- 20.0
- Author:
- James Sexton
 
- 
- 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description NadjacentNode(N node)Returns the node that is adjacent tonodealong the origin edge.abstract booleanequals(Object obj)abstract inthashCode()The hashcode of an orderedEndpointPairis equal toObjects.hashCode(source(), target()).abstract booleanisOrdered()Returnstrueif thisEndpointPairis an ordered pair (i.e.UnmodifiableIterator<N>iterator()NnodeU()If thisEndpointPairisOrdered()returns thesource(); otherwise, returns an arbitrary (but consistent) endpoint of the origin edge.NnodeV()static <N> EndpointPair<N>ordered(N source, N target)Returns anEndpointPairrepresenting the endpoints of a directed edge.abstract Nsource()If thisEndpointPairisOrdered(), returns the node which is the source.abstract Ntarget()If thisEndpointPairisOrdered(), returns the node which is the target.static <N> EndpointPair<N>unordered(N nodeU, N nodeV)Returns anEndpointPairrepresenting the endpoints of an undirected edge.- 
Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface java.lang.IterableforEach, spliterator
 
- 
 
- 
- 
- 
Method Detail- 
orderedpublic static <N> EndpointPair<N> ordered(N source, N target) Returns anEndpointPairrepresenting the endpoints of a directed edge.
 - 
unorderedpublic static <N> EndpointPair<N> unordered(N nodeU, N nodeV) Returns anEndpointPairrepresenting the endpoints of an undirected edge.
 - 
sourcepublic abstract N source() If thisEndpointPairisOrdered(), returns the node which is the source.- Throws:
- UnsupportedOperationException- if this- EndpointPairis not ordered
 
 - 
targetpublic abstract N target() If thisEndpointPairisOrdered(), returns the node which is the target.- Throws:
- UnsupportedOperationException- if this- EndpointPairis not ordered
 
 - 
nodeUpublic final N nodeU() If thisEndpointPairisOrdered()returns thesource(); otherwise, returns an arbitrary (but consistent) endpoint of the origin edge.
 - 
nodeVpublic final N nodeV() Returns the nodeadjacenttonodeU()along the origin edge. If thisEndpointPairisOrdered(), this is equal totarget().
 - 
adjacentNodepublic final N adjacentNode(N node) Returns the node that is adjacent tonodealong the origin edge.- Throws:
- IllegalArgumentException- if this- EndpointPairdoes not contain- node
- Since:
- 20.0 (but the argument type was changed from ObjecttoNin 31.0)
 
 - 
isOrderedpublic abstract boolean isOrdered() Returnstrueif thisEndpointPairis an ordered pair (i.e. represents the endpoints of a directed edge).
 - 
iteratorpublic final UnmodifiableIterator<N> iterator() 
 - 
equalspublic abstract boolean equals(@CheckForNull Object obj) Two orderedEndpointPairs are equal if theirsource()andtarget()are equal. Two unorderedEndpointPairs are equal if they contain the same nodes. An orderedEndpointPairis never equal to an unorderedEndpointPair.- Overrides:
- equalsin class- Object
- Parameters:
- obj- the reference object with which to compare.
- Returns:
- trueif this object is the same as the obj argument;- falseotherwise.
- See Also:
- Object.hashCode(),- HashMap
 
 - 
hashCodepublic abstract int hashCode() The hashcode of an orderedEndpointPairis equal toObjects.hashCode(source(), target()). The hashcode of an unorderedEndpointPairis equal tonodeU().hashCode() + nodeV().hashCode().- Overrides:
- hashCodein class- Object
- Returns:
- a hash code value for this object.
- See Also:
- Object.equals(java.lang.Object),- System.identityHashCode(java.lang.Object)
 
 
- 
 
-