alpar@906: /* -*- C++ -*- alpar@921: * src/test/graph_test.cc - Part of LEMON, a generic C++ optimization library alpar@906: * alpar@906: * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport alpar@906: * (Egervary Combinatorial Optimization Research Group, EGRES). alpar@906: * alpar@906: * Permission to use, modify and distribute this software is granted alpar@906: * provided that this copyright notice appears in all copies. For alpar@906: * precise terms see the accompanying LICENSE file. alpar@906: * alpar@906: * This software is provided "AS IS" with no warranty of any kind, alpar@906: * express or implied, and with no claim as to its suitability for any alpar@906: * purpose. alpar@906: * alpar@906: */ alpar@906: alpar@503: #include alpar@921: #include alpar@921: #include alpar@921: #include alpar@921: #include alpar@578: alpar@567: #include"test_tools.h" alpar@800: #include"graph_test.h" alpar@567: alpar@774: /** alpar@774: \file alpar@503: This test makes consistency checks of list graph structures. alpar@503: alpar@774: G.addNode(), G.addEdge(), G.tail(), G.head() alpar@503: alpar@592: \todo Checks for empty graphs and isolated points. alpar@774: conversion. alpar@503: */ alpar@503: alpar@921: using namespace lemon; alpar@503: alpar@503: template void bidirPetersen(Graph &G) alpar@503: { alpar@503: typedef typename Graph::Edge Edge; alpar@503: typedef typename Graph::EdgeIt EdgeIt; alpar@503: alpar@800: checkGraphEdgeList(G,15); alpar@503: alpar@503: std::vector ee; alpar@503: alpar@774: for(EdgeIt e(G);e!=INVALID;++e) ee.push_back(e); alpar@503: alpar@503: for(typename std::vector::iterator p=ee.begin();p!=ee.end();p++) alpar@503: G.addEdge(G.head(*p),G.tail(*p)); alpar@503: } alpar@503: alpar@503: template void checkPetersen(Graph &G) alpar@503: { alpar@503: typedef typename Graph::Node Node; alpar@503: alpar@503: typedef typename Graph::EdgeIt EdgeIt; alpar@503: typedef typename Graph::NodeIt NodeIt; alpar@503: alpar@800: checkGraphNodeList(G,10); alpar@800: checkGraphEdgeList(G,30); alpar@503: alpar@774: for(NodeIt n(G);n!=INVALID;++n) { alpar@800: checkGraphInEdgeList(G,n,3); alpar@800: checkGraphOutEdgeList(G,n,3); alpar@919: ++n; alpar@503: } alpar@503: } alpar@503: alpar@880: //Compile Graph alpar@921: template void lemon::checkCompileStaticGraph alpar@880: (skeleton::StaticGraph &); alpar@793: alpar@921: template void lemon::checkCompileGraph alpar@880: (skeleton::ExtendableGraph &); alpar@793: alpar@921: template void lemon::checkCompileErasableGraph alpar@880: (skeleton::ErasableGraph &); alpar@733: alpar@774: //Compile SmartGraph alpar@921: template void lemon::checkCompileGraph(SmartGraph &); alpar@921: template void lemon::checkCompileGraphFindEdge(SmartGraph &); deba@783: alpar@774: //Compile SymSmartGraph alpar@921: template void lemon::checkCompileGraph(SymSmartGraph &); alpar@921: template void lemon::checkCompileGraphFindEdge(SymSmartGraph &); alpar@774: alpar@774: //Compile ListGraph alpar@921: template void lemon::checkCompileGraph(ListGraph &); alpar@921: template void lemon::checkCompileErasableGraph(ListGraph &); alpar@921: template void lemon::checkCompileGraphFindEdge(ListGraph &); alpar@774: deba@783: alpar@774: //Compile SymListGraph alpar@921: template void lemon::checkCompileGraph(SymListGraph &); alpar@921: template void lemon::checkCompileErasableGraph(SymListGraph &); alpar@921: template void lemon::checkCompileGraphFindEdge(SymListGraph &); alpar@774: alpar@774: //Compile FullGraph alpar@921: template void lemon::checkCompileStaticGraph(FullGraph &); alpar@921: template void lemon::checkCompileGraphFindEdge(FullGraph &); alpar@550: alpar@774: //Compile EdgeSet alpar@921: template void lemon::checkCompileGraph > alpar@800: (EdgeSet &); alpar@921: template void lemon::checkCompileGraphEraseEdge > alpar@873: (EdgeSet &); alpar@921: template void lemon::checkCompileGraphFindEdge > alpar@800: (EdgeSet &); alpar@774: alpar@774: //Compile EdgeSet alpar@921: template void lemon::checkCompileGraph >(EdgeSet &); alpar@921: template void lemon::checkCompileGraphEraseEdge > alpar@800: (EdgeSet &); alpar@921: template void lemon::checkCompileGraphFindEdge > alpar@800: (EdgeSet &); alpar@774: alpar@503: alpar@503: int main() alpar@503: { alpar@503: { alpar@503: SmartGraph G; alpar@503: addPetersen(G); alpar@503: bidirPetersen(G); alpar@503: checkPetersen(G); alpar@503: } alpar@578: { alpar@578: ListGraph G; alpar@578: addPetersen(G); alpar@578: bidirPetersen(G); alpar@578: checkPetersen(G); alpar@578: } alpar@503: { alpar@919: SymSmartGraph G; alpar@919: addPetersen(G); alpar@919: checkPetersen(G); alpar@503: } alpar@578: { alpar@919: SymListGraph G; alpar@919: addPetersen(G); alpar@919: checkPetersen(G); alpar@578: } alpar@503: alpar@774: ///\file alpar@774: ///\todo map tests. alpar@774: ///\todo copy constr tests. alpar@503: alpar@503: std::cout << __FILE__ ": All tests passed.\n"; alpar@503: alpar@579: return 0; alpar@503: }