#include #include #include #include"test_tools.h" //#include<../work/alpar/list_graph.h> /* This test makes consistency checks of list graph structures. G.addNode(), G.addEdge(), G.valid(), G.tail(), G.head() */ using namespace hugo; template void checkCompile(Graph &G) { typedef typename Graph::Node Node; typedef typename Graph::NodeIt NodeIt; typedef typename Graph::Edge Edge; typedef typename Graph::EdgeIt EdgeIt; typedef typename Graph::InEdgeIt InEdgeIt; typedef typename Graph::OutEdgeIt OutEdgeIt; { Node i; Node j(i); Node k(INVALID); i=j; bool b=G.valid(i); b=b; b=(i==j); b=(i!=j); b=(i m(G); typename Graph::template NodeMap const &cm = m; //Const map //Inicialize with default value typename Graph::template NodeMap mdef(G,12); typename Graph::template NodeMap mm(cm); //Copy typename Graph::template NodeMap dm(cm); //Copy from another type int v; v=m[k]; m[k]=v; m.set(k,v); v=cm[k]; m=cm; dm=cm; //Copy from another type } { //bool NodeMap Node k; typename Graph::template NodeMap m(G); typename Graph::template NodeMap const &cm = m; //Const map //Inicialize with default value typename Graph::template NodeMap mdef(G,12); typename Graph::template NodeMap mm(cm); //Copy typename Graph::template NodeMap dm(cm); //Copy from another type bool v; v=m[k]; m[k]=v; m.set(k,v); v=cm[k]; m=cm; dm=cm; //Copy from another type m=dm; //Copy to another type } //EdgeMap tests { Edge k; typename Graph::template EdgeMap m(G); typename Graph::template EdgeMap const &cm = m; //Const map //Inicialize with default value typename Graph::template EdgeMap mdef(G,12); typename Graph::template EdgeMap mm(cm); //Copy typename Graph::template EdgeMap dm(cm); //Copy from another type int v; v=m[k]; m[k]=v; m.set(k,v); v=cm[k]; m=cm; dm=cm; //Copy from another type } { //bool EdgeMap Edge k; typename Graph::template EdgeMap m(G); typename Graph::template EdgeMap const &cm = m; //Const map //Inicialize with default value typename Graph::template EdgeMap mdef(G,12); typename Graph::template EdgeMap mm(cm); //Copy typename Graph::template EdgeMap dm(cm); //Copy from another type bool v; v=m[k]; m[k]=v; m.set(k,v); v=cm[k]; m=cm; dm=cm; //Copy from another type m=dm; //Copy to another type } } template void checkNodeList(Graph &G, int nn) { typename Graph::NodeIt n(G); for(int i=0;i void checkEdgeList(Graph &G, int nn) { typedef typename Graph::EdgeIt EdgeIt; EdgeIt e(G); for(int i=0;i void checkOutEdgeList(Graph &G, typename Graph::Node n, int nn) { typename Graph::OutEdgeIt e(G,n); for(int i=0;i void checkInEdgeList(Graph &G, typename Graph::Node n, int nn) { typename Graph::InEdgeIt e(G,n); for(int i=0;i void bidirPetersen(Graph &G) { typedef typename Graph::Edge Edge; typedef typename Graph::EdgeIt EdgeIt; checkEdgeList(G,15); std::vector ee; for(EdgeIt e(G);G.valid(e);G.next(e)) ee.push_back(e); for(typename std::vector::iterator p=ee.begin();p!=ee.end();p++) G.addEdge(G.head(*p),G.tail(*p)); } template void checkPetersen(Graph &G) { typedef typename Graph::Node Node; typedef typename Graph::EdgeIt EdgeIt; typedef typename Graph::NodeIt NodeIt; checkNodeList(G,10); checkEdgeList(G,30); for(NodeIt n(G);G.valid(n);G.next(n)) { checkInEdgeList(G,n,3); checkOutEdgeList(G,n,3); G.next(n); } } template void checkCompile(GraphSkeleton &); template void checkCompile(SmartGraph &); template void checkCompile(SymSmartGraph &); //template void checkCompile(ListGraph &); //template void checkCompile(SymListGraph &); //Due to some mysterious and some conceptual problems it does not work. //template void checkCompile >(EdgeSet &); 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); // } //\todo map tests. //\todo copy constr tests. std::cout << __FILE__ ": All tests passed.\n"; }