alpar@209
|
1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*-
|
kpeter@171
|
2 |
*
|
alpar@209
|
3 |
* This file is a part of LEMON, a generic C++ optimization library.
|
kpeter@171
|
4 |
*
|
alpar@440
|
5 |
* Copyright (C) 2003-2009
|
kpeter@171
|
6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
|
kpeter@171
|
7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES).
|
kpeter@171
|
8 |
*
|
kpeter@171
|
9 |
* Permission to use, modify and distribute this software is granted
|
kpeter@171
|
10 |
* provided that this copyright notice appears in all copies. For
|
kpeter@171
|
11 |
* precise terms see the accompanying LICENSE file.
|
kpeter@171
|
12 |
*
|
kpeter@171
|
13 |
* This software is provided "AS IS" with no warranty of any kind,
|
kpeter@171
|
14 |
* express or implied, and with no claim as to its suitability for any
|
kpeter@171
|
15 |
* purpose.
|
kpeter@171
|
16 |
*
|
kpeter@171
|
17 |
*/
|
kpeter@171
|
18 |
|
kpeter@171
|
19 |
#ifndef LEMON_TEST_GRAPH_TEST_H
|
kpeter@171
|
20 |
#define LEMON_TEST_GRAPH_TEST_H
|
kpeter@171
|
21 |
|
deba@228
|
22 |
#include <set>
|
deba@228
|
23 |
|
deba@220
|
24 |
#include <lemon/core.h>
|
deba@228
|
25 |
#include <lemon/maps.h>
|
deba@228
|
26 |
|
kpeter@171
|
27 |
#include "test_tools.h"
|
kpeter@171
|
28 |
|
kpeter@171
|
29 |
namespace lemon {
|
kpeter@171
|
30 |
|
kpeter@171
|
31 |
template<class Graph>
|
kpeter@171
|
32 |
void checkGraphNodeList(const Graph &G, int cnt)
|
kpeter@171
|
33 |
{
|
kpeter@171
|
34 |
typename Graph::NodeIt n(G);
|
kpeter@171
|
35 |
for(int i=0;i<cnt;i++) {
|
kpeter@171
|
36 |
check(n!=INVALID,"Wrong Node list linking.");
|
kpeter@171
|
37 |
++n;
|
kpeter@171
|
38 |
}
|
kpeter@171
|
39 |
check(n==INVALID,"Wrong Node list linking.");
|
kpeter@171
|
40 |
check(countNodes(G)==cnt,"Wrong Node number.");
|
kpeter@171
|
41 |
}
|
kpeter@171
|
42 |
|
kpeter@171
|
43 |
template<class Graph>
|
deba@1019
|
44 |
void checkGraphRedNodeList(const Graph &G, int cnt)
|
deba@1019
|
45 |
{
|
deba@1019
|
46 |
typename Graph::RedIt n(G);
|
deba@1019
|
47 |
for(int i=0;i<cnt;i++) {
|
deba@1019
|
48 |
check(n!=INVALID,"Wrong red Node list linking.");
|
deba@1025
|
49 |
check(G.red(n),"Wrong node set check.");
|
deba@1025
|
50 |
check(!G.blue(n),"Wrong node set check.");
|
deba@1025
|
51 |
typename Graph::Node nn = n;
|
deba@1025
|
52 |
check(G.asRedNodeUnsafe(nn) == n,"Wrong node conversion.");
|
deba@1025
|
53 |
check(G.asRedNode(nn) == n,"Wrong node conversion.");
|
deba@1025
|
54 |
check(G.asBlueNode(nn) == INVALID,"Wrong node conversion.");
|
deba@1025
|
55 |
std::pair<typename Graph::RedNode, typename Graph::BlueNode> rbn =
|
deba@1025
|
56 |
G.asRedBlueNode(nn);
|
deba@1025
|
57 |
check(rbn.first == n,"Wrong node conversion.");
|
deba@1025
|
58 |
check(rbn.second == INVALID,"Wrong node conversion.");
|
deba@1019
|
59 |
++n;
|
deba@1019
|
60 |
}
|
deba@1019
|
61 |
check(n==INVALID,"Wrong red Node list linking.");
|
deba@1019
|
62 |
check(countRedNodes(G)==cnt,"Wrong red Node number.");
|
deba@1019
|
63 |
}
|
deba@1019
|
64 |
|
deba@1019
|
65 |
template<class Graph>
|
deba@1019
|
66 |
void checkGraphBlueNodeList(const Graph &G, int cnt)
|
deba@1019
|
67 |
{
|
deba@1019
|
68 |
typename Graph::BlueIt n(G);
|
deba@1019
|
69 |
for(int i=0;i<cnt;i++) {
|
deba@1019
|
70 |
check(n!=INVALID,"Wrong blue Node list linking.");
|
deba@1025
|
71 |
check(G.blue(n),"Wrong node set check.");
|
deba@1025
|
72 |
check(!G.red(n),"Wrong node set check.");
|
deba@1025
|
73 |
typename Graph::Node nn = n;
|
deba@1025
|
74 |
check(G.asBlueNodeUnsafe(nn) == n,"Wrong node conversion.");
|
deba@1025
|
75 |
check(G.asBlueNode(nn) == n,"Wrong node conversion.");
|
deba@1025
|
76 |
check(G.asRedNode(nn) == INVALID,"Wrong node conversion.");
|
deba@1025
|
77 |
std::pair<typename Graph::RedNode, typename Graph::BlueNode> rbn =
|
deba@1025
|
78 |
G.asRedBlueNode(nn);
|
deba@1025
|
79 |
check(rbn.first == INVALID,"Wrong node conversion.");
|
deba@1025
|
80 |
check(rbn.second == n,"Wrong node conversion.");
|
deba@1019
|
81 |
++n;
|
deba@1019
|
82 |
}
|
deba@1019
|
83 |
check(n==INVALID,"Wrong blue Node list linking.");
|
deba@1019
|
84 |
check(countBlueNodes(G)==cnt,"Wrong blue Node number.");
|
deba@1019
|
85 |
}
|
deba@1019
|
86 |
|
deba@1019
|
87 |
template<class Graph>
|
kpeter@171
|
88 |
void checkGraphArcList(const Graph &G, int cnt)
|
kpeter@171
|
89 |
{
|
kpeter@171
|
90 |
typename Graph::ArcIt e(G);
|
kpeter@171
|
91 |
for(int i=0;i<cnt;i++) {
|
kpeter@171
|
92 |
check(e!=INVALID,"Wrong Arc list linking.");
|
deba@228
|
93 |
check(G.oppositeNode(G.source(e), e) == G.target(e),
|
deba@228
|
94 |
"Wrong opposite node");
|
deba@228
|
95 |
check(G.oppositeNode(G.target(e), e) == G.source(e),
|
deba@228
|
96 |
"Wrong opposite node");
|
kpeter@171
|
97 |
++e;
|
kpeter@171
|
98 |
}
|
kpeter@171
|
99 |
check(e==INVALID,"Wrong Arc list linking.");
|
kpeter@171
|
100 |
check(countArcs(G)==cnt,"Wrong Arc number.");
|
kpeter@171
|
101 |
}
|
kpeter@171
|
102 |
|
kpeter@171
|
103 |
template<class Graph>
|
kpeter@171
|
104 |
void checkGraphOutArcList(const Graph &G, typename Graph::Node n, int cnt)
|
kpeter@171
|
105 |
{
|
kpeter@171
|
106 |
typename Graph::OutArcIt e(G,n);
|
kpeter@171
|
107 |
for(int i=0;i<cnt;i++) {
|
kpeter@171
|
108 |
check(e!=INVALID,"Wrong OutArc list linking.");
|
kpeter@171
|
109 |
check(n==G.source(e),"Wrong OutArc list linking.");
|
deba@228
|
110 |
check(n==G.baseNode(e),"Wrong OutArc list linking.");
|
deba@228
|
111 |
check(G.target(e)==G.runningNode(e),"Wrong OutArc list linking.");
|
kpeter@171
|
112 |
++e;
|
kpeter@171
|
113 |
}
|
kpeter@171
|
114 |
check(e==INVALID,"Wrong OutArc list linking.");
|
kpeter@171
|
115 |
check(countOutArcs(G,n)==cnt,"Wrong OutArc number.");
|
kpeter@171
|
116 |
}
|
kpeter@171
|
117 |
|
kpeter@171
|
118 |
template<class Graph>
|
kpeter@171
|
119 |
void checkGraphInArcList(const Graph &G, typename Graph::Node n, int cnt)
|
kpeter@171
|
120 |
{
|
kpeter@171
|
121 |
typename Graph::InArcIt e(G,n);
|
kpeter@171
|
122 |
for(int i=0;i<cnt;i++) {
|
kpeter@171
|
123 |
check(e!=INVALID,"Wrong InArc list linking.");
|
kpeter@171
|
124 |
check(n==G.target(e),"Wrong InArc list linking.");
|
deba@228
|
125 |
check(n==G.baseNode(e),"Wrong OutArc list linking.");
|
deba@228
|
126 |
check(G.source(e)==G.runningNode(e),"Wrong OutArc list linking.");
|
kpeter@171
|
127 |
++e;
|
kpeter@171
|
128 |
}
|
kpeter@171
|
129 |
check(e==INVALID,"Wrong InArc list linking.");
|
kpeter@171
|
130 |
check(countInArcs(G,n)==cnt,"Wrong InArc number.");
|
kpeter@171
|
131 |
}
|
kpeter@171
|
132 |
|
kpeter@171
|
133 |
template<class Graph>
|
kpeter@171
|
134 |
void checkGraphEdgeList(const Graph &G, int cnt)
|
kpeter@171
|
135 |
{
|
kpeter@171
|
136 |
typename Graph::EdgeIt e(G);
|
kpeter@171
|
137 |
for(int i=0;i<cnt;i++) {
|
kpeter@171
|
138 |
check(e!=INVALID,"Wrong Edge list linking.");
|
deba@228
|
139 |
check(G.oppositeNode(G.u(e), e) == G.v(e), "Wrong opposite node");
|
deba@228
|
140 |
check(G.oppositeNode(G.v(e), e) == G.u(e), "Wrong opposite node");
|
kpeter@171
|
141 |
++e;
|
kpeter@171
|
142 |
}
|
kpeter@171
|
143 |
check(e==INVALID,"Wrong Edge list linking.");
|
kpeter@171
|
144 |
check(countEdges(G)==cnt,"Wrong Edge number.");
|
kpeter@171
|
145 |
}
|
kpeter@171
|
146 |
|
kpeter@171
|
147 |
template<class Graph>
|
kpeter@171
|
148 |
void checkGraphIncEdgeList(const Graph &G, typename Graph::Node n, int cnt)
|
kpeter@171
|
149 |
{
|
kpeter@171
|
150 |
typename Graph::IncEdgeIt e(G,n);
|
kpeter@171
|
151 |
for(int i=0;i<cnt;i++) {
|
kpeter@171
|
152 |
check(e!=INVALID,"Wrong IncEdge list linking.");
|
kpeter@171
|
153 |
check(n==G.u(e) || n==G.v(e),"Wrong IncEdge list linking.");
|
deba@228
|
154 |
check(n==G.baseNode(e),"Wrong OutArc list linking.");
|
deba@228
|
155 |
check(G.u(e)==G.runningNode(e) || G.v(e)==G.runningNode(e),
|
deba@228
|
156 |
"Wrong OutArc list linking.");
|
kpeter@171
|
157 |
++e;
|
kpeter@171
|
158 |
}
|
kpeter@171
|
159 |
check(e==INVALID,"Wrong IncEdge list linking.");
|
kpeter@171
|
160 |
check(countIncEdges(G,n)==cnt,"Wrong IncEdge number.");
|
kpeter@171
|
161 |
}
|
kpeter@171
|
162 |
|
deba@228
|
163 |
template <class Graph>
|
kpeter@374
|
164 |
void checkGraphIncEdgeArcLists(const Graph &G, typename Graph::Node n,
|
kpeter@374
|
165 |
int cnt)
|
kpeter@374
|
166 |
{
|
kpeter@374
|
167 |
checkGraphIncEdgeList(G, n, cnt);
|
kpeter@374
|
168 |
checkGraphOutArcList(G, n, cnt);
|
kpeter@374
|
169 |
checkGraphInArcList(G, n, cnt);
|
kpeter@374
|
170 |
}
|
kpeter@374
|
171 |
|
kpeter@374
|
172 |
template <class Graph>
|
deba@228
|
173 |
void checkGraphConArcList(const Graph &G, int cnt) {
|
deba@228
|
174 |
int i = 0;
|
deba@228
|
175 |
for (typename Graph::NodeIt u(G); u != INVALID; ++u) {
|
deba@228
|
176 |
for (typename Graph::NodeIt v(G); v != INVALID; ++v) {
|
deba@228
|
177 |
for (ConArcIt<Graph> a(G, u, v); a != INVALID; ++a) {
|
deba@228
|
178 |
check(G.source(a) == u, "Wrong iterator.");
|
deba@228
|
179 |
check(G.target(a) == v, "Wrong iterator.");
|
deba@228
|
180 |
++i;
|
deba@228
|
181 |
}
|
deba@228
|
182 |
}
|
deba@228
|
183 |
}
|
deba@228
|
184 |
check(cnt == i, "Wrong iterator.");
|
kpeter@171
|
185 |
}
|
kpeter@171
|
186 |
|
kpeter@171
|
187 |
template <class Graph>
|
deba@228
|
188 |
void checkGraphConEdgeList(const Graph &G, int cnt) {
|
deba@228
|
189 |
int i = 0;
|
deba@228
|
190 |
for (typename Graph::NodeIt u(G); u != INVALID; ++u) {
|
deba@228
|
191 |
for (typename Graph::NodeIt v(G); v != INVALID; ++v) {
|
deba@228
|
192 |
for (ConEdgeIt<Graph> e(G, u, v); e != INVALID; ++e) {
|
deba@228
|
193 |
check((G.u(e) == u && G.v(e) == v) ||
|
deba@228
|
194 |
(G.u(e) == v && G.v(e) == u), "Wrong iterator.");
|
deba@228
|
195 |
i += u == v ? 2 : 1;
|
deba@228
|
196 |
}
|
deba@228
|
197 |
}
|
deba@228
|
198 |
}
|
deba@228
|
199 |
check(2 * cnt == i, "Wrong iterator.");
|
kpeter@171
|
200 |
}
|
kpeter@171
|
201 |
|
deba@228
|
202 |
template <typename Graph>
|
deba@228
|
203 |
void checkArcDirections(const Graph& G) {
|
deba@228
|
204 |
for (typename Graph::ArcIt a(G); a != INVALID; ++a) {
|
deba@228
|
205 |
check(G.source(a) == G.target(G.oppositeArc(a)), "Wrong direction");
|
deba@228
|
206 |
check(G.target(a) == G.source(G.oppositeArc(a)), "Wrong direction");
|
deba@228
|
207 |
check(G.direct(a, G.direction(a)) == a, "Wrong direction");
|
kpeter@171
|
208 |
}
|
kpeter@171
|
209 |
}
|
kpeter@171
|
210 |
|
deba@228
|
211 |
template <typename Graph>
|
deba@228
|
212 |
void checkNodeIds(const Graph& G) {
|
deba@1019
|
213 |
typedef typename Graph::Node Node;
|
deba@228
|
214 |
std::set<int> values;
|
deba@228
|
215 |
for (typename Graph::NodeIt n(G); n != INVALID; ++n) {
|
deba@228
|
216 |
check(G.nodeFromId(G.id(n)) == n, "Wrong id");
|
deba@228
|
217 |
check(values.find(G.id(n)) == values.end(), "Wrong id");
|
deba@228
|
218 |
check(G.id(n) <= G.maxNodeId(), "Wrong maximum id");
|
deba@228
|
219 |
values.insert(G.id(n));
|
kpeter@171
|
220 |
}
|
deba@1019
|
221 |
check(G.maxId(Node()) <= G.maxNodeId(), "Wrong maximum id");
|
deba@1019
|
222 |
}
|
deba@1019
|
223 |
|
deba@1019
|
224 |
template <typename Graph>
|
deba@1019
|
225 |
void checkRedNodeIds(const Graph& G) {
|
deba@1019
|
226 |
typedef typename Graph::RedNode RedNode;
|
deba@1019
|
227 |
std::set<int> values;
|
deba@1019
|
228 |
for (typename Graph::RedIt n(G); n != INVALID; ++n) {
|
deba@1019
|
229 |
check(G.red(n), "Wrong partition");
|
deba@1025
|
230 |
check(values.find(G.id(n)) == values.end(), "Wrong id");
|
deba@1025
|
231 |
check(G.id(n) <= G.maxRedId(), "Wrong maximum id");
|
deba@1019
|
232 |
values.insert(G.id(n));
|
deba@1019
|
233 |
}
|
deba@1019
|
234 |
check(G.maxId(RedNode()) == G.maxRedId(), "Wrong maximum id");
|
deba@1019
|
235 |
}
|
deba@1019
|
236 |
|
deba@1019
|
237 |
template <typename Graph>
|
deba@1019
|
238 |
void checkBlueNodeIds(const Graph& G) {
|
deba@1019
|
239 |
typedef typename Graph::BlueNode BlueNode;
|
deba@1019
|
240 |
std::set<int> values;
|
deba@1019
|
241 |
for (typename Graph::BlueIt n(G); n != INVALID; ++n) {
|
deba@1019
|
242 |
check(G.blue(n), "Wrong partition");
|
deba@1025
|
243 |
check(values.find(G.id(n)) == values.end(), "Wrong id");
|
deba@1025
|
244 |
check(G.id(n) <= G.maxBlueId(), "Wrong maximum id");
|
deba@1019
|
245 |
values.insert(G.id(n));
|
deba@1019
|
246 |
}
|
deba@1019
|
247 |
check(G.maxId(BlueNode()) == G.maxBlueId(), "Wrong maximum id");
|
kpeter@171
|
248 |
}
|
kpeter@171
|
249 |
|
deba@228
|
250 |
template <typename Graph>
|
deba@228
|
251 |
void checkArcIds(const Graph& G) {
|
deba@1019
|
252 |
typedef typename Graph::Arc Arc;
|
deba@228
|
253 |
std::set<int> values;
|
deba@228
|
254 |
for (typename Graph::ArcIt a(G); a != INVALID; ++a) {
|
deba@228
|
255 |
check(G.arcFromId(G.id(a)) == a, "Wrong id");
|
deba@228
|
256 |
check(values.find(G.id(a)) == values.end(), "Wrong id");
|
deba@228
|
257 |
check(G.id(a) <= G.maxArcId(), "Wrong maximum id");
|
deba@228
|
258 |
values.insert(G.id(a));
|
deba@228
|
259 |
}
|
deba@1019
|
260 |
check(G.maxId(Arc()) <= G.maxArcId(), "Wrong maximum id");
|
kpeter@171
|
261 |
}
|
alpar@209
|
262 |
|
deba@228
|
263 |
template <typename Graph>
|
deba@228
|
264 |
void checkEdgeIds(const Graph& G) {
|
deba@1019
|
265 |
typedef typename Graph::Edge Edge;
|
deba@228
|
266 |
std::set<int> values;
|
deba@228
|
267 |
for (typename Graph::EdgeIt e(G); e != INVALID; ++e) {
|
deba@228
|
268 |
check(G.edgeFromId(G.id(e)) == e, "Wrong id");
|
deba@228
|
269 |
check(values.find(G.id(e)) == values.end(), "Wrong id");
|
deba@228
|
270 |
check(G.id(e) <= G.maxEdgeId(), "Wrong maximum id");
|
deba@228
|
271 |
values.insert(G.id(e));
|
deba@228
|
272 |
}
|
deba@1019
|
273 |
check(G.maxId(Edge()) <= G.maxEdgeId(), "Wrong maximum id");
|
kpeter@171
|
274 |
}
|
kpeter@171
|
275 |
|
deba@228
|
276 |
template <typename Graph>
|
deba@228
|
277 |
void checkGraphNodeMap(const Graph& G) {
|
deba@228
|
278 |
typedef typename Graph::Node Node;
|
deba@228
|
279 |
typedef typename Graph::NodeIt NodeIt;
|
deba@228
|
280 |
|
deba@228
|
281 |
typedef typename Graph::template NodeMap<int> IntNodeMap;
|
deba@228
|
282 |
IntNodeMap map(G, 42);
|
deba@228
|
283 |
for (NodeIt it(G); it != INVALID; ++it) {
|
deba@228
|
284 |
check(map[it] == 42, "Wrong map constructor.");
|
deba@228
|
285 |
}
|
deba@228
|
286 |
int s = 0;
|
deba@228
|
287 |
for (NodeIt it(G); it != INVALID; ++it) {
|
deba@228
|
288 |
map[it] = 0;
|
deba@228
|
289 |
check(map[it] == 0, "Wrong operator[].");
|
deba@228
|
290 |
map.set(it, s);
|
deba@228
|
291 |
check(map[it] == s, "Wrong set.");
|
deba@228
|
292 |
++s;
|
deba@228
|
293 |
}
|
deba@228
|
294 |
s = s * (s - 1) / 2;
|
deba@228
|
295 |
for (NodeIt it(G); it != INVALID; ++it) {
|
deba@228
|
296 |
s -= map[it];
|
deba@228
|
297 |
}
|
deba@228
|
298 |
check(s == 0, "Wrong sum.");
|
deba@228
|
299 |
|
kpeter@263
|
300 |
// map = constMap<Node>(12);
|
kpeter@263
|
301 |
// for (NodeIt it(G); it != INVALID; ++it) {
|
kpeter@263
|
302 |
// check(map[it] == 12, "Wrong operator[].");
|
kpeter@263
|
303 |
// }
|
deba@228
|
304 |
}
|
deba@228
|
305 |
|
deba@228
|
306 |
template <typename Graph>
|
deba@1019
|
307 |
void checkGraphRedMap(const Graph& G) {
|
deba@1019
|
308 |
typedef typename Graph::Node Node;
|
deba@1019
|
309 |
typedef typename Graph::RedIt RedIt;
|
deba@1019
|
310 |
|
deba@1019
|
311 |
typedef typename Graph::template RedMap<int> IntRedMap;
|
deba@1019
|
312 |
IntRedMap map(G, 42);
|
deba@1019
|
313 |
for (RedIt it(G); it != INVALID; ++it) {
|
deba@1019
|
314 |
check(map[it] == 42, "Wrong map constructor.");
|
deba@1019
|
315 |
}
|
deba@1019
|
316 |
int s = 0;
|
deba@1019
|
317 |
for (RedIt it(G); it != INVALID; ++it) {
|
deba@1019
|
318 |
map[it] = 0;
|
deba@1019
|
319 |
check(map[it] == 0, "Wrong operator[].");
|
deba@1019
|
320 |
map.set(it, s);
|
deba@1019
|
321 |
check(map[it] == s, "Wrong set.");
|
deba@1019
|
322 |
++s;
|
deba@1019
|
323 |
}
|
deba@1019
|
324 |
s = s * (s - 1) / 2;
|
deba@1019
|
325 |
for (RedIt it(G); it != INVALID; ++it) {
|
deba@1019
|
326 |
s -= map[it];
|
deba@1019
|
327 |
}
|
deba@1019
|
328 |
check(s == 0, "Wrong sum.");
|
deba@1019
|
329 |
|
deba@1019
|
330 |
// map = constMap<Node>(12);
|
deba@1019
|
331 |
// for (NodeIt it(G); it != INVALID; ++it) {
|
deba@1019
|
332 |
// check(map[it] == 12, "Wrong operator[].");
|
deba@1019
|
333 |
// }
|
deba@1019
|
334 |
}
|
deba@1019
|
335 |
|
deba@1019
|
336 |
template <typename Graph>
|
deba@1019
|
337 |
void checkGraphBlueMap(const Graph& G) {
|
deba@1019
|
338 |
typedef typename Graph::Node Node;
|
deba@1019
|
339 |
typedef typename Graph::BlueIt BlueIt;
|
deba@1019
|
340 |
|
deba@1019
|
341 |
typedef typename Graph::template BlueMap<int> IntBlueMap;
|
deba@1019
|
342 |
IntBlueMap map(G, 42);
|
deba@1019
|
343 |
for (BlueIt it(G); it != INVALID; ++it) {
|
deba@1019
|
344 |
check(map[it] == 42, "Wrong map constructor.");
|
deba@1019
|
345 |
}
|
deba@1019
|
346 |
int s = 0;
|
deba@1019
|
347 |
for (BlueIt it(G); it != INVALID; ++it) {
|
deba@1019
|
348 |
map[it] = 0;
|
deba@1019
|
349 |
check(map[it] == 0, "Wrong operator[].");
|
deba@1019
|
350 |
map.set(it, s);
|
deba@1019
|
351 |
check(map[it] == s, "Wrong set.");
|
deba@1019
|
352 |
++s;
|
deba@1019
|
353 |
}
|
deba@1019
|
354 |
s = s * (s - 1) / 2;
|
deba@1019
|
355 |
for (BlueIt it(G); it != INVALID; ++it) {
|
deba@1019
|
356 |
s -= map[it];
|
deba@1019
|
357 |
}
|
deba@1019
|
358 |
check(s == 0, "Wrong sum.");
|
deba@1019
|
359 |
|
deba@1019
|
360 |
// map = constMap<Node>(12);
|
deba@1019
|
361 |
// for (NodeIt it(G); it != INVALID; ++it) {
|
deba@1019
|
362 |
// check(map[it] == 12, "Wrong operator[].");
|
deba@1019
|
363 |
// }
|
deba@1019
|
364 |
}
|
deba@1019
|
365 |
|
deba@1019
|
366 |
template <typename Graph>
|
deba@228
|
367 |
void checkGraphArcMap(const Graph& G) {
|
deba@228
|
368 |
typedef typename Graph::Arc Arc;
|
deba@228
|
369 |
typedef typename Graph::ArcIt ArcIt;
|
deba@228
|
370 |
|
deba@228
|
371 |
typedef typename Graph::template ArcMap<int> IntArcMap;
|
deba@228
|
372 |
IntArcMap map(G, 42);
|
deba@228
|
373 |
for (ArcIt it(G); it != INVALID; ++it) {
|
deba@228
|
374 |
check(map[it] == 42, "Wrong map constructor.");
|
deba@228
|
375 |
}
|
deba@228
|
376 |
int s = 0;
|
deba@228
|
377 |
for (ArcIt it(G); it != INVALID; ++it) {
|
deba@228
|
378 |
map[it] = 0;
|
deba@228
|
379 |
check(map[it] == 0, "Wrong operator[].");
|
deba@228
|
380 |
map.set(it, s);
|
deba@228
|
381 |
check(map[it] == s, "Wrong set.");
|
deba@228
|
382 |
++s;
|
deba@228
|
383 |
}
|
deba@228
|
384 |
s = s * (s - 1) / 2;
|
deba@228
|
385 |
for (ArcIt it(G); it != INVALID; ++it) {
|
deba@228
|
386 |
s -= map[it];
|
deba@228
|
387 |
}
|
deba@228
|
388 |
check(s == 0, "Wrong sum.");
|
deba@228
|
389 |
|
kpeter@263
|
390 |
// map = constMap<Arc>(12);
|
kpeter@263
|
391 |
// for (ArcIt it(G); it != INVALID; ++it) {
|
kpeter@263
|
392 |
// check(map[it] == 12, "Wrong operator[].");
|
kpeter@263
|
393 |
// }
|
deba@228
|
394 |
}
|
deba@228
|
395 |
|
deba@228
|
396 |
template <typename Graph>
|
deba@228
|
397 |
void checkGraphEdgeMap(const Graph& G) {
|
deba@228
|
398 |
typedef typename Graph::Edge Edge;
|
deba@228
|
399 |
typedef typename Graph::EdgeIt EdgeIt;
|
deba@228
|
400 |
|
deba@228
|
401 |
typedef typename Graph::template EdgeMap<int> IntEdgeMap;
|
deba@228
|
402 |
IntEdgeMap map(G, 42);
|
deba@228
|
403 |
for (EdgeIt it(G); it != INVALID; ++it) {
|
deba@228
|
404 |
check(map[it] == 42, "Wrong map constructor.");
|
deba@228
|
405 |
}
|
deba@228
|
406 |
int s = 0;
|
deba@228
|
407 |
for (EdgeIt it(G); it != INVALID; ++it) {
|
deba@228
|
408 |
map[it] = 0;
|
deba@228
|
409 |
check(map[it] == 0, "Wrong operator[].");
|
deba@228
|
410 |
map.set(it, s);
|
deba@228
|
411 |
check(map[it] == s, "Wrong set.");
|
deba@228
|
412 |
++s;
|
deba@228
|
413 |
}
|
deba@228
|
414 |
s = s * (s - 1) / 2;
|
deba@228
|
415 |
for (EdgeIt it(G); it != INVALID; ++it) {
|
deba@228
|
416 |
s -= map[it];
|
deba@228
|
417 |
}
|
deba@228
|
418 |
check(s == 0, "Wrong sum.");
|
deba@228
|
419 |
|
kpeter@263
|
420 |
// map = constMap<Edge>(12);
|
kpeter@263
|
421 |
// for (EdgeIt it(G); it != INVALID; ++it) {
|
kpeter@263
|
422 |
// check(map[it] == 12, "Wrong operator[].");
|
kpeter@263
|
423 |
// }
|
deba@228
|
424 |
}
|
deba@228
|
425 |
|
deba@228
|
426 |
|
kpeter@171
|
427 |
} //namespace lemon
|
kpeter@171
|
428 |
|
kpeter@171
|
429 |
#endif
|