More Abstractions: Vertex and Edge

We define abstractions for Vertex and Edge.

/**
 * Edge position for graph.
 * @param <E> Element type.
 */
public interface Edge<E> extends Position<E> {
}
/**
 * Vertex position for graph.
 * @param <V> Element type.
 */
public interface Vertex<V> extends Position<V> {
}

In these simple abstractions, a Vertex and an Edge are just Positions.

/**
 * Generic position interface.
 * @param <T> the element type.
 */
public interface Position<T> {

  /**
   * Read element from this position.
   * @return element at this position.
   */
  T get();
}

In the same way our List interface used Position, the Graph interface uses Vertex and Edge abstractions.