#include<iostream>
#include<hugo/smart_graph.h>
#include<hugo/skeletons/graph.h>
#include<hugo/list_graph.h>
#include<hugo/full_graph.h>

#include"test_tools.h"
#include"graph_test.h"

/**
\file
This test makes consistency checks of list graph structures.

G.addNode(), G.addEdge(), G.tail(), G.head()

\todo Checks for empty graphs and isolated points.
conversion.
*/

using namespace hugo;

template<class Graph> void bidirPetersen(Graph &G)
{
  typedef typename Graph::Edge Edge;
  typedef typename Graph::EdgeIt EdgeIt;
  
  checkGraphEdgeList(G,15);
  
  std::vector<Edge> ee;
  
  for(EdgeIt e(G);e!=INVALID;++e) ee.push_back(e);

  for(typename std::vector<Edge>::iterator p=ee.begin();p!=ee.end();p++)
    G.addEdge(G.head(*p),G.tail(*p));
}

template<class Graph> void checkPetersen(Graph &G)
{
  typedef typename Graph::Node Node;

  typedef typename Graph::EdgeIt EdgeIt;
  typedef typename Graph::NodeIt NodeIt;

  checkGraphNodeList(G,10);
  checkGraphEdgeList(G,30);

  for(NodeIt n(G);n!=INVALID;++n) {
    checkGraphInEdgeList(G,n,3);
    checkGraphOutEdgeList(G,n,3);
    ++n;
  }  
}

//Compile GraphSkeleton
template void checkCompileStaticGraph<skeleton::StaticGraphSkeleton>
(skeleton::StaticGraphSkeleton &);

template void checkCompileGraph<skeleton::GraphSkeleton>
(skeleton::GraphSkeleton &);

template void checkCompileErasableGraph<skeleton::ErasableGraphSkeleton>
(skeleton::ErasableGraphSkeleton &);

//Compile SmartGraph
template void checkCompileGraph<SmartGraph>(SmartGraph &);
template void checkCompileGraphFindEdge<SmartGraph>(SmartGraph &);

//Compile SymSmartGraph
template void checkCompileGraph<SymSmartGraph>(SymSmartGraph &);
template void checkCompileGraphFindEdge<SymSmartGraph>(SymSmartGraph &);

//Compile ListGraph
template void checkCompileGraph<ListGraph>(ListGraph &);
template void checkCompileErasableGraph<ListGraph>(ListGraph &);
template void checkCompileGraphFindEdge<ListGraph>(ListGraph &);


//Compile SymListGraph
template void checkCompileGraph<SymListGraph>(SymListGraph &);
template void checkCompileErasableGraph<SymListGraph>(SymListGraph &);
template void checkCompileGraphFindEdge<SymListGraph>(SymListGraph &);

//Compile FullGraph
template void checkCompileStaticGraph<FullGraph>(FullGraph &);
template void checkCompileGraphFindEdge<FullGraph>(FullGraph &);

//Compile EdgeSet <ListGraph>
template void checkCompileGraph<EdgeSet <ListGraph> >(EdgeSet <ListGraph> &);
template void checkCompileGraphEraseEdge<EdgeSet <ListGraph> >
(EdgeSet <ListGraph> &);
template void checkCompileGraphFindEdge<EdgeSet <ListGraph> >
(EdgeSet <ListGraph> &);

//Compile EdgeSet <NodeSet>
template void checkCompileGraph<EdgeSet <NodeSet> >(EdgeSet <NodeSet> &);
template void checkCompileGraphEraseEdge<EdgeSet <NodeSet> >
(EdgeSet <NodeSet> &);
template void checkCompileGraphFindEdge<EdgeSet <NodeSet> >
(EdgeSet <NodeSet> &);


int main() 
{
  {
    SmartGraph G;
    addPetersen(G);
    bidirPetersen(G);
    checkPetersen(G);
  }
  {
    ListGraph G;
    addPetersen(G);
    bidirPetersen(G);
    checkPetersen(G);
  }
  {
    SymSmartGraph G;
    addPetersen(G);
    checkPetersen(G);
  }
  {
    SymListGraph G;
    addPetersen(G);
    checkPetersen(G);
  }

  ///\file
  ///\todo map tests.
  ///\todo copy constr tests.

  std::cout << __FILE__ ": All tests passed.\n";

  return 0;
}
