1.1 --- a/test/sym_graph_test.cc Mon Nov 21 17:48:00 2005 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,98 +0,0 @@
1.4 -/* -*- C++ -*-
1.5 - * test/sym_graph_test.cc - Part of LEMON, a generic C++ optimization library
1.6 - *
1.7 - * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.8 - * (Egervary Research Group on Combinatorial Optimization, EGRES).
1.9 - *
1.10 - * Permission to use, modify and distribute this software is granted
1.11 - * provided that this copyright notice appears in all copies. For
1.12 - * precise terms see the accompanying LICENSE file.
1.13 - *
1.14 - * This software is provided "AS IS" with no warranty of any kind,
1.15 - * express or implied, and with no claim as to its suitability for any
1.16 - * purpose.
1.17 - *
1.18 - */
1.19 -
1.20 -#include<iostream>
1.21 -
1.22 -#include<lemon/concept/sym_graph.h>
1.23 -
1.24 -#include<lemon/list_graph.h>
1.25 -#include<lemon/smart_graph.h>
1.26 -#include<lemon/full_graph.h>
1.27 -
1.28 -#include"test_tools.h"
1.29 -#include"graph_test.h"
1.30 -#include"sym_graph_test.h"
1.31 -
1.32 -/**
1.33 -\file
1.34 -This test makes consistency checks of list graph structures.
1.35 -
1.36 -G.addNode(), G.addEdge(), G.source(), G.target()
1.37 -
1.38 -\todo Checks for empty graphs and isolated points.
1.39 -conversion.
1.40 -*/
1.41 -
1.42 -using namespace lemon;
1.43 -
1.44 -template<class Graph> void checkPetersen(Graph &G)
1.45 -{
1.46 - typedef typename Graph::NodeIt NodeIt;
1.47 -
1.48 -
1.49 - checkGraphNodeList(G,10);
1.50 - checkGraphEdgeList(G,30);
1.51 - checkGraphSymEdgeList(G,15);
1.52 -
1.53 - for(NodeIt n(G);n!=INVALID;++n) {
1.54 - checkGraphInEdgeList(G,n,3);
1.55 - checkGraphOutEdgeList(G,n,3);
1.56 - }
1.57 -}
1.58 -
1.59 -//Compile Graph
1.60 -template void lemon::checkCompileStaticSymGraph<concept::StaticSymGraph>
1.61 -(concept::StaticSymGraph &);
1.62 -
1.63 -template void lemon::checkCompileSymGraph<concept::ExtendableSymGraph>
1.64 -(concept::ExtendableSymGraph &);
1.65 -
1.66 -template void lemon::checkCompileErasableSymGraph<concept::ErasableSymGraph>
1.67 -(concept::ErasableSymGraph &);
1.68 -
1.69 -
1.70 -//Compile SymSmartGraph
1.71 -template void lemon::checkCompileSymGraph<SymSmartGraph>(SymSmartGraph &);
1.72 -template
1.73 -void lemon::concept::checkCompileGraphFindEdge<SymSmartGraph>(SymSmartGraph &);
1.74 -
1.75 -//Compile SymListGraph
1.76 -template void lemon::checkCompileSymGraph<SymListGraph>(SymListGraph &);
1.77 -template void lemon::checkCompileErasableSymGraph<SymListGraph>(SymListGraph &);
1.78 -template
1.79 -void lemon::concept::checkCompileGraphFindEdge<SymListGraph>(SymListGraph &);
1.80 -
1.81 -int main()
1.82 -{
1.83 - {
1.84 - SymSmartGraph G;
1.85 - addSymPetersen(G);
1.86 - checkPetersen(G);
1.87 - }
1.88 - {
1.89 - SymListGraph G;
1.90 - addSymPetersen(G);
1.91 - checkPetersen(G);
1.92 - }
1.93 -
1.94 - ///\file
1.95 - ///\todo map tests.
1.96 - ///\todo copy constr tests.
1.97 -
1.98 - std::cout << __FILE__ ": All tests passed.\n";
1.99 -
1.100 - return 0;
1.101 -}
2.1 --- a/test/sym_graph_test.h Mon Nov 21 17:48:00 2005 +0000
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,183 +0,0 @@
2.4 -/* -*- C++ -*-
2.5 - * test/sym_graph_test.h - Part of LEMON, a generic C++ optimization library
2.6 - *
2.7 - * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
2.8 - * (Egervary Research Group on Combinatorial Optimization, EGRES).
2.9 - *
2.10 - * Permission to use, modify and distribute this software is granted
2.11 - * provided that this copyright notice appears in all copies. For
2.12 - * precise terms see the accompanying LICENSE file.
2.13 - *
2.14 - * This software is provided "AS IS" with no warranty of any kind,
2.15 - * express or implied, and with no claim as to its suitability for any
2.16 - * purpose.
2.17 - *
2.18 - */
2.19 -#ifndef LEMON_TEST_SYM_GRAPH_TEST_H
2.20 -#define LEMON_TEST_SYM_GRAPH_TEST_H
2.21 -
2.22 -
2.23 -#include "graph_test.h"
2.24 -#include "test_tools.h"
2.25 -
2.26 -//! \ingroup misc
2.27 -//! \file
2.28 -//! \brief Some utility to test symmetric graph classes.
2.29 -namespace lemon {
2.30 -
2.31 - /// \e
2.32 -
2.33 - /// \todo This should go to lemon/concept/symgraph.h
2.34 - ///
2.35 - template<class Graph> void checkCompileStaticSymGraph(Graph &G)
2.36 - {
2.37 - typedef typename Graph::Node Node;
2.38 - typedef typename Graph::NodeIt NodeIt;
2.39 - typedef typename Graph::SymEdge SymEdge;
2.40 - typedef typename Graph::SymEdgeIt SymEdgeIt;
2.41 - typedef typename Graph::Edge Edge;
2.42 - typedef typename Graph::EdgeIt EdgeIt;
2.43 - typedef typename Graph::InEdgeIt InEdgeIt;
2.44 - typedef typename Graph::OutEdgeIt OutEdgeIt;
2.45 -
2.46 - lemon::concept::checkCompileStaticGraph(G);
2.47 -
2.48 - {
2.49 - SymEdge i; SymEdge j(i); SymEdge k(INVALID);
2.50 - i=j;
2.51 - bool b; b=true;
2.52 - b=(i==INVALID); b=(i!=INVALID);
2.53 - b=(i==j); b=(i!=j); b=(i<j);
2.54 - Edge e;
2.55 - e = G.forward(i);
2.56 - e = G.backward(i);
2.57 - }
2.58 - {
2.59 - SymEdgeIt i; SymEdgeIt j(i); SymEdgeIt k(INVALID); SymEdgeIt l(G);
2.60 - i=j;
2.61 - j=G.first(i);
2.62 - j=++i;
2.63 - bool b; b=true;
2.64 - b=(i==INVALID); b=(i!=INVALID);
2.65 - SymEdge n(i);
2.66 - n=i;
2.67 - b=(i==j); b=(i!=j); b=(i<j);
2.68 - //SymEdge ->SymEdgeIt conversion
2.69 - SymEdgeIt ni(G,n);
2.70 - }
2.71 - {
2.72 - Edge i, j;
2.73 - j = G.opposite(i);
2.74 - }
2.75 - {
2.76 - Node n;
2.77 - SymEdge se;
2.78 - se=INVALID;
2.79 - n=G.source(se);
2.80 - n=G.target(se);
2.81 - }
2.82 - // id tests
2.83 - { SymEdge n; int i=G.id(n); i=i; }
2.84 - //SymEdgeMap tests
2.85 - {
2.86 - SymEdge k;
2.87 - typename Graph::template SymEdgeMap<int> m(G);
2.88 - typename Graph::template SymEdgeMap<int> const &cm = m; //Const map
2.89 - //Inicialize with default value
2.90 - typename Graph::template SymEdgeMap<int> mdef(G,12);
2.91 - typename Graph::template SymEdgeMap<int> mm(cm); //Copy
2.92 - typename Graph::template SymEdgeMap<double> dm(cm); //Copy from another type
2.93 - int v;
2.94 - v=m[k]; m[k]=v; m.set(k,v);
2.95 - v=cm[k];
2.96 -
2.97 - m=cm;
2.98 - dm=cm; //Copy from another type
2.99 - {
2.100 - //Check the typedef's
2.101 - typename Graph::template SymEdgeMap<int>::Value val;
2.102 - val = 1;
2.103 - typename Graph::template SymEdgeMap<int>::Key key;
2.104 - key = typename Graph::SymEdgeIt(G);
2.105 - }
2.106 - }
2.107 - { //bool SymEdgeMap
2.108 - SymEdge k;
2.109 - typename Graph::template SymEdgeMap<bool> m(G);
2.110 - typename Graph::template SymEdgeMap<bool> const &cm = m; //Const map
2.111 - //Inicialize with default value
2.112 - typename Graph::template SymEdgeMap<bool> mdef(G,12);
2.113 - typename Graph::template SymEdgeMap<bool> mm(cm); //Copy
2.114 - typename Graph::template SymEdgeMap<int> dm(cm); //Copy from another type
2.115 - bool v;
2.116 - v=m[k]; m[k]=v; m.set(k,v);
2.117 - v=cm[k];
2.118 -
2.119 - m=cm;
2.120 - dm=cm; //Copy from another type
2.121 - m=dm; //Copy to another type
2.122 - {
2.123 - //Check the typedef's
2.124 - typename Graph::template SymEdgeMap<bool>::Value val;
2.125 - val=true;
2.126 - typename Graph::template SymEdgeMap<bool>::Key key;
2.127 - key= typename Graph::SymEdgeIt(G);
2.128 - }
2.129 - }
2.130 - }
2.131 -
2.132 - template<class Graph> void checkCompileSymGraph(Graph &G)
2.133 - {
2.134 - checkCompileStaticSymGraph(G);
2.135 -
2.136 - typedef typename Graph::Node Node;
2.137 - typedef typename Graph::NodeIt NodeIt;
2.138 - typedef typename Graph::SymEdge SymEdge;
2.139 - typedef typename Graph::SymEdgeIt SymEdgeIt;
2.140 - typedef typename Graph::Edge Edge;
2.141 - typedef typename Graph::EdgeIt EdgeIt;
2.142 - typedef typename Graph::InEdgeIt InEdgeIt;
2.143 - typedef typename Graph::OutEdgeIt OutEdgeIt;
2.144 -
2.145 - Node n,m;
2.146 - n=G.addNode();
2.147 - m=G.addNode();
2.148 - SymEdge e;
2.149 - e = G.addEdge(n,m);
2.150 -
2.151 - // G.clear();
2.152 - }
2.153 -
2.154 - template<class Graph> void checkCompileSymGraphEraseSymEdge(Graph &G)
2.155 - {
2.156 - typename Graph::SymEdge n;
2.157 - G.erase(n);
2.158 - }
2.159 -
2.160 - template<class Graph> void checkCompileErasableSymGraph(Graph &G)
2.161 - {
2.162 - checkCompileSymGraph(G);
2.163 - lemon::concept::checkCompileGraphEraseNode(G);
2.164 - checkCompileSymGraphEraseSymEdge(G);
2.165 - }
2.166 -
2.167 - template<class Graph> void checkGraphSymEdgeList(Graph &G, int nn)
2.168 - {
2.169 - typedef typename Graph::SymEdgeIt SymEdgeIt;
2.170 -
2.171 - SymEdgeIt e(G);
2.172 - for(int i=0;i<nn;i++) {
2.173 - check(e!=INVALID,"Wrong SymEdge list linking.");
2.174 - ++e;
2.175 - }
2.176 - check(e==INVALID,"Wrong SymEdge list linking.");
2.177 - }
2.178 -
2.179 - ///\file
2.180 - ///\todo Check target(), source() as well;
2.181 -
2.182 -
2.183 -} //namespace lemon
2.184 -
2.185 -
2.186 -#endif