/** * CSE 373, Spring 2011, Jessica Miller * A basic graph interface. */ import java.util.*; public interface IGraph { /** * Adds a vertex to the graph. * @param v Vertex to add to the graph * @throws IllegalArgumentException if vertex passed is null */ public void addVertex(V v); /** * Adds an edge to the graph * @param v1 source vertex * @param v2 destination vertex * @param weight the weight of the edge * @throws IllegalArgumentException if either vertex passed is null */ public void addEdge(V v1, V v2, int weight); /** * Returns whether or not an edge exists between the two vertices. * @param v1 source vertex * @param v2 destination vertex * @return whether or not an edge exists between the two vertices * @throws IllegalArgumentException if either vertex passed is null * or either vertex is not found in the graph */ public boolean hasEdge(V v1, V v2); /** * Returns the edge between the two vertices. * @param v1 source vertex * @param v2 destination vertex * @return the edge between the two vertices or null if there is no edge * between them * @throws IllegalArgumentException if either vertex passed is null * or either vertex is not found in the graph */ public Edge getEdge(V v1, V v2); public boolean hasPath(V v1, V v2); /** * Returns a path between the two vertices if one exists. * Uses depth-first search algorithm to find the path. * @param v1 the source vertex * @param v2 the destination vertex * @return a path between the two vertices; null if a path does not exist * @throws IllegalArgumentException if either vertex passed is null * or either vertex is not found in the graph */ public List getDFSPath(V v1, V v2); public String toString(); }