import net.datastructures.Edge; import net.datastructures.InvalidPositionException; import net.datastructures.Vertex; /** * An interface for a directed graph. modified from net.datastructures.Graph version 4.0 * @author Roberto Tamassia, morgan wahl */ public interface DirectedGraph { /** Returns the number of vertices of the graph */ public int numVertices(); /** Returns the number of edges of the graph */ public int numEdges(); /** Returns the vertices of the graph as an iterable collection */ public Iterable> vertices(); /** Returns the edges of the graph as an iterable collection */ public Iterable> edges(); /** Replaces the element of a given vertex with a new element and returns the old element */ public V replace(Vertex p, V o) throws InvalidPositionException; /** Replaces the element of a given edge with a new element and returns the old element */ public E replace(Edge p, E o) throws InvalidPositionException; /** Returns the incoming edges to a vertex as an iterable collection */ public Iterable> incomingEdges(Vertex v) throws InvalidPositionException; /** Returns the outgoing edges to a vertex as an iterable collection */ public Iterable> outgoingEdges(Vertex v) throws InvalidPositionException; /** Returns the start and end vertices, in that order, of a edge as an array of length 2 */ public Vertex[] endVertices(Edge e) throws InvalidPositionException; /** Returns the other endvertex of an incident edge */ public Vertex opposite(Vertex v, Edge e) throws InvalidPositionException; /** Tests whether two vertices are adjacent */ public boolean areAdjacent(Vertex u, Vertex v) throws InvalidPositionException; /** Inserts and return a new vertex with a given element */ public Vertex insertVertex(V o); /** Inserts and return a new edge with a given element from one vertex to another */ public Edge insertEdge(Vertex from, Vertex to, E o) throws InvalidPositionException; /** Removes a vertex and all its incident edges and returns the element stored at the removed vertex */ public V removeVertex(Vertex v) throws InvalidPositionException; /** Removes an edge and return its element */ public E removeEdge(Edge e) throws InvalidPositionException; }