src/test/graph_test.cc
changeset 946 c94ef40a22ce
parent 938 70e2886211d5
child 959 c80ef5912903
     1.1 --- a/src/test/graph_test.cc	Mon Oct 25 13:29:46 2004 +0000
     1.2 +++ b/src/test/graph_test.cc	Wed Oct 27 22:38:50 2004 +0000
     1.3 @@ -1,157 +1,67 @@
     1.4 -/* -*- C++ -*-
     1.5 - * src/test/graph_test.cc - Part of LEMON, a generic C++ optimization library
     1.6 - *
     1.7 - * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     1.8 - * (Egervary Combinatorial Optimization Research Group, 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 +// -*- c++ -*-
    1.20  
    1.21 -#include<iostream>
    1.22 -#include<lemon/smart_graph.h>
    1.23 -#include<lemon/skeletons/graph.h>
    1.24 -#include<lemon/list_graph.h>
    1.25 -#include<lemon/full_graph.h>
    1.26 +#include <iostream>
    1.27 +#include <vector>
    1.28  
    1.29 -#include"test_tools.h"
    1.30 -#include"graph_test.h"
    1.31 +#include <lemon/skeletons/graph.h>
    1.32 +#include <lemon/list_graph.h>
    1.33 +#include <lemon/smart_graph.h>
    1.34 +#include <lemon/full_graph.h>
    1.35  
    1.36 -/**
    1.37 -\file
    1.38 -This test makes consistency checks of list graph structures.
    1.39 +#include "test_tools.h"
    1.40 +#include "graph_test.h"
    1.41 +#include "map_test.h"
    1.42  
    1.43 -G.addNode(), G.addEdge(), G.tail(), G.head()
    1.44 -
    1.45 -\todo Checks for empty graphs and isolated points.
    1.46 -conversion.
    1.47 -*/
    1.48  
    1.49  using namespace lemon;
    1.50 +using namespace lemon::skeleton;
    1.51  
    1.52 -template<class Graph> void bidirPetersen(Graph &G)
    1.53 -{
    1.54 -  typedef typename Graph::Edge Edge;
    1.55 -  typedef typename Graph::EdgeIt EdgeIt;
    1.56 -  
    1.57 -  checkGraphEdgeList(G,15);
    1.58 -  
    1.59 -  std::vector<Edge> ee;
    1.60 -  
    1.61 -  for(EdgeIt e(G);e!=INVALID;++e) ee.push_back(e);
    1.62  
    1.63 -  for(typename std::vector<Edge>::iterator p=ee.begin();p!=ee.end();p++)
    1.64 -    G.addEdge(G.head(*p),G.tail(*p));
    1.65 -}
    1.66 +int main() {
    1.67 +  ///\file
    1.68 +  { // checking graph components
    1.69 +    function_requires<BaseGraphComponentConcept<BaseGraphComponent> >();
    1.70  
    1.71 -template<class Graph> void checkPetersen(Graph &G)
    1.72 -{
    1.73 -  typedef typename Graph::Node Node;
    1.74 +    function_requires<BaseIterableGraphComponentConcept<BaseIterableGraphComponent> >();
    1.75  
    1.76 -  typedef typename Graph::EdgeIt EdgeIt;
    1.77 -  typedef typename Graph::NodeIt NodeIt;
    1.78 +    function_requires<IDableGraphComponentConcept<IDableGraphComponent> >();
    1.79 +    function_requires<MaxIDableGraphComponentConcept<MaxIDableGraphComponent> >();
    1.80  
    1.81 -  checkGraphNodeList(G,10);
    1.82 -  checkGraphEdgeList(G,30);
    1.83 +    function_requires<BaseExtendableGraphComponentConcept<BaseExtendableGraphComponent> >();
    1.84 +    function_requires<BaseErasableGraphComponentConcept<BaseErasableGraphComponent> >();
    1.85 +    function_requires<BaseClearableGraphComponentConcept<BaseClearableGraphComponent> >();
    1.86  
    1.87 -  for(NodeIt n(G);n!=INVALID;++n) {
    1.88 -    checkGraphInEdgeList(G,n,3);
    1.89 -    checkGraphOutEdgeList(G,n,3);
    1.90 -  }  
    1.91 -}
    1.92 +    function_requires<IterableGraphComponentConcept<IterableGraphComponent> >();
    1.93  
    1.94 -//Compile Graph
    1.95 -template void lemon::skeleton::checkCompileStaticGraph<skeleton::StaticGraph>
    1.96 -(skeleton::StaticGraph &);
    1.97 +    function_requires<IdMappableGraphComponentConcept<IdMappableGraphComponent> >();
    1.98 +    function_requires<MappableGraphComponentConcept<MappableGraphComponent> >();
    1.99  
   1.100 -template
   1.101 -void lemon::skeleton::checkCompileExtendableGraph<skeleton::ExtendableGraph>
   1.102 -(skeleton::ExtendableGraph &);
   1.103 +    function_requires<ExtendableGraphComponentConcept<ExtendableGraphComponent> >();
   1.104 +    function_requires<ErasableGraphComponentConcept<ErasableGraphComponent> >();
   1.105 +    function_requires<ClearableGraphComponentConcept<ClearableGraphComponent> >();
   1.106 +  }
   1.107 +  { // checking skeleton graphs
   1.108 +    function_requires<StaticGraphConcept<StaticGraph> >();
   1.109 +    function_requires<ExtendableGraphConcept<ExtendableGraph> >();
   1.110 +    function_requires<ErasableGraphConcept<ErasableGraph> >();
   1.111 +  }
   1.112 +  { // checking list graph
   1.113 +    function_requires<ErasableGraphConcept<ListGraph> >();
   1.114  
   1.115 -template
   1.116 -void lemon::skeleton::checkCompileErasableGraph<skeleton::ErasableGraph>
   1.117 -(skeleton::ErasableGraph &);
   1.118 +    checkGraph<ListGraph>();
   1.119 +    checkGraphNodeMap<ListGraph>();
   1.120 +    checkGraphEdgeMap<ListGraph>();
   1.121 +  }
   1.122 +  { // checking smart graph
   1.123 +    function_requires<ExtendableGraphConcept<SmartGraph> >();
   1.124  
   1.125 -//Compile SmartGraph
   1.126 -template
   1.127 -void lemon::skeleton::checkCompileExtendableGraph<SmartGraph>(SmartGraph &);
   1.128 -template
   1.129 -void lemon::skeleton::checkCompileGraphFindEdge<SmartGraph>(SmartGraph &);
   1.130 -
   1.131 -//Compile SymSmartGraph
   1.132 -//template void hugo::checkCompileGraph<SymSmartGraph>(SymSmartGraph &);
   1.133 -//template void hugo::checkCompileGraphFindEdge<SymSmartGraph>(SymSmartGraph &);
   1.134 -
   1.135 -//Compile ListGraph
   1.136 -template
   1.137 -void lemon::skeleton::checkCompileExtendableGraph<ListGraph>(ListGraph &);
   1.138 -template
   1.139 -void lemon::skeleton::checkCompileErasableGraph<ListGraph>(ListGraph &);
   1.140 -template
   1.141 -void lemon::skeleton::checkCompileGraphFindEdge<ListGraph>(ListGraph &);
   1.142 -
   1.143 -
   1.144 -//Compile SymListGraph
   1.145 -//template void hugo::checkCompileGraph<SymListGraph>(SymListGraph &);
   1.146 -//template void hugo::checkCompileErasableGraph<SymListGraph>(SymListGraph &);
   1.147 -//template void hugo::checkCompileGraphFindEdge<SymListGraph>(SymListGraph &);
   1.148 -
   1.149 -//Compile FullGraph
   1.150 -template void lemon::skeleton::checkCompileStaticGraph<FullGraph>(FullGraph &);
   1.151 -template
   1.152 -void lemon::skeleton::checkCompileGraphFindEdge<FullGraph>(FullGraph &);
   1.153 -
   1.154 -//Compile EdgeSet <ListGraph>
   1.155 -template void lemon::skeleton::checkCompileExtendableGraph<EdgeSet <ListGraph> >
   1.156 -(EdgeSet <ListGraph> &);
   1.157 -template void lemon::skeleton::checkCompileGraphEraseEdge<EdgeSet <ListGraph> >
   1.158 -(EdgeSet <ListGraph> &);
   1.159 -template void lemon::skeleton::checkCompileGraphFindEdge<EdgeSet <ListGraph> >
   1.160 -(EdgeSet <ListGraph> &);
   1.161 -
   1.162 -//Compile EdgeSet <NodeSet>
   1.163 -template void lemon::skeleton::checkCompileExtendableGraph<EdgeSet <NodeSet> >
   1.164 -(EdgeSet <NodeSet> &);
   1.165 -template void lemon::skeleton::checkCompileGraphEraseEdge<EdgeSet <NodeSet> >
   1.166 -(EdgeSet <NodeSet> &);
   1.167 -template void lemon::skeleton::checkCompileGraphFindEdge<EdgeSet <NodeSet> >
   1.168 -(EdgeSet <NodeSet> &);
   1.169 -
   1.170 -
   1.171 -int main() 
   1.172 -{
   1.173 -  {
   1.174 -    SmartGraph G;
   1.175 -    addPetersen(G);
   1.176 -    bidirPetersen(G);
   1.177 -    checkPetersen(G);
   1.178 +    checkGraph<SmartGraph>();
   1.179 +    checkGraphNodeMap<SmartGraph>();
   1.180 +    checkGraphEdgeMap<SmartGraph>();
   1.181    }
   1.182 -  {
   1.183 -    ListGraph G;
   1.184 -    addPetersen(G);
   1.185 -    bidirPetersen(G);
   1.186 -    checkPetersen(G);
   1.187 +  { // checking full graph
   1.188 +    function_requires<StaticGraphConcept<FullGraph> >();
   1.189    }
   1.190 -  {
   1.191 -    //    SymSmartGraph G;
   1.192 -    //    addPetersen(G);
   1.193 -    //    checkPetersen(G);
   1.194 -  }
   1.195 -  {
   1.196 -    //    SymListGraph G;
   1.197 -    //    addPetersen(G);
   1.198 -    //    checkPetersen(G);
   1.199 -  }
   1.200 -
   1.201 -  ///\file
   1.202 -  ///\todo map tests.
   1.203 -  ///\todo copy constr tests.
   1.204  
   1.205    std::cout << __FILE__ ": All tests passed.\n";
   1.206