import java.util.Collection; /** * Abstract implementation of a graph. * Must be extended to create a particular kind of graph. */ public abstract class AbstractGraph implements Graph { // Graph representation - an iterable collection of vertices and edges protected Collection vertices; protected Collection edges; /** * Construct a new abstract graph * @param vertices the initial set of verticies in the graph * @param edges the initial set of edges in the graph */ AbstractGraph(Collection vertices, Collection edges) { this.vertices = vertices; this.edges = edges; } /** * Return the vertices in this graph * @return the set of vertices in this graph */ public Collection vertices() { return vertices; } /** * Return the edges in this graph * @return the set of edges in this graph */ public Collection edges() { return edges; } }