Top Description Inners Fields Constructors Methods
com.google.common.graph

public abstract Class EndpointPair<N>

extends Object
implements Iterable<N>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable
Known Direct Subclasses
com.google.common.graph.EndpointPair.Ordered, com.google.common.graph.EndpointPair.Unordered
Annotations
@Beta
@Immutable
containerOf:N
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkNotNull, com.google.common.graph.GraphConstants.NOT_AVAILABLE_ON_UNDIRECTED

An immutable pair representing the two endpoints of an edge in a graph. The 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.

Author
James Sexton
Since
20.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private final N
private final N

Constructor Summary

AccessConstructor and Description
private
EndpointPair(N nodeU, N nodeV)

Method Summary

Modifier and TypeMethod and Description
public final N
adjacentNode(N node)

Returns the node that is adjacent to node along the origin edge.

public abstract boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Two ordered EndpointPairs are equal if their source() and target() are equal.
public abstract int
hashCode()

Overrides java.lang.Object.hashCode.

The hashcode of an ordered EndpointPair is equal to Objects.hashCode(source(), target()).
public abstract boolean
isOrdered()

Returns true if this EndpointPair is an ordered pair (i.e. represents the endpoints of a directed edge).

public final UnmodifiableIterator<N>
iterator()

Implements java.lang.Iterable.iterator.

Iterates in the order nodeU(), nodeV().
public final N
nodeU()

If this EndpointPair isOrdered() returns the source(); otherwise, returns an arbitrary (but consistent) endpoint of the origin edge.

public final N
nodeV()

Returns the node adjacent to nodeU() along the origin edge.

pack-priv static <N> EndpointPair<N>
of(Graph<?> graph, N nodeU, N nodeV)

Returns an EndpointPair representing the endpoints of an edge in graph.

pack-priv static <N> EndpointPair<N>
of(Network<?, ?> network, N nodeU, N nodeV)

Returns an EndpointPair representing the endpoints of an edge in network.

public static <N> EndpointPair<N>
ordered(N source, N target)

Returns an EndpointPair representing the endpoints of a directed edge.

public abstract N
source()

If this EndpointPair isOrdered(), returns the node which is the source.

public abstract N
target()

If this EndpointPair isOrdered(), returns the node which is the target.

public static <N> EndpointPair<N>
unordered(N nodeU, N nodeV)

Returns an EndpointPair representing the endpoints of an undirected edge.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

nodeUback to summary
private final N nodeU
nodeVback to summary
private final N nodeV

Constructor Detail

EndpointPairback to summary
private EndpointPair(N nodeU, N nodeV)

Method Detail

adjacentNodeback to summary
public final N adjacentNode(N node)

Returns the node that is adjacent to node along the origin edge.

Exceptions
IllegalArgumentException:
if this EndpointPair does not contain node
Since
20.0 (but the argument type was changed from Object to N in 31.0)
equalsback to summary
public abstract boolean equals(Object obj)

Overrides java.lang.Object.equals.

Two ordered 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.

Parameters
obj:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public abstract int hashCode()

Overrides java.lang.Object.hashCode.

The hashcode of an ordered EndpointPair is equal to Objects.hashCode(source(), target()). The hashcode of an unordered EndpointPair is equal to nodeU().hashCode() + nodeV().hashCode().

Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object.

Annotations
@Override
isOrderedback to summary
public abstract boolean isOrdered()

Returns true if this EndpointPair is an ordered pair (i.e. represents the endpoints of a directed edge).

iteratorback to summary
public final UnmodifiableIterator<N> iterator()

Implements java.lang.Iterable.iterator.

Iterates in the order nodeU(), nodeV().

Returns:UnmodifiableIterator<N>

Doc from java.lang.Iterable.iterator.

an Iterator.

Annotations
@Override
nodeUback to summary
public final N nodeU()

If this EndpointPair isOrdered() returns the source(); otherwise, returns an arbitrary (but consistent) endpoint of the origin edge.

nodeVback to summary
public final N nodeV()

Returns the node adjacent to nodeU() along the origin edge. If this EndpointPair isOrdered(), this is equal to target().

ofback to summary
pack-priv static <N> EndpointPair<N> of(Graph<?> graph, N nodeU, N nodeV)

Returns an EndpointPair representing the endpoints of an edge in graph.

ofback to summary
pack-priv static <N> EndpointPair<N> of(Network<?, ?> network, N nodeU, N nodeV)

Returns an EndpointPair representing the endpoints of an edge in network.

orderedback to summary
public static <N> EndpointPair<N> ordered(N source, N target)

Returns an EndpointPair representing the endpoints of a directed edge.

sourceback to summary
public abstract N source()

If this EndpointPair isOrdered(), returns the node which is the source.

Exceptions
UnsupportedOperationException:
if this EndpointPair is not ordered
targetback to summary
public abstract N target()

If this EndpointPair isOrdered(), returns the node which is the target.

Exceptions
UnsupportedOperationException:
if this EndpointPair is not ordered
unorderedback to summary
public static <N> EndpointPair<N> unordered(N nodeU, N nodeV)

Returns an EndpointPair representing the endpoints of an undirected edge.

com.google.common.graph back to summary

private final Class EndpointPair.Ordered<N>

extends EndpointPair<N>
Class Inheritance

Constructor Summary

AccessConstructor and Description
private
Ordered(N source, N target)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
obj
)

Implements abstract com.google.common.graph.EndpointPair.equals.

Two ordered EndpointPairs are equal if their source() and target() are equal.
public int
hashCode()

Implements abstract com.google.common.graph.EndpointPair.hashCode.

The hashcode of an ordered EndpointPair is equal to Objects.hashCode(source(), target()).
public boolean
isOrdered()

Implements abstract com.google.common.graph.EndpointPair.isOrdered.

Returns true if this EndpointPair is an ordered pair (i.e. represents the endpoints of a directed edge).
public N
source()

Implements abstract com.google.common.graph.EndpointPair.source.

If this EndpointPair isOrdered(), returns the node which is the source.
public N
target()

Implements abstract com.google.common.graph.EndpointPair.target.

If this EndpointPair isOrdered(), returns the node which is the target.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from com.google.common.graph.EndpointPair:
adjacentNodeiteratornodeUnodeVofoforderedunordered

Constructor Detail

Orderedback to summary
private Ordered(N source, N target)

Method Detail

equalsback to summary
public boolean equals(Object obj)

Implements abstract com.google.common.graph.EndpointPair.equals.

Doc from com.google.common.graph.EndpointPair.equals.

Two ordered 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.

Parameters
obj:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Implements abstract com.google.common.graph.EndpointPair.hashCode.

Doc from com.google.common.graph.EndpointPair.hashCode.

The hashcode of an ordered EndpointPair is equal to Objects.hashCode(source(), target()). The hashcode of an unordered EndpointPair is equal to nodeU().hashCode() + nodeV().hashCode().

Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object.

Annotations
@Override
isOrderedback to summary
public boolean isOrdered()

Implements abstract com.google.common.graph.EndpointPair.isOrdered.

Doc from com.google.common.graph.EndpointPair.isOrdered.

Returns true if this EndpointPair is an ordered pair (i.e. represents the endpoints of a directed edge).

Annotations
@Override
sourceback to summary
public N source()

Implements abstract com.google.common.graph.EndpointPair.source.

Doc from com.google.common.graph.EndpointPair.source.

If this EndpointPair isOrdered(), returns the node which is the source.

Annotations
@Override
targetback to summary
public N target()

Implements abstract com.google.common.graph.EndpointPair.target.

Doc from com.google.common.graph.EndpointPair.target.

If this EndpointPair isOrdered(), returns the node which is the target.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
com.google.common.graph back to summary

private final Class EndpointPair.Unordered<N>

extends EndpointPair<N>
Class Inheritance

Constructor Summary

AccessConstructor and Description
private
Unordered(N nodeU, N nodeV)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
obj
)

Implements abstract com.google.common.graph.EndpointPair.equals.

Two ordered EndpointPairs are equal if their source() and target() are equal.
public int
hashCode()

Implements abstract com.google.common.graph.EndpointPair.hashCode.

The hashcode of an ordered EndpointPair is equal to Objects.hashCode(source(), target()).
public boolean
isOrdered()

Implements abstract com.google.common.graph.EndpointPair.isOrdered.

Returns true if this EndpointPair is an ordered pair (i.e. represents the endpoints of a directed edge).
public N
source()

Implements abstract com.google.common.graph.EndpointPair.source.

If this EndpointPair isOrdered(), returns the node which is the source.
public N
target()

Implements abstract com.google.common.graph.EndpointPair.target.

If this EndpointPair isOrdered(), returns the node which is the target.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from com.google.common.graph.EndpointPair:
adjacentNodeiteratornodeUnodeVofoforderedunordered

Constructor Detail

Unorderedback to summary
private Unordered(N nodeU, N nodeV)

Method Detail

equalsback to summary
public boolean equals(Object obj)

Implements abstract com.google.common.graph.EndpointPair.equals.

Doc from com.google.common.graph.EndpointPair.equals.

Two ordered 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.

Parameters
obj:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Implements abstract com.google.common.graph.EndpointPair.hashCode.

Doc from com.google.common.graph.EndpointPair.hashCode.

The hashcode of an ordered EndpointPair is equal to Objects.hashCode(source(), target()). The hashcode of an unordered EndpointPair is equal to nodeU().hashCode() + nodeV().hashCode().

Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object.

Annotations
@Override
isOrderedback to summary
public boolean isOrdered()

Implements abstract com.google.common.graph.EndpointPair.isOrdered.

Doc from com.google.common.graph.EndpointPair.isOrdered.

Returns true if this EndpointPair is an ordered pair (i.e. represents the endpoints of a directed edge).

Annotations
@Override
sourceback to summary
public N source()

Implements abstract com.google.common.graph.EndpointPair.source.

Doc from com.google.common.graph.EndpointPair.source.

If this EndpointPair isOrdered(), returns the node which is the source.

Annotations
@Override
targetback to summary
public N target()

Implements abstract com.google.common.graph.EndpointPair.target.

Doc from com.google.common.graph.EndpointPair.target.

If this EndpointPair isOrdered(), returns the node which is the target.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override