package javakurs.uebung08;

/**
 * {@link GraphVisitor} defines the interface for visitors used in depth first
 * search and breadth first search.
 *
 * @param <EdgeInfo>
 *          the kind of information assigned to the edges of the traversed graph
 *
 * @author Bernd Kiefer, DFKi
 * @author Joerg Steffen, DFKI
 * @version $Id$
 */
public interface GraphVisitor<EdgeInfo> {

  /**
   * In the BFS/DFS variants that visits each vertex of the graph, this method
   * is called for the start vertices where the real search begins.
   *
   * @param v
   *          the start vertex
   * @param g
   *          the graph to which the start vertex belongs to
   */
  void startVertex(int v, DirectedGraphBase<EdgeInfo> g);


  /**
   * This method is called when a vertex turns from white to gray.
   *
   * @param v
   *          the vertex that is discovered
   * @param g
   *          the graph to which the discovered vertex belongs to
   */
  void discoverVertex(int v, DirectedGraphBase<EdgeInfo> g);


  /**
   * This method is called when a vertex turns from gray to black.
   *
   * @param v
   *          the vertex that is left
   * @param g
   *          the graph to which the left vertex belongs to
   * */
  void finishVertex(int v, DirectedGraphBase<EdgeInfo> g);


  /**
   * This method is called when a tree edge is used.
   *
   * @param e
   *          the tree edge
   * @param g
   *          the graph to which the tree edge belongs to
   */
  void treeEdge(Edge<EdgeInfo> e, DirectedGraphBase<EdgeInfo> g);


  /**
   * This method is called when a non-tree edge is used.
   *
   * @param e
   *          the non-tree edge
   * @param g
   *          the graph to which the non-tree edge belongs to
   */
  void nonTreeEdge(Edge<EdgeInfo> e, DirectedGraphBase<EdgeInfo> g);

}
