Graph Interface: Insert Edges

The Graph interface has an operation to insert edges:

/**
 * Insert a new edge.
 *
 * @param from Vertex position where edge starts.
 * @param to   Vertex position where edge ends.
 * @param e    Element to insert.
 * @return Edge position created to hold element.
 */
Edge<E> insert(Vertex<V> from, Vertex<V> to, E e);

When we add an edge, we specify the two vertices "from" and "to", in addition to the data we may want to store in the edge.

Notice the insert method is overloaded: we've seen the insert method that created a vertex for us.

Similar to the method vertices, we have an edges method that returns an Iterable of edges.

/**
 * Edges of graph.
 *
 * @return Iterable over all edges of the graph 
 *         (in no specific order).
 */
Iterable<Edge<E>> edges();