2 * src/test/sym_graph_test.h - Part of HUGOlib, a generic C++ optimization library
4 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5 * (Egervary Combinatorial Optimization Research Group, EGRES).
7 * Permission to use, modify and distribute this software is granted
8 * provided that this copyright notice appears in all copies. For
9 * precise terms see the accompanying LICENSE file.
11 * This software is provided "AS IS" with no warranty of any kind,
12 * express or implied, and with no claim as to its suitability for any
16 #ifndef HUGO_TEST_SYM_GRAPH_TEST_H
17 #define HUGO_TEST_SYM_GRAPH_TEST_H
20 #include "graph_test.h"
21 #include "test_tools.h"
25 //! \brief Some utility to test symmetric graph classes.
28 template<class Graph> void checkCompileStaticSymGraph(Graph &G)
30 typedef typename Graph::Node Node;
31 typedef typename Graph::NodeIt NodeIt;
32 typedef typename Graph::SymEdge SymEdge;
33 typedef typename Graph::SymEdgeIt SymEdgeIt;
34 typedef typename Graph::Edge Edge;
35 typedef typename Graph::EdgeIt EdgeIt;
36 typedef typename Graph::InEdgeIt InEdgeIt;
37 typedef typename Graph::OutEdgeIt OutEdgeIt;
39 checkCompileStaticGraph(G);
42 SymEdge i; SymEdge j(i); SymEdge k(INVALID);
45 b=(i==INVALID); b=(i!=INVALID);
46 b=(i==j); b=(i!=j); b=(i<j);
52 SymEdgeIt i; SymEdgeIt j(i); SymEdgeIt k(INVALID); SymEdgeIt l(G);
57 b=(i==INVALID); b=(i!=INVALID);
60 b=(i==j); b=(i!=j); b=(i<j);
61 //SymEdge ->SymEdgeIt conversion
76 { SymEdge n; int i=G.id(n); i=i; }
80 typename Graph::template SymEdgeMap<int> m(G);
81 typename Graph::template SymEdgeMap<int> const &cm = m; //Const map
82 //Inicialize with default value
83 typename Graph::template SymEdgeMap<int> mdef(G,12);
84 typename Graph::template SymEdgeMap<int> mm(cm); //Copy
85 typename Graph::template SymEdgeMap<double> dm(cm); //Copy from another type
87 v=m[k]; m[k]=v; m.set(k,v);
91 dm=cm; //Copy from another type
94 typename Graph::template SymEdgeMap<int>::ValueType val;
96 typename Graph::template SymEdgeMap<int>::KeyType key;
97 key = typename Graph::SymEdgeIt(G);
102 typename Graph::template SymEdgeMap<bool> m(G);
103 typename Graph::template SymEdgeMap<bool> const &cm = m; //Const map
104 //Inicialize with default value
105 typename Graph::template SymEdgeMap<bool> mdef(G,12);
106 typename Graph::template SymEdgeMap<bool> mm(cm); //Copy
107 typename Graph::template SymEdgeMap<int> dm(cm); //Copy from another type
109 v=m[k]; m[k]=v; m.set(k,v);
113 dm=cm; //Copy from another type
114 m=dm; //Copy to another type
116 //Check the typedef's
117 typename Graph::template SymEdgeMap<bool>::ValueType val;
119 typename Graph::template SymEdgeMap<bool>::KeyType key;
120 key= typename Graph::SymEdgeIt(G);
125 template<class Graph> void checkCompileSymGraph(Graph &G)
127 checkCompileStaticSymGraph(G);
129 typedef typename Graph::Node Node;
130 typedef typename Graph::NodeIt NodeIt;
131 typedef typename Graph::SymEdge SymEdge;
132 typedef typename Graph::SymEdgeIt SymEdgeIt;
133 typedef typename Graph::Edge Edge;
134 typedef typename Graph::EdgeIt EdgeIt;
135 typedef typename Graph::InEdgeIt InEdgeIt;
136 typedef typename Graph::OutEdgeIt OutEdgeIt;
147 template<class Graph> void checkCompileSymGraphEraseSymEdge(Graph &G)
149 typename Graph::SymEdge n;
153 template<class Graph> void checkCompileErasableSymGraph(Graph &G)
155 checkCompileSymGraph(G);
156 checkCompileGraphEraseNode(G);
157 checkCompileSymGraphEraseSymEdge(G);
160 template<class Graph> void checkGraphSymEdgeList(Graph &G, int nn)
162 typedef typename Graph::SymEdgeIt SymEdgeIt;
165 for(int i=0;i<nn;i++) {
166 check(e!=INVALID,"Wrong SymEdge list linking.");
169 check(e==INVALID,"Wrong SymEdge list linking.");
173 ///\todo Check head(), tail() as well;