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@1270
|
5 |
* Copyright (C) 2003-2013
|
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.");
|
alpar@1337
|
41 |
|
alpar@1337
|
42 |
#ifdef LEMON_CXX11
|
alpar@1337
|
43 |
{
|
alpar@1337
|
44 |
typename Graph::NodeIt n(G);
|
alpar@1337
|
45 |
for(auto u: G.nodes())
|
alpar@1337
|
46 |
{
|
alpar@1337
|
47 |
check(n==u,"Wrong STL Node iterator.");
|
alpar@1337
|
48 |
++n;
|
alpar@1337
|
49 |
}
|
alpar@1337
|
50 |
check(n==INVALID,"Wrong STL Node iterator.");
|
alpar@1337
|
51 |
}
|
alpar@1337
|
52 |
{
|
alpar@1337
|
53 |
typename Graph::NodeIt n(G);
|
alpar@1337
|
54 |
for(typename Graph::Node u: G.nodes())
|
alpar@1337
|
55 |
{
|
alpar@1337
|
56 |
check(n==u,"Wrong STL Node iterator.");
|
alpar@1337
|
57 |
++n;
|
alpar@1337
|
58 |
}
|
alpar@1337
|
59 |
check(n==INVALID,"Wrong STL Node iterator.");
|
alpar@1337
|
60 |
}
|
alpar@1337
|
61 |
#endif
|
kpeter@171
|
62 |
}
|
kpeter@171
|
63 |
|
kpeter@171
|
64 |
template<class Graph>
|
deba@1187
|
65 |
void checkGraphRedNodeList(const Graph &G, int cnt)
|
deba@1187
|
66 |
{
|
deba@1194
|
67 |
typename Graph::RedNodeIt n(G);
|
deba@1187
|
68 |
for(int i=0;i<cnt;i++) {
|
deba@1187
|
69 |
check(n!=INVALID,"Wrong red Node list linking.");
|
deba@1193
|
70 |
check(G.red(n),"Wrong node set check.");
|
deba@1193
|
71 |
check(!G.blue(n),"Wrong node set check.");
|
deba@1193
|
72 |
typename Graph::Node nn = n;
|
deba@1193
|
73 |
check(G.asRedNodeUnsafe(nn) == n,"Wrong node conversion.");
|
deba@1193
|
74 |
check(G.asRedNode(nn) == n,"Wrong node conversion.");
|
deba@1193
|
75 |
check(G.asBlueNode(nn) == INVALID,"Wrong node conversion.");
|
deba@1187
|
76 |
++n;
|
deba@1187
|
77 |
}
|
deba@1187
|
78 |
check(n==INVALID,"Wrong red Node list linking.");
|
deba@1187
|
79 |
check(countRedNodes(G)==cnt,"Wrong red Node number.");
|
alpar@1337
|
80 |
#ifdef LEMON_CXX11
|
alpar@1337
|
81 |
{
|
alpar@1337
|
82 |
typename Graph::RedNodeIt n(G);
|
alpar@1337
|
83 |
for(auto u: G.redNodes())
|
alpar@1337
|
84 |
{
|
alpar@1337
|
85 |
check(n==u,"Wrong STL RedNode iterator.");
|
alpar@1337
|
86 |
++n;
|
alpar@1337
|
87 |
}
|
alpar@1337
|
88 |
check(n==INVALID,"Wrong STL RedNode iterator.");
|
alpar@1337
|
89 |
}
|
alpar@1337
|
90 |
{
|
alpar@1337
|
91 |
typename Graph::RedNodeIt n(G);
|
alpar@1337
|
92 |
for(typename Graph::RedNode u: G.redNodes())
|
alpar@1337
|
93 |
{
|
alpar@1337
|
94 |
check(n==u,"Wrong STL RedNode iterator.");
|
alpar@1337
|
95 |
++n;
|
alpar@1337
|
96 |
}
|
alpar@1337
|
97 |
check(n==INVALID,"Wrong STL RedNode iterator.");
|
alpar@1337
|
98 |
}
|
alpar@1337
|
99 |
#endif
|
deba@1187
|
100 |
}
|
deba@1187
|
101 |
|
deba@1187
|
102 |
template<class Graph>
|
deba@1187
|
103 |
void checkGraphBlueNodeList(const Graph &G, int cnt)
|
deba@1187
|
104 |
{
|
deba@1194
|
105 |
typename Graph::BlueNodeIt n(G);
|
deba@1187
|
106 |
for(int i=0;i<cnt;i++) {
|
deba@1187
|
107 |
check(n!=INVALID,"Wrong blue Node list linking.");
|
deba@1193
|
108 |
check(G.blue(n),"Wrong node set check.");
|
deba@1193
|
109 |
check(!G.red(n),"Wrong node set check.");
|
deba@1193
|
110 |
typename Graph::Node nn = n;
|
deba@1193
|
111 |
check(G.asBlueNodeUnsafe(nn) == n,"Wrong node conversion.");
|
deba@1193
|
112 |
check(G.asBlueNode(nn) == n,"Wrong node conversion.");
|
deba@1193
|
113 |
check(G.asRedNode(nn) == INVALID,"Wrong node conversion.");
|
deba@1187
|
114 |
++n;
|
deba@1187
|
115 |
}
|
deba@1187
|
116 |
check(n==INVALID,"Wrong blue Node list linking.");
|
deba@1187
|
117 |
check(countBlueNodes(G)==cnt,"Wrong blue Node number.");
|
alpar@1337
|
118 |
#ifdef LEMON_CXX11
|
alpar@1337
|
119 |
{
|
alpar@1337
|
120 |
typename Graph::BlueNodeIt n(G);
|
alpar@1337
|
121 |
for(auto u: G.blueNodes())
|
alpar@1337
|
122 |
{
|
alpar@1337
|
123 |
check(n==u,"Wrong STL BlueNode iterator.");
|
alpar@1337
|
124 |
++n;
|
alpar@1337
|
125 |
}
|
alpar@1337
|
126 |
check(n==INVALID,"Wrong STL BlueNode iterator.");
|
alpar@1337
|
127 |
}
|
alpar@1337
|
128 |
{
|
alpar@1337
|
129 |
typename Graph::BlueNodeIt n(G);
|
alpar@1337
|
130 |
for(typename Graph::BlueNode u: G.blueNodes())
|
alpar@1337
|
131 |
{
|
alpar@1337
|
132 |
check(n==u,"Wrong STL BlueNode iterator.");
|
alpar@1337
|
133 |
++n;
|
alpar@1337
|
134 |
}
|
alpar@1337
|
135 |
check(n==INVALID,"Wrong STL BlueNode iterator.");
|
alpar@1337
|
136 |
}
|
alpar@1337
|
137 |
#endif
|
alpar@1337
|
138 |
|
deba@1187
|
139 |
}
|
deba@1187
|
140 |
|
deba@1187
|
141 |
template<class Graph>
|
kpeter@171
|
142 |
void checkGraphArcList(const Graph &G, int cnt)
|
kpeter@171
|
143 |
{
|
kpeter@171
|
144 |
typename Graph::ArcIt e(G);
|
kpeter@171
|
145 |
for(int i=0;i<cnt;i++) {
|
kpeter@171
|
146 |
check(e!=INVALID,"Wrong Arc list linking.");
|
deba@228
|
147 |
check(G.oppositeNode(G.source(e), e) == G.target(e),
|
deba@228
|
148 |
"Wrong opposite node");
|
deba@228
|
149 |
check(G.oppositeNode(G.target(e), e) == G.source(e),
|
deba@228
|
150 |
"Wrong opposite node");
|
kpeter@171
|
151 |
++e;
|
kpeter@171
|
152 |
}
|
kpeter@171
|
153 |
check(e==INVALID,"Wrong Arc list linking.");
|
kpeter@171
|
154 |
check(countArcs(G)==cnt,"Wrong Arc number.");
|
alpar@1337
|
155 |
#ifdef LEMON_CXX11
|
alpar@1337
|
156 |
{
|
alpar@1337
|
157 |
typename Graph::ArcIt a(G);
|
alpar@1337
|
158 |
for(auto e: G.arcs())
|
alpar@1337
|
159 |
{
|
alpar@1337
|
160 |
check(a==e,"Wrong STL Arc iterator.");
|
alpar@1337
|
161 |
++a;
|
alpar@1337
|
162 |
}
|
alpar@1337
|
163 |
check(a==INVALID,"Wrong STL Arc iterator.");
|
alpar@1337
|
164 |
}
|
alpar@1337
|
165 |
{
|
alpar@1337
|
166 |
typename Graph::ArcIt a(G);
|
alpar@1337
|
167 |
for(typename Graph::Arc e: G.arcs())
|
alpar@1337
|
168 |
{
|
alpar@1337
|
169 |
check(a==e,"Wrong STL Arc iterator.");
|
alpar@1337
|
170 |
++a;
|
alpar@1337
|
171 |
}
|
alpar@1337
|
172 |
check(a==INVALID,"Wrong STL Arc iterator.");
|
alpar@1337
|
173 |
}
|
alpar@1337
|
174 |
#endif
|
alpar@1337
|
175 |
|
kpeter@171
|
176 |
}
|
kpeter@171
|
177 |
|
kpeter@171
|
178 |
template<class Graph>
|
kpeter@171
|
179 |
void checkGraphOutArcList(const Graph &G, typename Graph::Node n, int cnt)
|
kpeter@171
|
180 |
{
|
kpeter@171
|
181 |
typename Graph::OutArcIt e(G,n);
|
kpeter@171
|
182 |
for(int i=0;i<cnt;i++) {
|
kpeter@171
|
183 |
check(e!=INVALID,"Wrong OutArc list linking.");
|
kpeter@171
|
184 |
check(n==G.source(e),"Wrong OutArc list linking.");
|
deba@228
|
185 |
check(n==G.baseNode(e),"Wrong OutArc list linking.");
|
deba@228
|
186 |
check(G.target(e)==G.runningNode(e),"Wrong OutArc list linking.");
|
kpeter@171
|
187 |
++e;
|
kpeter@171
|
188 |
}
|
kpeter@171
|
189 |
check(e==INVALID,"Wrong OutArc list linking.");
|
kpeter@171
|
190 |
check(countOutArcs(G,n)==cnt,"Wrong OutArc number.");
|
alpar@1337
|
191 |
#ifdef LEMON_CXX11
|
alpar@1337
|
192 |
{
|
alpar@1337
|
193 |
typename Graph::OutArcIt a(G,n);
|
alpar@1337
|
194 |
for(auto e: G.outArcs(n))
|
alpar@1337
|
195 |
{
|
alpar@1337
|
196 |
check(a==e,"Wrong STL OutArc iterator.");
|
alpar@1337
|
197 |
++a;
|
alpar@1337
|
198 |
}
|
alpar@1337
|
199 |
check(a==INVALID,"Wrong STL OutArc iterator.");
|
alpar@1337
|
200 |
}
|
alpar@1337
|
201 |
{
|
alpar@1337
|
202 |
typename Graph::OutArcIt a(G,n);
|
alpar@1337
|
203 |
for(typename Graph::Arc e: G.outArcs(n))
|
alpar@1337
|
204 |
{
|
alpar@1337
|
205 |
check(a==e,"Wrong STL OutArc iterator.");
|
alpar@1337
|
206 |
++a;
|
alpar@1337
|
207 |
}
|
alpar@1337
|
208 |
check(a==INVALID,"Wrong STL OutArc iterator.");
|
alpar@1337
|
209 |
}
|
alpar@1337
|
210 |
#endif
|
alpar@1337
|
211 |
|
kpeter@171
|
212 |
}
|
kpeter@171
|
213 |
|
kpeter@171
|
214 |
template<class Graph>
|
kpeter@171
|
215 |
void checkGraphInArcList(const Graph &G, typename Graph::Node n, int cnt)
|
kpeter@171
|
216 |
{
|
kpeter@171
|
217 |
typename Graph::InArcIt e(G,n);
|
kpeter@171
|
218 |
for(int i=0;i<cnt;i++) {
|
kpeter@171
|
219 |
check(e!=INVALID,"Wrong InArc list linking.");
|
kpeter@171
|
220 |
check(n==G.target(e),"Wrong InArc list linking.");
|
deba@228
|
221 |
check(n==G.baseNode(e),"Wrong OutArc list linking.");
|
deba@228
|
222 |
check(G.source(e)==G.runningNode(e),"Wrong OutArc list linking.");
|
kpeter@171
|
223 |
++e;
|
kpeter@171
|
224 |
}
|
kpeter@171
|
225 |
check(e==INVALID,"Wrong InArc list linking.");
|
kpeter@171
|
226 |
check(countInArcs(G,n)==cnt,"Wrong InArc number.");
|
alpar@1337
|
227 |
#ifdef LEMON_CXX11
|
alpar@1337
|
228 |
{
|
alpar@1337
|
229 |
typename Graph::InArcIt a(G,n);
|
alpar@1337
|
230 |
for(auto e: G.inArcs(n))
|
alpar@1337
|
231 |
{
|
alpar@1337
|
232 |
check(a==e,"Wrong STL InArc iterator.");
|
alpar@1337
|
233 |
++a;
|
alpar@1337
|
234 |
}
|
alpar@1337
|
235 |
check(a==INVALID,"Wrong STL InArc iterator.");
|
alpar@1337
|
236 |
}
|
alpar@1337
|
237 |
{
|
alpar@1337
|
238 |
typename Graph::InArcIt a(G,n);
|
alpar@1337
|
239 |
for(typename Graph::Arc e: G.inArcs(n))
|
alpar@1337
|
240 |
{
|
alpar@1337
|
241 |
check(a==e,"Wrong STL InArc iterator.");
|
alpar@1337
|
242 |
++a;
|
alpar@1337
|
243 |
}
|
alpar@1337
|
244 |
check(a==INVALID,"Wrong STL InArc iterator.");
|
alpar@1337
|
245 |
}
|
alpar@1337
|
246 |
#endif
|
kpeter@171
|
247 |
}
|
kpeter@171
|
248 |
|
kpeter@171
|
249 |
template<class Graph>
|
kpeter@171
|
250 |
void checkGraphEdgeList(const Graph &G, int cnt)
|
kpeter@171
|
251 |
{
|
kpeter@171
|
252 |
typename Graph::EdgeIt e(G);
|
kpeter@171
|
253 |
for(int i=0;i<cnt;i++) {
|
kpeter@171
|
254 |
check(e!=INVALID,"Wrong Edge list linking.");
|
deba@228
|
255 |
check(G.oppositeNode(G.u(e), e) == G.v(e), "Wrong opposite node");
|
deba@228
|
256 |
check(G.oppositeNode(G.v(e), e) == G.u(e), "Wrong opposite node");
|
kpeter@171
|
257 |
++e;
|
kpeter@171
|
258 |
}
|
kpeter@171
|
259 |
check(e==INVALID,"Wrong Edge list linking.");
|
kpeter@171
|
260 |
check(countEdges(G)==cnt,"Wrong Edge number.");
|
alpar@1337
|
261 |
#ifdef LEMON_CXX11
|
alpar@1337
|
262 |
{
|
alpar@1337
|
263 |
typename Graph::EdgeIt a(G);
|
alpar@1337
|
264 |
for(auto e: G.edges())
|
alpar@1337
|
265 |
{
|
alpar@1337
|
266 |
check(a==e,"Wrong STL Edge iterator.");
|
alpar@1337
|
267 |
++a;
|
alpar@1337
|
268 |
}
|
alpar@1337
|
269 |
check(a==INVALID,"Wrong STL Edge iterator.");
|
alpar@1337
|
270 |
}
|
alpar@1337
|
271 |
{
|
alpar@1337
|
272 |
typename Graph::EdgeIt a(G);
|
alpar@1337
|
273 |
for(typename Graph::Edge e: G.edges())
|
alpar@1337
|
274 |
{
|
alpar@1337
|
275 |
check(a==e,"Wrong STL Edge iterator.");
|
alpar@1337
|
276 |
++a;
|
alpar@1337
|
277 |
}
|
alpar@1337
|
278 |
check(a==INVALID,"Wrong STL Edge iterator.");
|
alpar@1337
|
279 |
}
|
alpar@1337
|
280 |
#endif
|
alpar@1337
|
281 |
|
kpeter@171
|
282 |
}
|
kpeter@171
|
283 |
|
kpeter@171
|
284 |
template<class Graph>
|
kpeter@171
|
285 |
void checkGraphIncEdgeList(const Graph &G, typename Graph::Node n, int cnt)
|
kpeter@171
|
286 |
{
|
kpeter@171
|
287 |
typename Graph::IncEdgeIt e(G,n);
|
kpeter@171
|
288 |
for(int i=0;i<cnt;i++) {
|
kpeter@171
|
289 |
check(e!=INVALID,"Wrong IncEdge list linking.");
|
kpeter@171
|
290 |
check(n==G.u(e) || n==G.v(e),"Wrong IncEdge list linking.");
|
deba@228
|
291 |
check(n==G.baseNode(e),"Wrong OutArc list linking.");
|
deba@228
|
292 |
check(G.u(e)==G.runningNode(e) || G.v(e)==G.runningNode(e),
|
deba@228
|
293 |
"Wrong OutArc list linking.");
|
kpeter@171
|
294 |
++e;
|
kpeter@171
|
295 |
}
|
kpeter@171
|
296 |
check(e==INVALID,"Wrong IncEdge list linking.");
|
kpeter@171
|
297 |
check(countIncEdges(G,n)==cnt,"Wrong IncEdge number.");
|
alpar@1337
|
298 |
#ifdef LEMON_CXX11
|
alpar@1337
|
299 |
{
|
alpar@1337
|
300 |
typename Graph::IncEdgeIt a(G,n);
|
alpar@1337
|
301 |
for(auto e: G.incEdges(n))
|
alpar@1337
|
302 |
{
|
alpar@1337
|
303 |
check(a==e,"Wrong STL IncEdge iterator.");
|
alpar@1337
|
304 |
++a;
|
alpar@1337
|
305 |
}
|
alpar@1337
|
306 |
check(a==INVALID,"Wrong STL IncEdge iterator.");
|
alpar@1337
|
307 |
}
|
alpar@1337
|
308 |
{
|
alpar@1337
|
309 |
typename Graph::IncEdgeIt a(G,n);
|
alpar@1337
|
310 |
for(typename Graph::Edge e: G.incEdges(n))
|
alpar@1337
|
311 |
{
|
alpar@1337
|
312 |
check(a==e,"Wrong STL IncEdge iterator.");
|
alpar@1337
|
313 |
++a;
|
alpar@1337
|
314 |
}
|
alpar@1337
|
315 |
check(a==INVALID,"Wrong STL IncEdge iterator.");
|
alpar@1337
|
316 |
}
|
alpar@1337
|
317 |
#endif
|
alpar@1337
|
318 |
|
kpeter@171
|
319 |
}
|
kpeter@171
|
320 |
|
deba@228
|
321 |
template <class Graph>
|
kpeter@387
|
322 |
void checkGraphIncEdgeArcLists(const Graph &G, typename Graph::Node n,
|
kpeter@387
|
323 |
int cnt)
|
kpeter@387
|
324 |
{
|
kpeter@387
|
325 |
checkGraphIncEdgeList(G, n, cnt);
|
kpeter@387
|
326 |
checkGraphOutArcList(G, n, cnt);
|
kpeter@387
|
327 |
checkGraphInArcList(G, n, cnt);
|
kpeter@387
|
328 |
}
|
kpeter@387
|
329 |
|
kpeter@387
|
330 |
template <class Graph>
|
deba@228
|
331 |
void checkGraphConArcList(const Graph &G, int cnt) {
|
deba@228
|
332 |
int i = 0;
|
deba@228
|
333 |
for (typename Graph::NodeIt u(G); u != INVALID; ++u) {
|
deba@228
|
334 |
for (typename Graph::NodeIt v(G); v != INVALID; ++v) {
|
deba@228
|
335 |
for (ConArcIt<Graph> a(G, u, v); a != INVALID; ++a) {
|
deba@228
|
336 |
check(G.source(a) == u, "Wrong iterator.");
|
deba@228
|
337 |
check(G.target(a) == v, "Wrong iterator.");
|
deba@228
|
338 |
++i;
|
deba@228
|
339 |
}
|
deba@228
|
340 |
}
|
deba@228
|
341 |
}
|
deba@228
|
342 |
check(cnt == i, "Wrong iterator.");
|
kpeter@171
|
343 |
}
|
kpeter@171
|
344 |
|
kpeter@171
|
345 |
template <class Graph>
|
deba@228
|
346 |
void checkGraphConEdgeList(const Graph &G, int cnt) {
|
deba@228
|
347 |
int i = 0;
|
deba@228
|
348 |
for (typename Graph::NodeIt u(G); u != INVALID; ++u) {
|
deba@228
|
349 |
for (typename Graph::NodeIt v(G); v != INVALID; ++v) {
|
deba@228
|
350 |
for (ConEdgeIt<Graph> e(G, u, v); e != INVALID; ++e) {
|
deba@228
|
351 |
check((G.u(e) == u && G.v(e) == v) ||
|
deba@228
|
352 |
(G.u(e) == v && G.v(e) == u), "Wrong iterator.");
|
deba@228
|
353 |
i += u == v ? 2 : 1;
|
deba@228
|
354 |
}
|
deba@228
|
355 |
}
|
deba@228
|
356 |
}
|
deba@228
|
357 |
check(2 * cnt == i, "Wrong iterator.");
|
kpeter@171
|
358 |
}
|
kpeter@171
|
359 |
|
deba@228
|
360 |
template <typename Graph>
|
deba@228
|
361 |
void checkArcDirections(const Graph& G) {
|
deba@228
|
362 |
for (typename Graph::ArcIt a(G); a != INVALID; ++a) {
|
deba@228
|
363 |
check(G.source(a) == G.target(G.oppositeArc(a)), "Wrong direction");
|
deba@228
|
364 |
check(G.target(a) == G.source(G.oppositeArc(a)), "Wrong direction");
|
deba@228
|
365 |
check(G.direct(a, G.direction(a)) == a, "Wrong direction");
|
kpeter@171
|
366 |
}
|
kpeter@171
|
367 |
}
|
kpeter@171
|
368 |
|
deba@228
|
369 |
template <typename Graph>
|
deba@228
|
370 |
void checkNodeIds(const Graph& G) {
|
deba@1187
|
371 |
typedef typename Graph::Node Node;
|
deba@228
|
372 |
std::set<int> values;
|
deba@228
|
373 |
for (typename Graph::NodeIt n(G); n != INVALID; ++n) {
|
deba@228
|
374 |
check(G.nodeFromId(G.id(n)) == n, "Wrong id");
|
deba@228
|
375 |
check(values.find(G.id(n)) == values.end(), "Wrong id");
|
deba@228
|
376 |
check(G.id(n) <= G.maxNodeId(), "Wrong maximum id");
|
deba@228
|
377 |
values.insert(G.id(n));
|
kpeter@171
|
378 |
}
|
deba@1187
|
379 |
check(G.maxId(Node()) <= G.maxNodeId(), "Wrong maximum id");
|
deba@1187
|
380 |
}
|
deba@1187
|
381 |
|
deba@1187
|
382 |
template <typename Graph>
|
deba@1187
|
383 |
void checkRedNodeIds(const Graph& G) {
|
deba@1187
|
384 |
typedef typename Graph::RedNode RedNode;
|
deba@1187
|
385 |
std::set<int> values;
|
deba@1194
|
386 |
for (typename Graph::RedNodeIt n(G); n != INVALID; ++n) {
|
deba@1187
|
387 |
check(G.red(n), "Wrong partition");
|
deba@1193
|
388 |
check(values.find(G.id(n)) == values.end(), "Wrong id");
|
deba@1193
|
389 |
check(G.id(n) <= G.maxRedId(), "Wrong maximum id");
|
deba@1187
|
390 |
values.insert(G.id(n));
|
deba@1187
|
391 |
}
|
deba@1187
|
392 |
check(G.maxId(RedNode()) == G.maxRedId(), "Wrong maximum id");
|
deba@1187
|
393 |
}
|
deba@1187
|
394 |
|
deba@1187
|
395 |
template <typename Graph>
|
deba@1187
|
396 |
void checkBlueNodeIds(const Graph& G) {
|
deba@1187
|
397 |
typedef typename Graph::BlueNode BlueNode;
|
deba@1187
|
398 |
std::set<int> values;
|
deba@1194
|
399 |
for (typename Graph::BlueNodeIt n(G); n != INVALID; ++n) {
|
deba@1187
|
400 |
check(G.blue(n), "Wrong partition");
|
deba@1193
|
401 |
check(values.find(G.id(n)) == values.end(), "Wrong id");
|
deba@1193
|
402 |
check(G.id(n) <= G.maxBlueId(), "Wrong maximum id");
|
deba@1187
|
403 |
values.insert(G.id(n));
|
deba@1187
|
404 |
}
|
deba@1187
|
405 |
check(G.maxId(BlueNode()) == G.maxBlueId(), "Wrong maximum id");
|
kpeter@171
|
406 |
}
|
kpeter@171
|
407 |
|
deba@228
|
408 |
template <typename Graph>
|
deba@228
|
409 |
void checkArcIds(const Graph& G) {
|
deba@1187
|
410 |
typedef typename Graph::Arc Arc;
|
deba@228
|
411 |
std::set<int> values;
|
deba@228
|
412 |
for (typename Graph::ArcIt a(G); a != INVALID; ++a) {
|
deba@228
|
413 |
check(G.arcFromId(G.id(a)) == a, "Wrong id");
|
deba@228
|
414 |
check(values.find(G.id(a)) == values.end(), "Wrong id");
|
deba@228
|
415 |
check(G.id(a) <= G.maxArcId(), "Wrong maximum id");
|
deba@228
|
416 |
values.insert(G.id(a));
|
deba@228
|
417 |
}
|
deba@1187
|
418 |
check(G.maxId(Arc()) <= G.maxArcId(), "Wrong maximum id");
|
kpeter@171
|
419 |
}
|
alpar@209
|
420 |
|
deba@228
|
421 |
template <typename Graph>
|
deba@228
|
422 |
void checkEdgeIds(const Graph& G) {
|
deba@1187
|
423 |
typedef typename Graph::Edge Edge;
|
deba@228
|
424 |
std::set<int> values;
|
deba@228
|
425 |
for (typename Graph::EdgeIt e(G); e != INVALID; ++e) {
|
deba@228
|
426 |
check(G.edgeFromId(G.id(e)) == e, "Wrong id");
|
deba@228
|
427 |
check(values.find(G.id(e)) == values.end(), "Wrong id");
|
deba@228
|
428 |
check(G.id(e) <= G.maxEdgeId(), "Wrong maximum id");
|
deba@228
|
429 |
values.insert(G.id(e));
|
deba@228
|
430 |
}
|
deba@1187
|
431 |
check(G.maxId(Edge()) <= G.maxEdgeId(), "Wrong maximum id");
|
kpeter@171
|
432 |
}
|
kpeter@171
|
433 |
|
deba@228
|
434 |
template <typename Graph>
|
deba@228
|
435 |
void checkGraphNodeMap(const Graph& G) {
|
deba@228
|
436 |
typedef typename Graph::Node Node;
|
deba@228
|
437 |
typedef typename Graph::NodeIt NodeIt;
|
deba@228
|
438 |
|
deba@228
|
439 |
typedef typename Graph::template NodeMap<int> IntNodeMap;
|
deba@228
|
440 |
IntNodeMap map(G, 42);
|
deba@228
|
441 |
for (NodeIt it(G); it != INVALID; ++it) {
|
deba@228
|
442 |
check(map[it] == 42, "Wrong map constructor.");
|
deba@228
|
443 |
}
|
deba@228
|
444 |
int s = 0;
|
deba@228
|
445 |
for (NodeIt it(G); it != INVALID; ++it) {
|
deba@228
|
446 |
map[it] = 0;
|
deba@228
|
447 |
check(map[it] == 0, "Wrong operator[].");
|
deba@228
|
448 |
map.set(it, s);
|
deba@228
|
449 |
check(map[it] == s, "Wrong set.");
|
deba@228
|
450 |
++s;
|
deba@228
|
451 |
}
|
deba@228
|
452 |
s = s * (s - 1) / 2;
|
deba@228
|
453 |
for (NodeIt it(G); it != INVALID; ++it) {
|
deba@228
|
454 |
s -= map[it];
|
deba@228
|
455 |
}
|
deba@228
|
456 |
check(s == 0, "Wrong sum.");
|
deba@228
|
457 |
|
kpeter@263
|
458 |
// map = constMap<Node>(12);
|
kpeter@263
|
459 |
// for (NodeIt it(G); it != INVALID; ++it) {
|
kpeter@263
|
460 |
// check(map[it] == 12, "Wrong operator[].");
|
kpeter@263
|
461 |
// }
|
deba@228
|
462 |
}
|
deba@228
|
463 |
|
deba@228
|
464 |
template <typename Graph>
|
deba@1194
|
465 |
void checkGraphRedNodeMap(const Graph& G) {
|
deba@1187
|
466 |
typedef typename Graph::Node Node;
|
deba@1194
|
467 |
typedef typename Graph::RedNodeIt RedNodeIt;
|
deba@1187
|
468 |
|
deba@1194
|
469 |
typedef typename Graph::template RedNodeMap<int> IntRedNodeMap;
|
deba@1194
|
470 |
IntRedNodeMap map(G, 42);
|
deba@1194
|
471 |
for (RedNodeIt it(G); it != INVALID; ++it) {
|
deba@1187
|
472 |
check(map[it] == 42, "Wrong map constructor.");
|
deba@1187
|
473 |
}
|
deba@1187
|
474 |
int s = 0;
|
deba@1194
|
475 |
for (RedNodeIt it(G); it != INVALID; ++it) {
|
deba@1187
|
476 |
map[it] = 0;
|
deba@1187
|
477 |
check(map[it] == 0, "Wrong operator[].");
|
deba@1187
|
478 |
map.set(it, s);
|
deba@1187
|
479 |
check(map[it] == s, "Wrong set.");
|
deba@1187
|
480 |
++s;
|
deba@1187
|
481 |
}
|
deba@1187
|
482 |
s = s * (s - 1) / 2;
|
deba@1194
|
483 |
for (RedNodeIt it(G); it != INVALID; ++it) {
|
deba@1187
|
484 |
s -= map[it];
|
deba@1187
|
485 |
}
|
deba@1187
|
486 |
check(s == 0, "Wrong sum.");
|
deba@1187
|
487 |
|
deba@1187
|
488 |
// map = constMap<Node>(12);
|
deba@1187
|
489 |
// for (NodeIt it(G); it != INVALID; ++it) {
|
deba@1187
|
490 |
// check(map[it] == 12, "Wrong operator[].");
|
deba@1187
|
491 |
// }
|
deba@1187
|
492 |
}
|
deba@1187
|
493 |
|
deba@1187
|
494 |
template <typename Graph>
|
deba@1194
|
495 |
void checkGraphBlueNodeMap(const Graph& G) {
|
deba@1187
|
496 |
typedef typename Graph::Node Node;
|
deba@1194
|
497 |
typedef typename Graph::BlueNodeIt BlueNodeIt;
|
deba@1187
|
498 |
|
deba@1194
|
499 |
typedef typename Graph::template BlueNodeMap<int> IntBlueNodeMap;
|
deba@1194
|
500 |
IntBlueNodeMap map(G, 42);
|
deba@1194
|
501 |
for (BlueNodeIt it(G); it != INVALID; ++it) {
|
deba@1187
|
502 |
check(map[it] == 42, "Wrong map constructor.");
|
deba@1187
|
503 |
}
|
deba@1187
|
504 |
int s = 0;
|
deba@1194
|
505 |
for (BlueNodeIt it(G); it != INVALID; ++it) {
|
deba@1187
|
506 |
map[it] = 0;
|
deba@1187
|
507 |
check(map[it] == 0, "Wrong operator[].");
|
deba@1187
|
508 |
map.set(it, s);
|
deba@1187
|
509 |
check(map[it] == s, "Wrong set.");
|
deba@1187
|
510 |
++s;
|
deba@1187
|
511 |
}
|
deba@1187
|
512 |
s = s * (s - 1) / 2;
|
deba@1194
|
513 |
for (BlueNodeIt it(G); it != INVALID; ++it) {
|
deba@1187
|
514 |
s -= map[it];
|
deba@1187
|
515 |
}
|
deba@1187
|
516 |
check(s == 0, "Wrong sum.");
|
deba@1187
|
517 |
|
deba@1187
|
518 |
// map = constMap<Node>(12);
|
deba@1187
|
519 |
// for (NodeIt it(G); it != INVALID; ++it) {
|
deba@1187
|
520 |
// check(map[it] == 12, "Wrong operator[].");
|
deba@1187
|
521 |
// }
|
deba@1187
|
522 |
}
|
deba@1187
|
523 |
|
deba@1187
|
524 |
template <typename Graph>
|
deba@228
|
525 |
void checkGraphArcMap(const Graph& G) {
|
deba@228
|
526 |
typedef typename Graph::Arc Arc;
|
deba@228
|
527 |
typedef typename Graph::ArcIt ArcIt;
|
deba@228
|
528 |
|
deba@228
|
529 |
typedef typename Graph::template ArcMap<int> IntArcMap;
|
deba@228
|
530 |
IntArcMap map(G, 42);
|
deba@228
|
531 |
for (ArcIt it(G); it != INVALID; ++it) {
|
deba@228
|
532 |
check(map[it] == 42, "Wrong map constructor.");
|
deba@228
|
533 |
}
|
deba@228
|
534 |
int s = 0;
|
deba@228
|
535 |
for (ArcIt it(G); it != INVALID; ++it) {
|
deba@228
|
536 |
map[it] = 0;
|
deba@228
|
537 |
check(map[it] == 0, "Wrong operator[].");
|
deba@228
|
538 |
map.set(it, s);
|
deba@228
|
539 |
check(map[it] == s, "Wrong set.");
|
deba@228
|
540 |
++s;
|
deba@228
|
541 |
}
|
deba@228
|
542 |
s = s * (s - 1) / 2;
|
deba@228
|
543 |
for (ArcIt it(G); it != INVALID; ++it) {
|
deba@228
|
544 |
s -= map[it];
|
deba@228
|
545 |
}
|
deba@228
|
546 |
check(s == 0, "Wrong sum.");
|
deba@228
|
547 |
|
kpeter@263
|
548 |
// map = constMap<Arc>(12);
|
kpeter@263
|
549 |
// for (ArcIt it(G); it != INVALID; ++it) {
|
kpeter@263
|
550 |
// check(map[it] == 12, "Wrong operator[].");
|
kpeter@263
|
551 |
// }
|
deba@228
|
552 |
}
|
deba@228
|
553 |
|
deba@228
|
554 |
template <typename Graph>
|
deba@228
|
555 |
void checkGraphEdgeMap(const Graph& G) {
|
deba@228
|
556 |
typedef typename Graph::Edge Edge;
|
deba@228
|
557 |
typedef typename Graph::EdgeIt EdgeIt;
|
deba@228
|
558 |
|
deba@228
|
559 |
typedef typename Graph::template EdgeMap<int> IntEdgeMap;
|
deba@228
|
560 |
IntEdgeMap map(G, 42);
|
deba@228
|
561 |
for (EdgeIt it(G); it != INVALID; ++it) {
|
deba@228
|
562 |
check(map[it] == 42, "Wrong map constructor.");
|
deba@228
|
563 |
}
|
deba@228
|
564 |
int s = 0;
|
deba@228
|
565 |
for (EdgeIt it(G); it != INVALID; ++it) {
|
deba@228
|
566 |
map[it] = 0;
|
deba@228
|
567 |
check(map[it] == 0, "Wrong operator[].");
|
deba@228
|
568 |
map.set(it, s);
|
deba@228
|
569 |
check(map[it] == s, "Wrong set.");
|
deba@228
|
570 |
++s;
|
deba@228
|
571 |
}
|
deba@228
|
572 |
s = s * (s - 1) / 2;
|
deba@228
|
573 |
for (EdgeIt it(G); it != INVALID; ++it) {
|
deba@228
|
574 |
s -= map[it];
|
deba@228
|
575 |
}
|
deba@228
|
576 |
check(s == 0, "Wrong sum.");
|
deba@228
|
577 |
|
kpeter@263
|
578 |
// map = constMap<Edge>(12);
|
kpeter@263
|
579 |
// for (EdgeIt it(G); it != INVALID; ++it) {
|
kpeter@263
|
580 |
// check(map[it] == 12, "Wrong operator[].");
|
kpeter@263
|
581 |
// }
|
deba@228
|
582 |
}
|
deba@228
|
583 |
|
deba@228
|
584 |
|
kpeter@171
|
585 |
} //namespace lemon
|
kpeter@171
|
586 |
|
kpeter@171
|
587 |
#endif
|