More Abstractions: Vertex and Edge

  • Describe the relationship between the Position abstraction and 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(); }

The Graph interface uses Vertex and Edge abstractions similar to how the List interface used Position.