Graph Interface: Getting the Endpoints
There are two utility methods in the Graph interface where given an Edge, you can ask the abstraction to return the start or end vertex of that edge.
/**
* Start vertex of edge.
*
* @param e Edge position to explore.
* @return Vertex position edge starts from.
* @throws PositionException If edge position is invalid.
*/
Vertex<V> from(Edge<E> e) throws PositionException;
/**
* End vertex of edge.
*
* @param e Edge position to explore.
* @return Vertex position edge leads to.
* @throws PositionException If edge position is invalid.
*/
Vertex<V> to(Edge<E> e) throws PositionException;
And this is one reason why we use an Edge abstraction.
When you insert and edge and it gives you Edge abstraction, that Edge abstraction is like a receipt which you can give back to the Graph and ask for more information about the edge.
The client is not able, on their own, to get data such as the endpoints of an Edge because the Edge abstraction is just a Position and all provides, is a getter to get the data store in it.