From Definition to Abstraction

A graph $G = (V, E)$ consists of a nonempty set $V$ of vertices (or nodes) and a collection $E$ of edges (or arcs).


Open the starter code and look at the Graph.java which defines the Graph interface:

/**
 * Graph ADT.
 *
 * @param <V> Vertex element type.
 * @param <E> Edge element type.
 */
public interface Graph<V, E> {
  // Operations not shown
}

The Graph interface declaration looks a lot like the Mathematical definition of Graph but be careful as V and E here are not collection of vertices/edges. They are generic type of the data you store in a vertex or in an edge.

In fact, we define abstractions for Vertex and Edge.