public interface Edge
from and to methods reflect only a naming convention used to
distinguish between the two vertices connected by this edge.
Note that futher refinements of the Edge interface may contain
further conditions for edge equality. In order to guarantee symmetry of the
equals method, implementations are encouraged
to implement equals using a symmetric check:
public boolean equals(Object o) {
if (o instanceof Edge) {
Edge e = (Edge)o;
boolean isEqual = true; // fill in with implementation specifics
return isEqual && o.equals(e);
}
}
| Modifier and Type | Method and Description |
|---|---|
<T extends Edge> |
clone(int from,
int to)
Clones the contents associated with this edge, returning the copy mapped
to the provided vertices.
|
boolean |
equals(Object o)
Returns
true if o connects the same two vertices
regardless of the edge orientation. |
<T extends Edge> |
flip()
Returns a copy of this edge with the
from and to vertices swapped. |
int |
from()
Returns the index of the tail vertex
|
int |
to()
Returns the index of the head vertex
|
<T extends Edge> T clone(int from, int to)
boolean equals(Object o)
true if o connects the same two vertices
regardless of the edge orientation.<T extends Edge> T flip()
from and to vertices swapped.T - the type of the Edge instance returned. In almost
every use-case imaginable, T should be set to the type of
Edge on which this method is called.int from()
int to()
Copyright © 2012. All Rights Reserved.