deba@937: /* -*- C++ -*- ladanyi@1435: * test/sym_graph_test.h - Part of LEMON, a generic C++ optimization library deba@937: * alpar@1164: * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport alpar@1359: * (Egervary Research Group on Combinatorial Optimization, EGRES). deba@937: * deba@937: * Permission to use, modify and distribute this software is granted deba@937: * provided that this copyright notice appears in all copies. For deba@937: * precise terms see the accompanying LICENSE file. deba@937: * deba@937: * This software is provided "AS IS" with no warranty of any kind, deba@937: * express or implied, and with no claim as to its suitability for any deba@937: * purpose. deba@937: * deba@937: */ deba@937: #ifndef LEMON_TEST_SYM_GRAPH_TEST_H deba@937: #define LEMON_TEST_SYM_GRAPH_TEST_H deba@937: deba@937: deba@937: #include "graph_test.h" deba@937: #include "test_tools.h" deba@937: deba@937: //! \ingroup misc deba@937: //! \file deba@937: //! \brief Some utility to test symmetric graph classes. deba@937: namespace lemon { alpar@938: alpar@938: /// \e deba@937: klao@959: /// \todo This should go to lemon/concept/symgraph.h alpar@938: /// deba@937: template void checkCompileStaticSymGraph(Graph &G) deba@937: { deba@937: typedef typename Graph::Node Node; deba@937: typedef typename Graph::NodeIt NodeIt; deba@937: typedef typename Graph::SymEdge SymEdge; deba@937: typedef typename Graph::SymEdgeIt SymEdgeIt; deba@937: typedef typename Graph::Edge Edge; deba@937: typedef typename Graph::EdgeIt EdgeIt; deba@937: typedef typename Graph::InEdgeIt InEdgeIt; deba@937: typedef typename Graph::OutEdgeIt OutEdgeIt; deba@937: klao@959: lemon::concept::checkCompileStaticGraph(G); deba@937: deba@937: { deba@937: SymEdge i; SymEdge j(i); SymEdge k(INVALID); deba@937: i=j; deba@937: bool b; b=true; deba@937: b=(i==INVALID); b=(i!=INVALID); deba@937: b=(i==j); b=(i!=j); b=(iSymEdgeIt conversion deba@937: SymEdgeIt ni(G,n); deba@937: } deba@937: { deba@937: Edge i, j; deba@937: j = G.opposite(i); deba@937: } deba@937: { deba@937: Node n; deba@937: SymEdge se; deba@937: se=INVALID; alpar@986: n=G.source(se); alpar@986: n=G.target(se); deba@937: } deba@937: // id tests deba@937: { SymEdge n; int i=G.id(n); i=i; } deba@937: //SymEdgeMap tests deba@937: { deba@937: SymEdge k; deba@937: typename Graph::template SymEdgeMap m(G); deba@937: typename Graph::template SymEdgeMap const &cm = m; //Const map deba@937: //Inicialize with default value deba@937: typename Graph::template SymEdgeMap mdef(G,12); deba@937: typename Graph::template SymEdgeMap mm(cm); //Copy deba@937: typename Graph::template SymEdgeMap dm(cm); //Copy from another type deba@937: int v; deba@937: v=m[k]; m[k]=v; m.set(k,v); deba@937: v=cm[k]; deba@937: deba@937: m=cm; deba@937: dm=cm; //Copy from another type deba@937: { deba@937: //Check the typedef's alpar@987: typename Graph::template SymEdgeMap::Value val; deba@937: val = 1; alpar@987: typename Graph::template SymEdgeMap::Key key; deba@937: key = typename Graph::SymEdgeIt(G); deba@937: } deba@937: } deba@937: { //bool SymEdgeMap deba@937: SymEdge k; deba@937: typename Graph::template SymEdgeMap m(G); deba@937: typename Graph::template SymEdgeMap const &cm = m; //Const map deba@937: //Inicialize with default value deba@937: typename Graph::template SymEdgeMap mdef(G,12); deba@937: typename Graph::template SymEdgeMap mm(cm); //Copy deba@937: typename Graph::template SymEdgeMap dm(cm); //Copy from another type deba@937: bool v; deba@937: v=m[k]; m[k]=v; m.set(k,v); deba@937: v=cm[k]; deba@937: deba@937: m=cm; deba@937: dm=cm; //Copy from another type deba@937: m=dm; //Copy to another type deba@937: { deba@937: //Check the typedef's alpar@987: typename Graph::template SymEdgeMap::Value val; deba@937: val=true; alpar@987: typename Graph::template SymEdgeMap::Key key; deba@937: key= typename Graph::SymEdgeIt(G); deba@937: } deba@937: } deba@937: } deba@937: deba@937: template void checkCompileSymGraph(Graph &G) deba@937: { deba@937: checkCompileStaticSymGraph(G); deba@937: deba@937: typedef typename Graph::Node Node; deba@937: typedef typename Graph::NodeIt NodeIt; deba@937: typedef typename Graph::SymEdge SymEdge; deba@937: typedef typename Graph::SymEdgeIt SymEdgeIt; deba@937: typedef typename Graph::Edge Edge; deba@937: typedef typename Graph::EdgeIt EdgeIt; deba@937: typedef typename Graph::InEdgeIt InEdgeIt; deba@937: typedef typename Graph::OutEdgeIt OutEdgeIt; deba@937: deba@937: Node n,m; deba@937: n=G.addNode(); deba@937: m=G.addNode(); deba@937: SymEdge e; deba@937: e = G.addEdge(n,m); deba@937: deba@937: // G.clear(); deba@937: } deba@937: deba@937: template void checkCompileSymGraphEraseSymEdge(Graph &G) deba@937: { deba@937: typename Graph::SymEdge n; deba@937: G.erase(n); deba@937: } deba@937: deba@937: template void checkCompileErasableSymGraph(Graph &G) deba@937: { deba@937: checkCompileSymGraph(G); klao@959: lemon::concept::checkCompileGraphEraseNode(G); deba@937: checkCompileSymGraphEraseSymEdge(G); deba@937: } deba@937: deba@937: template void checkGraphSymEdgeList(Graph &G, int nn) deba@937: { deba@937: typedef typename Graph::SymEdgeIt SymEdgeIt; deba@937: deba@937: SymEdgeIt e(G); deba@937: for(int i=0;i