
package com.dataart.spreadsheetanalytics.api.model;

import java.util.Collection;

import com.dataart.spreadsheetanalytics.api.engine.IAuditor;
import com.dataart.spreadsheetanalytics.engine.CalculationEngineException;

/**
 * Represents execution graph. Can be got from {@link IAuditor} methods.
 * Contains {@link IExecutionGraphVertex} and {@link IExecutionGraphEdge}.
 */
public interface IExecutionGraph<V extends IExecutionGraphVertex, E extends IExecutionGraphEdge> {

    /**
     * Returns the root vertex of ExecutionGraph
     *
     * @throws CalculationEngineException if there is no root vertex
     */
    V getRootVertex() throws CalculationEngineException;

    /**
     * Returns the set of the graph edges 
     */
    Collection<E> getEdges();

    /**
     * Returns the set of the graph vertices
     */
    Collection<V> getVertices();

    /**
     * Returns the source vertex of specified edge
     */
    V getEdgeSource(E edge);

    /**
     * Returns the target vertex of specified edge
     */
    V getEdgeTarget(E edge);

    void addVertex(V vertex);
    
    void addEdge(V from, V to);
    
    void removeVertex(V vertex);
    
    Collection<E> getIncomingEdgesOf(V vertex);
    
    Collection<E> getOutgoingEdgesOf(V vertex);
    
    boolean containsVertex(V vertex);
}
