1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/test/graph_factory_test.cc Wed Oct 27 22:38:50 2004 +0000
1.3 @@ -0,0 +1,154 @@
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 +
1.20 +#include<iostream>
1.21 +#include<lemon/smart_graph.h>
1.22 +#include<lemon/skeletons/graph.h>
1.23 +#include<lemon/skeletons/maps.h>
1.24 +#include<lemon/list_graph_base.h>
1.25 +#include<lemon/full_graph.h>
1.26 +
1.27 +#include"test_tools.h"
1.28 +#include"graph_test.h"
1.29 +
1.30 +/**
1.31 +\file
1.32 +This test makes consistency checks of list graph structures.
1.33 +
1.34 +G.addNode(), G.addEdge(), G.tail(), G.head()
1.35 +
1.36 +\todo Checks for empty graphs and isolated points.
1.37 +conversion.
1.38 +*/
1.39 +
1.40 +using namespace lemon;
1.41 +
1.42 +template<class Graph> void bidirPetersen(Graph &G)
1.43 +{
1.44 + typedef typename Graph::Edge Edge;
1.45 + typedef typename Graph::EdgeIt EdgeIt;
1.46 +
1.47 + checkGraphEdgeList(G,15);
1.48 +
1.49 + std::vector<Edge> ee;
1.50 +
1.51 + for(EdgeIt e(G);e!=INVALID;++e) ee.push_back(e);
1.52 +
1.53 + for(typename std::vector<Edge>::iterator p=ee.begin();p!=ee.end();p++)
1.54 + G.addEdge(G.head(*p),G.tail(*p));
1.55 +}
1.56 +
1.57 +template<class Graph> void checkPetersen(Graph &G)
1.58 +{
1.59 + typedef typename Graph::Node Node;
1.60 +
1.61 + typedef typename Graph::EdgeIt EdgeIt;
1.62 + typedef typename Graph::NodeIt NodeIt;
1.63 +
1.64 + checkGraphNodeList(G,10);
1.65 + checkGraphEdgeList(G,30);
1.66 +
1.67 + for(NodeIt n(G);n!=INVALID;++n) {
1.68 + checkGraphInEdgeList(G,n,3);
1.69 + checkGraphOutEdgeList(G,n,3);
1.70 + }
1.71 +}
1.72 +
1.73 +//Compile Graph
1.74 +template void lemon::skeleton::checkCompileStaticGraph<skeleton::StaticGraph>
1.75 +(skeleton::StaticGraph &);
1.76 +
1.77 +template
1.78 +void lemon::skeleton::checkCompileExtendableGraph<skeleton::ExtendableGraph>
1.79 +(skeleton::ExtendableGraph &);
1.80 +
1.81 +template
1.82 +void lemon::skeleton::checkCompileErasableGraph<skeleton::ErasableGraph>
1.83 +(skeleton::ErasableGraph &);
1.84 +
1.85 +//Compile SmartGraph
1.86 +template
1.87 +void lemon::skeleton::checkCompileExtendableGraph<SmartGraph>(SmartGraph &);
1.88 +template
1.89 +void lemon::skeleton::checkCompileGraphFindEdge<SmartGraph>(SmartGraph &);
1.90 +
1.91 +//Compile SymSmartGraph
1.92 +//template void hugo::checkCompileGraph<SymSmartGraph>(SymSmartGraph &);
1.93 +//template void hugo::checkCompileGraphFindEdge<SymSmartGraph>(SymSmartGraph &);
1.94 +
1.95 +//Compile ListGraph
1.96 +template
1.97 +void lemon::skeleton::checkCompileExtendableGraph<ListGraph>(ListGraph &);
1.98 +template
1.99 +void lemon::skeleton::checkCompileErasableGraph<ListGraph>(ListGraph &);
1.100 +template
1.101 +void lemon::skeleton::checkCompileGraphFindEdge<ListGraph>(ListGraph &);
1.102 +
1.103 +
1.104 +//Compile SymListGraph
1.105 +//template void hugo::checkCompileGraph<SymListGraph>(SymListGraph &);
1.106 +//template void hugo::checkCompileErasableGraph<SymListGraph>(SymListGraph &);
1.107 +//template void hugo::checkCompileGraphFindEdge<SymListGraph>(SymListGraph &);
1.108 +
1.109 +//Compile FullGraph
1.110 +template void lemon::skeleton::checkCompileStaticGraph<FullGraph>(FullGraph &);
1.111 +template
1.112 +void lemon::skeleton::checkCompileGraphFindEdge<FullGraph>(FullGraph &);
1.113 +
1.114 +
1.115 +int main()
1.116 +{
1.117 + {
1.118 + SmartGraph G;
1.119 + addPetersen(G);
1.120 + bidirPetersen(G);
1.121 + checkPetersen(G);
1.122 + }
1.123 + {
1.124 + ListGraph G;
1.125 + addPetersen(G);
1.126 + bidirPetersen(G);
1.127 + checkPetersen(G);
1.128 + }
1.129 + {
1.130 + // SymSmartGraph G;
1.131 + // addPetersen(G);
1.132 + // checkPetersen(G);
1.133 + }
1.134 + {
1.135 + // SymListGraph G;
1.136 + // addPetersen(G);
1.137 + // checkPetersen(G);
1.138 + }
1.139 +
1.140 + ///\file
1.141 + ///\todo map tests.
1.142 + ///\todo copy constr tests.
1.143 +
1.144 +
1.145 + // Some map tests.
1.146 + // FIXME: These shouldn't be here.
1.147 + using namespace skeleton;
1.148 + function_requires< ReadMapConcept< ReadMap<int,int> > >();
1.149 + function_requires< WriteMapConcept< WriteMap<int,int> > >();
1.150 + function_requires< ReadWriteMapConcept< ReadWriteMap<int,int> > >();
1.151 + function_requires< ReferenceMapConcept< ReferenceMap<int,int> > >();
1.152 +
1.153 +
1.154 + std::cout << __FILE__ ": All tests passed.\n";
1.155 +
1.156 + return 0;
1.157 +}