#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <queue>
#include "core/IdGraph.h"

#ifndef CHANNELDEPENDENCYGRAPH_H_
#define CHANNELDEPENDENCYGRAPH_H_

namespace cosi {

namespace commstruct {

namespace onchipcommunication {

using namespace std ;

/**Basic data structure for representing a Channel Dependency Graph.
 *
 *
 *@author Alessandro Pinto,
 *@author apinto@eecs.berkeley.edu,
 *@author EECS Grad Student,
 *@author 211 Cory Hall #1772,
 *@author Berkeley, CA, 94720-1772
 *@author (510)-6429670

 *@version $Id: ChannelDependencyGraph.h,v 1.1 2008/02/20 04:21:21 apinto Exp $
 */


class ChannelDependencyGraph : public IdGraph
{
public:

  /**\brief Defult Constructor*/
  ChannelDependencyGraph( string Name ) ;
  /**\brief Defult Destructor*/
  ~ChannelDependencyGraph ( ) ;

  /**\brief Union of vertices and edges.*/
  void Union( ChannelDependencyGraph G ) ;

  /**\brief Adds a channel.*/
  void AddChannel( pair<int,int> pChannel );

  /**\brief Returns true if  the vertex is in the graph.*/
  bool InC( pair<int,int> pChannel ) ;

  /**\brief Returns true if the edge (i,j) is in the graph.*/
  bool InD( pair<int,int> pChannel1 , pair<int,int> pChannel2 )  ;

  /**\brief Adds an edge between i and j.*/
  void AddDependency( pair<int,int> pChannel1 , pair<int,int> pChannel2 ) ;

  void RemoveDependency( pair<int,int> pChannel1 , pair<int,int> pChannel2 ) ;

  vector< pair< int , int > > GetChannels( )   ;

  //list_iterator in_begin( pair<int,int> pChannel ) ;
  //list_iterator in_end( pair<int,int> pChannel ) ;
  //list_iterator out_begin( pair<int,int> pChannel ) ;
  //list_iterator out_end( pair<int,int> pChannel ) ;

  bool Reachable( pair<int, int > pChannel1 , pair<int,int> pChannel2 ) ;

  bool Cyclic( ) ;

 private:

  map< pair< int , int > , int > mChannelToVertex ;

} ;
}
}
}


#endif /*CHANNELDEPENDENCYGRAPH_H_*/
