import java.util.Collection; /** * Interface specifying a graph. * Assumes that we do not have negative cost edges in the graph. */ public interface Graph { /** * Return the collection of vertices of this graph * @return the vertices as a collection (which is anything iterable) */ public Collection vertices(); /** * Return the collection of edges of this graph * @return the edges as a collection (which is anything iterable) */ public Collection edges(); /** * Return a collection of vertices adjacent to a given vertex v. * i.e., the set of all vertices w where edges v -> w exist in the graph. * @param v one of the vertices in the graph * @return an iterable collection of vertices adjacent to v in the graph */ public Collection adjacentVertices(Vertex v); /** * Test whether vertex b is adjacent to vertex a (i.e. a -> b) in a directed graph. * @param a one vertex * @param b another vertex * @return cost of edge if there is a directed edge from a to b in the graph * Return -1 otherwise. * (Including returning -1 if one of the two vertices does not exist.) * Assumes that we do not have negative cost edges in the graph. */ public int isAdjacent(Vertex a, Vertex b); }