package edu.caltech.cs2.interfaces;

public interface IGraph<V, E> {
    /**
     * Add a vertex to the graph.
     * @param vertex The vertex to add
     * @return true if vertex was not present already.
     */
    public boolean addVertex(V vertex);

    /**
     * Adds edge e to the graph.
     *
     * @param e The edge to add.
     * @throws IllegalArgumentException
     *             If src and dest are not valid vertices (eg. refers to vertices not in the graph).
     * @return true If src and dest were not already present; false if it was (in which case the graph is still updated).
     */
    public boolean addEdge(V src, V dest, E e);

    /**
     * Adds edge e to the graph in both directionns.
     *
     * @param e The edge to add.
     * @throws IllegalArgumentException
     *    If src and dest are not valid vertices (eg. refers to vertices not in the graph).
     * @return true If src and dest were not already present in either direction; false if it was (in which case the graph is still updated).
     */
    public boolean addUndirectedEdge(V src, V dest, E e);

    /**
     * Remove an edge from src to dest from the graph.
     *
     * @throws IllegalArgumentException if src or dest is not in the graph.
     * @return true if an edge from src to dest edge was present.
     */
    public boolean removeEdge(V src, V dest);

    /**
     * Returns the set of vertices in the graph.
     * @return The set of all vertices in the graph.
     */
    public ISet<V> vertices();

    /**
     * Tests if vertices i and j are adjacent, returning the edge between
     * them if so.
     *
     * @throws IllegalArgumentException if i or j are not vertices in the graph.
     * @return The edge from i to j if it exists in the graph;
     * 		   null otherwise.
     */
    public E adjacent(V i, V j);

    /**
     * Return the neighbours of a given vertex when this graph is treated as
     * DIRECTED; that is, vertices to which vertex has an outgoing edge.
     *
     * @param vertex The vertex the neighbours of which to return.
     * @throws IllegalArgumentException if vertex is not in the graph.
     * @return The set of neighbors of vertex.
     */
    public ISet<V> neighbors(V vertex);
}