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.");
|
kpeter@171
|
41 |
}
|
kpeter@171
|
42 |
|
kpeter@171
|
43 |
template<class Graph>
|
deba@1187
|
44 |
void checkGraphRedNodeList(const Graph &G, int cnt)
|
deba@1187
|
45 |
{
|
deba@1194
|
46 |
typename Graph::RedNodeIt n(G);
|
deba@1187
|
47 |
for(int i=0;i<cnt;i++) {
|
deba@1187
|
48 |
check(n!=INVALID,"Wrong red Node list linking.");
|
deba@1193
|
49 |
check(G.red(n),"Wrong node set check.");
|
deba@1193
|
50 |
check(!G.blue(n),"Wrong node set check.");
|
deba@1193
|
51 |
typename Graph::Node nn = n;
|
deba@1193
|
52 |
check(G.asRedNodeUnsafe(nn) == n,"Wrong node conversion.");
|
deba@1193
|
53 |
check(G.asRedNode(nn) == n,"Wrong node conversion.");
|
deba@1193
|
54 |
check(G.asBlueNode(nn) == INVALID,"Wrong node conversion.");
|
deba@1187
|
55 |
++n;
|
deba@1187
|
56 |
}
|
deba@1187
|
57 |
check(n==INVALID,"Wrong red Node list linking.");
|
deba@1187
|
58 |
check(countRedNodes(G)==cnt,"Wrong red Node number.");
|
deba@1187
|
59 |
}
|
deba@1187
|
60 |
|
deba@1187
|
61 |
template<class Graph>
|
deba@1187
|
62 |
void checkGraphBlueNodeList(const Graph &G, int cnt)
|
deba@1187
|
63 |
{
|
deba@1194
|
64 |
typename Graph::BlueNodeIt n(G);
|
deba@1187
|
65 |
for(int i=0;i<cnt;i++) {
|
deba@1187
|
66 |
check(n!=INVALID,"Wrong blue Node list linking.");
|
deba@1193
|
67 |
check(G.blue(n),"Wrong node set check.");
|
deba@1193
|
68 |
check(!G.red(n),"Wrong node set check.");
|
deba@1193
|
69 |
typename Graph::Node nn = n;
|
deba@1193
|
70 |
check(G.asBlueNodeUnsafe(nn) == n,"Wrong node conversion.");
|
deba@1193
|
71 |
check(G.asBlueNode(nn) == n,"Wrong node conversion.");
|
deba@1193
|
72 |
check(G.asRedNode(nn) == INVALID,"Wrong node conversion.");
|
deba@1187
|
73 |
++n;
|
deba@1187
|
74 |
}
|
deba@1187
|
75 |
check(n==INVALID,"Wrong blue Node list linking.");
|
deba@1187
|
76 |
check(countBlueNodes(G)==cnt,"Wrong blue Node number.");
|
deba@1187
|
77 |
}
|
deba@1187
|
78 |
|
deba@1187
|
79 |
template<class Graph>
|
kpeter@171
|
80 |
void checkGraphArcList(const Graph &G, int cnt)
|
kpeter@171
|
81 |
{
|
kpeter@171
|
82 |
typename Graph::ArcIt e(G);
|
kpeter@171
|
83 |
for(int i=0;i<cnt;i++) {
|
kpeter@171
|
84 |
check(e!=INVALID,"Wrong Arc list linking.");
|
deba@228
|
85 |
check(G.oppositeNode(G.source(e), e) == G.target(e),
|
deba@228
|
86 |
"Wrong opposite node");
|
deba@228
|
87 |
check(G.oppositeNode(G.target(e), e) == G.source(e),
|
deba@228
|
88 |
"Wrong opposite node");
|
kpeter@171
|
89 |
++e;
|
kpeter@171
|
90 |
}
|
kpeter@171
|
91 |
check(e==INVALID,"Wrong Arc list linking.");
|
kpeter@171
|
92 |
check(countArcs(G)==cnt,"Wrong Arc number.");
|
kpeter@171
|
93 |
}
|
kpeter@171
|
94 |
|
kpeter@171
|
95 |
template<class Graph>
|
kpeter@171
|
96 |
void checkGraphOutArcList(const Graph &G, typename Graph::Node n, int cnt)
|
kpeter@171
|
97 |
{
|
kpeter@171
|
98 |
typename Graph::OutArcIt e(G,n);
|
kpeter@171
|
99 |
for(int i=0;i<cnt;i++) {
|
kpeter@171
|
100 |
check(e!=INVALID,"Wrong OutArc list linking.");
|
kpeter@171
|
101 |
check(n==G.source(e),"Wrong OutArc list linking.");
|
deba@228
|
102 |
check(n==G.baseNode(e),"Wrong OutArc list linking.");
|
deba@228
|
103 |
check(G.target(e)==G.runningNode(e),"Wrong OutArc list linking.");
|
kpeter@171
|
104 |
++e;
|
kpeter@171
|
105 |
}
|
kpeter@171
|
106 |
check(e==INVALID,"Wrong OutArc list linking.");
|
kpeter@171
|
107 |
check(countOutArcs(G,n)==cnt,"Wrong OutArc number.");
|
kpeter@171
|
108 |
}
|
kpeter@171
|
109 |
|
kpeter@171
|
110 |
template<class Graph>
|
kpeter@171
|
111 |
void checkGraphInArcList(const Graph &G, typename Graph::Node n, int cnt)
|
kpeter@171
|
112 |
{
|
kpeter@171
|
113 |
typename Graph::InArcIt e(G,n);
|
kpeter@171
|
114 |
for(int i=0;i<cnt;i++) {
|
kpeter@171
|
115 |
check(e!=INVALID,"Wrong InArc list linking.");
|
kpeter@171
|
116 |
check(n==G.target(e),"Wrong InArc list linking.");
|
deba@228
|
117 |
check(n==G.baseNode(e),"Wrong OutArc list linking.");
|
deba@228
|
118 |
check(G.source(e)==G.runningNode(e),"Wrong OutArc list linking.");
|
kpeter@171
|
119 |
++e;
|
kpeter@171
|
120 |
}
|
kpeter@171
|
121 |
check(e==INVALID,"Wrong InArc list linking.");
|
kpeter@171
|
122 |
check(countInArcs(G,n)==cnt,"Wrong InArc number.");
|
kpeter@171
|
123 |
}
|
kpeter@171
|
124 |
|
kpeter@171
|
125 |
template<class Graph>
|
kpeter@171
|
126 |
void checkGraphEdgeList(const Graph &G, int cnt)
|
kpeter@171
|
127 |
{
|
kpeter@171
|
128 |
typename Graph::EdgeIt e(G);
|
kpeter@171
|
129 |
for(int i=0;i<cnt;i++) {
|
kpeter@171
|
130 |
check(e!=INVALID,"Wrong Edge list linking.");
|
deba@228
|
131 |
check(G.oppositeNode(G.u(e), e) == G.v(e), "Wrong opposite node");
|
deba@228
|
132 |
check(G.oppositeNode(G.v(e), e) == G.u(e), "Wrong opposite node");
|
kpeter@171
|
133 |
++e;
|
kpeter@171
|
134 |
}
|
kpeter@171
|
135 |
check(e==INVALID,"Wrong Edge list linking.");
|
kpeter@171
|
136 |
check(countEdges(G)==cnt,"Wrong Edge number.");
|
kpeter@171
|
137 |
}
|
kpeter@171
|
138 |
|
kpeter@171
|
139 |
template<class Graph>
|
kpeter@171
|
140 |
void checkGraphIncEdgeList(const Graph &G, typename Graph::Node n, int cnt)
|
kpeter@171
|
141 |
{
|
kpeter@171
|
142 |
typename Graph::IncEdgeIt e(G,n);
|
kpeter@171
|
143 |
for(int i=0;i<cnt;i++) {
|
kpeter@171
|
144 |
check(e!=INVALID,"Wrong IncEdge list linking.");
|
kpeter@171
|
145 |
check(n==G.u(e) || n==G.v(e),"Wrong IncEdge list linking.");
|
deba@228
|
146 |
check(n==G.baseNode(e),"Wrong OutArc list linking.");
|
deba@228
|
147 |
check(G.u(e)==G.runningNode(e) || G.v(e)==G.runningNode(e),
|
deba@228
|
148 |
"Wrong OutArc list linking.");
|
kpeter@171
|
149 |
++e;
|
kpeter@171
|
150 |
}
|
kpeter@171
|
151 |
check(e==INVALID,"Wrong IncEdge list linking.");
|
kpeter@171
|
152 |
check(countIncEdges(G,n)==cnt,"Wrong IncEdge number.");
|
kpeter@171
|
153 |
}
|
kpeter@171
|
154 |
|
deba@228
|
155 |
template <class Graph>
|
kpeter@387
|
156 |
void checkGraphIncEdgeArcLists(const Graph &G, typename Graph::Node n,
|
kpeter@387
|
157 |
int cnt)
|
kpeter@387
|
158 |
{
|
kpeter@387
|
159 |
checkGraphIncEdgeList(G, n, cnt);
|
kpeter@387
|
160 |
checkGraphOutArcList(G, n, cnt);
|
kpeter@387
|
161 |
checkGraphInArcList(G, n, cnt);
|
kpeter@387
|
162 |
}
|
kpeter@387
|
163 |
|
kpeter@387
|
164 |
template <class Graph>
|
deba@228
|
165 |
void checkGraphConArcList(const Graph &G, int cnt) {
|
deba@228
|
166 |
int i = 0;
|
deba@228
|
167 |
for (typename Graph::NodeIt u(G); u != INVALID; ++u) {
|
deba@228
|
168 |
for (typename Graph::NodeIt v(G); v != INVALID; ++v) {
|
deba@228
|
169 |
for (ConArcIt<Graph> a(G, u, v); a != INVALID; ++a) {
|
deba@228
|
170 |
check(G.source(a) == u, "Wrong iterator.");
|
deba@228
|
171 |
check(G.target(a) == v, "Wrong iterator.");
|
deba@228
|
172 |
++i;
|
deba@228
|
173 |
}
|
deba@228
|
174 |
}
|
deba@228
|
175 |
}
|
deba@228
|
176 |
check(cnt == i, "Wrong iterator.");
|
kpeter@171
|
177 |
}
|
kpeter@171
|
178 |
|
kpeter@171
|
179 |
template <class Graph>
|
deba@228
|
180 |
void checkGraphConEdgeList(const Graph &G, int cnt) {
|
deba@228
|
181 |
int i = 0;
|
deba@228
|
182 |
for (typename Graph::NodeIt u(G); u != INVALID; ++u) {
|
deba@228
|
183 |
for (typename Graph::NodeIt v(G); v != INVALID; ++v) {
|
deba@228
|
184 |
for (ConEdgeIt<Graph> e(G, u, v); e != INVALID; ++e) {
|
deba@228
|
185 |
check((G.u(e) == u && G.v(e) == v) ||
|
deba@228
|
186 |
(G.u(e) == v && G.v(e) == u), "Wrong iterator.");
|
deba@228
|
187 |
i += u == v ? 2 : 1;
|
deba@228
|
188 |
}
|
deba@228
|
189 |
}
|
deba@228
|
190 |
}
|
deba@228
|
191 |
check(2 * cnt == i, "Wrong iterator.");
|
kpeter@171
|
192 |
}
|
kpeter@171
|
193 |
|
deba@228
|
194 |
template <typename Graph>
|
deba@228
|
195 |
void checkArcDirections(const Graph& G) {
|
deba@228
|
196 |
for (typename Graph::ArcIt a(G); a != INVALID; ++a) {
|
deba@228
|
197 |
check(G.source(a) == G.target(G.oppositeArc(a)), "Wrong direction");
|
deba@228
|
198 |
check(G.target(a) == G.source(G.oppositeArc(a)), "Wrong direction");
|
deba@228
|
199 |
check(G.direct(a, G.direction(a)) == a, "Wrong direction");
|
kpeter@171
|
200 |
}
|
kpeter@171
|
201 |
}
|
kpeter@171
|
202 |
|
deba@228
|
203 |
template <typename Graph>
|
deba@228
|
204 |
void checkNodeIds(const Graph& G) {
|
deba@1187
|
205 |
typedef typename Graph::Node Node;
|
deba@228
|
206 |
std::set<int> values;
|
deba@228
|
207 |
for (typename Graph::NodeIt n(G); n != INVALID; ++n) {
|
deba@228
|
208 |
check(G.nodeFromId(G.id(n)) == n, "Wrong id");
|
deba@228
|
209 |
check(values.find(G.id(n)) == values.end(), "Wrong id");
|
deba@228
|
210 |
check(G.id(n) <= G.maxNodeId(), "Wrong maximum id");
|
deba@228
|
211 |
values.insert(G.id(n));
|
kpeter@171
|
212 |
}
|
deba@1187
|
213 |
check(G.maxId(Node()) <= G.maxNodeId(), "Wrong maximum id");
|
deba@1187
|
214 |
}
|
deba@1187
|
215 |
|
deba@1187
|
216 |
template <typename Graph>
|
deba@1187
|
217 |
void checkRedNodeIds(const Graph& G) {
|
deba@1187
|
218 |
typedef typename Graph::RedNode RedNode;
|
deba@1187
|
219 |
std::set<int> values;
|
deba@1194
|
220 |
for (typename Graph::RedNodeIt n(G); n != INVALID; ++n) {
|
deba@1187
|
221 |
check(G.red(n), "Wrong partition");
|
deba@1193
|
222 |
check(values.find(G.id(n)) == values.end(), "Wrong id");
|
deba@1193
|
223 |
check(G.id(n) <= G.maxRedId(), "Wrong maximum id");
|
deba@1187
|
224 |
values.insert(G.id(n));
|
deba@1187
|
225 |
}
|
deba@1187
|
226 |
check(G.maxId(RedNode()) == G.maxRedId(), "Wrong maximum id");
|
deba@1187
|
227 |
}
|
deba@1187
|
228 |
|
deba@1187
|
229 |
template <typename Graph>
|
deba@1187
|
230 |
void checkBlueNodeIds(const Graph& G) {
|
deba@1187
|
231 |
typedef typename Graph::BlueNode BlueNode;
|
deba@1187
|
232 |
std::set<int> values;
|
deba@1194
|
233 |
for (typename Graph::BlueNodeIt n(G); n != INVALID; ++n) {
|
deba@1187
|
234 |
check(G.blue(n), "Wrong partition");
|
deba@1193
|
235 |
check(values.find(G.id(n)) == values.end(), "Wrong id");
|
deba@1193
|
236 |
check(G.id(n) <= G.maxBlueId(), "Wrong maximum id");
|
deba@1187
|
237 |
values.insert(G.id(n));
|
deba@1187
|
238 |
}
|
deba@1187
|
239 |
check(G.maxId(BlueNode()) == G.maxBlueId(), "Wrong maximum id");
|
kpeter@171
|
240 |
}
|
kpeter@171
|
241 |
|
deba@228
|
242 |
template <typename Graph>
|
deba@228
|
243 |
void checkArcIds(const Graph& G) {
|
deba@1187
|
244 |
typedef typename Graph::Arc Arc;
|
deba@228
|
245 |
std::set<int> values;
|
deba@228
|
246 |
for (typename Graph::ArcIt a(G); a != INVALID; ++a) {
|
deba@228
|
247 |
check(G.arcFromId(G.id(a)) == a, "Wrong id");
|
deba@228
|
248 |
check(values.find(G.id(a)) == values.end(), "Wrong id");
|
deba@228
|
249 |
check(G.id(a) <= G.maxArcId(), "Wrong maximum id");
|
deba@228
|
250 |
values.insert(G.id(a));
|
deba@228
|
251 |
}
|
deba@1187
|
252 |
check(G.maxId(Arc()) <= G.maxArcId(), "Wrong maximum id");
|
kpeter@171
|
253 |
}
|
alpar@209
|
254 |
|
deba@228
|
255 |
template <typename Graph>
|
deba@228
|
256 |
void checkEdgeIds(const Graph& G) {
|
deba@1187
|
257 |
typedef typename Graph::Edge Edge;
|
deba@228
|
258 |
std::set<int> values;
|
deba@228
|
259 |
for (typename Graph::EdgeIt e(G); e != INVALID; ++e) {
|
deba@228
|
260 |
check(G.edgeFromId(G.id(e)) == e, "Wrong id");
|
deba@228
|
261 |
check(values.find(G.id(e)) == values.end(), "Wrong id");
|
deba@228
|
262 |
check(G.id(e) <= G.maxEdgeId(), "Wrong maximum id");
|
deba@228
|
263 |
values.insert(G.id(e));
|
deba@228
|
264 |
}
|
deba@1187
|
265 |
check(G.maxId(Edge()) <= G.maxEdgeId(), "Wrong maximum id");
|
kpeter@171
|
266 |
}
|
kpeter@171
|
267 |
|
deba@228
|
268 |
template <typename Graph>
|
deba@228
|
269 |
void checkGraphNodeMap(const Graph& G) {
|
deba@228
|
270 |
typedef typename Graph::Node Node;
|
deba@228
|
271 |
typedef typename Graph::NodeIt NodeIt;
|
deba@228
|
272 |
|
deba@228
|
273 |
typedef typename Graph::template NodeMap<int> IntNodeMap;
|
deba@228
|
274 |
IntNodeMap map(G, 42);
|
deba@228
|
275 |
for (NodeIt it(G); it != INVALID; ++it) {
|
deba@228
|
276 |
check(map[it] == 42, "Wrong map constructor.");
|
deba@228
|
277 |
}
|
deba@228
|
278 |
int s = 0;
|
deba@228
|
279 |
for (NodeIt it(G); it != INVALID; ++it) {
|
deba@228
|
280 |
map[it] = 0;
|
deba@228
|
281 |
check(map[it] == 0, "Wrong operator[].");
|
deba@228
|
282 |
map.set(it, s);
|
deba@228
|
283 |
check(map[it] == s, "Wrong set.");
|
deba@228
|
284 |
++s;
|
deba@228
|
285 |
}
|
deba@228
|
286 |
s = s * (s - 1) / 2;
|
deba@228
|
287 |
for (NodeIt it(G); it != INVALID; ++it) {
|
deba@228
|
288 |
s -= map[it];
|
deba@228
|
289 |
}
|
deba@228
|
290 |
check(s == 0, "Wrong sum.");
|
deba@228
|
291 |
|
kpeter@263
|
292 |
// map = constMap<Node>(12);
|
kpeter@263
|
293 |
// for (NodeIt it(G); it != INVALID; ++it) {
|
kpeter@263
|
294 |
// check(map[it] == 12, "Wrong operator[].");
|
kpeter@263
|
295 |
// }
|
deba@228
|
296 |
}
|
deba@228
|
297 |
|
deba@228
|
298 |
template <typename Graph>
|
deba@1194
|
299 |
void checkGraphRedNodeMap(const Graph& G) {
|
deba@1187
|
300 |
typedef typename Graph::Node Node;
|
deba@1194
|
301 |
typedef typename Graph::RedNodeIt RedNodeIt;
|
deba@1187
|
302 |
|
deba@1194
|
303 |
typedef typename Graph::template RedNodeMap<int> IntRedNodeMap;
|
deba@1194
|
304 |
IntRedNodeMap map(G, 42);
|
deba@1194
|
305 |
for (RedNodeIt it(G); it != INVALID; ++it) {
|
deba@1187
|
306 |
check(map[it] == 42, "Wrong map constructor.");
|
deba@1187
|
307 |
}
|
deba@1187
|
308 |
int s = 0;
|
deba@1194
|
309 |
for (RedNodeIt it(G); it != INVALID; ++it) {
|
deba@1187
|
310 |
map[it] = 0;
|
deba@1187
|
311 |
check(map[it] == 0, "Wrong operator[].");
|
deba@1187
|
312 |
map.set(it, s);
|
deba@1187
|
313 |
check(map[it] == s, "Wrong set.");
|
deba@1187
|
314 |
++s;
|
deba@1187
|
315 |
}
|
deba@1187
|
316 |
s = s * (s - 1) / 2;
|
deba@1194
|
317 |
for (RedNodeIt it(G); it != INVALID; ++it) {
|
deba@1187
|
318 |
s -= map[it];
|
deba@1187
|
319 |
}
|
deba@1187
|
320 |
check(s == 0, "Wrong sum.");
|
deba@1187
|
321 |
|
deba@1187
|
322 |
// map = constMap<Node>(12);
|
deba@1187
|
323 |
// for (NodeIt it(G); it != INVALID; ++it) {
|
deba@1187
|
324 |
// check(map[it] == 12, "Wrong operator[].");
|
deba@1187
|
325 |
// }
|
deba@1187
|
326 |
}
|
deba@1187
|
327 |
|
deba@1187
|
328 |
template <typename Graph>
|
deba@1194
|
329 |
void checkGraphBlueNodeMap(const Graph& G) {
|
deba@1187
|
330 |
typedef typename Graph::Node Node;
|
deba@1194
|
331 |
typedef typename Graph::BlueNodeIt BlueNodeIt;
|
deba@1187
|
332 |
|
deba@1194
|
333 |
typedef typename Graph::template BlueNodeMap<int> IntBlueNodeMap;
|
deba@1194
|
334 |
IntBlueNodeMap map(G, 42);
|
deba@1194
|
335 |
for (BlueNodeIt it(G); it != INVALID; ++it) {
|
deba@1187
|
336 |
check(map[it] == 42, "Wrong map constructor.");
|
deba@1187
|
337 |
}
|
deba@1187
|
338 |
int s = 0;
|
deba@1194
|
339 |
for (BlueNodeIt it(G); it != INVALID; ++it) {
|
deba@1187
|
340 |
map[it] = 0;
|
deba@1187
|
341 |
check(map[it] == 0, "Wrong operator[].");
|
deba@1187
|
342 |
map.set(it, s);
|
deba@1187
|
343 |
check(map[it] == s, "Wrong set.");
|
deba@1187
|
344 |
++s;
|
deba@1187
|
345 |
}
|
deba@1187
|
346 |
s = s * (s - 1) / 2;
|
deba@1194
|
347 |
for (BlueNodeIt it(G); it != INVALID; ++it) {
|
deba@1187
|
348 |
s -= map[it];
|
deba@1187
|
349 |
}
|
deba@1187
|
350 |
check(s == 0, "Wrong sum.");
|
deba@1187
|
351 |
|
deba@1187
|
352 |
// map = constMap<Node>(12);
|
deba@1187
|
353 |
// for (NodeIt it(G); it != INVALID; ++it) {
|
deba@1187
|
354 |
// check(map[it] == 12, "Wrong operator[].");
|
deba@1187
|
355 |
// }
|
deba@1187
|
356 |
}
|
deba@1187
|
357 |
|
deba@1187
|
358 |
template <typename Graph>
|
deba@228
|
359 |
void checkGraphArcMap(const Graph& G) {
|
deba@228
|
360 |
typedef typename Graph::Arc Arc;
|
deba@228
|
361 |
typedef typename Graph::ArcIt ArcIt;
|
deba@228
|
362 |
|
deba@228
|
363 |
typedef typename Graph::template ArcMap<int> IntArcMap;
|
deba@228
|
364 |
IntArcMap map(G, 42);
|
deba@228
|
365 |
for (ArcIt it(G); it != INVALID; ++it) {
|
deba@228
|
366 |
check(map[it] == 42, "Wrong map constructor.");
|
deba@228
|
367 |
}
|
deba@228
|
368 |
int s = 0;
|
deba@228
|
369 |
for (ArcIt it(G); it != INVALID; ++it) {
|
deba@228
|
370 |
map[it] = 0;
|
deba@228
|
371 |
check(map[it] == 0, "Wrong operator[].");
|
deba@228
|
372 |
map.set(it, s);
|
deba@228
|
373 |
check(map[it] == s, "Wrong set.");
|
deba@228
|
374 |
++s;
|
deba@228
|
375 |
}
|
deba@228
|
376 |
s = s * (s - 1) / 2;
|
deba@228
|
377 |
for (ArcIt it(G); it != INVALID; ++it) {
|
deba@228
|
378 |
s -= map[it];
|
deba@228
|
379 |
}
|
deba@228
|
380 |
check(s == 0, "Wrong sum.");
|
deba@228
|
381 |
|
kpeter@263
|
382 |
// map = constMap<Arc>(12);
|
kpeter@263
|
383 |
// for (ArcIt it(G); it != INVALID; ++it) {
|
kpeter@263
|
384 |
// check(map[it] == 12, "Wrong operator[].");
|
kpeter@263
|
385 |
// }
|
deba@228
|
386 |
}
|
deba@228
|
387 |
|
deba@228
|
388 |
template <typename Graph>
|
deba@228
|
389 |
void checkGraphEdgeMap(const Graph& G) {
|
deba@228
|
390 |
typedef typename Graph::Edge Edge;
|
deba@228
|
391 |
typedef typename Graph::EdgeIt EdgeIt;
|
deba@228
|
392 |
|
deba@228
|
393 |
typedef typename Graph::template EdgeMap<int> IntEdgeMap;
|
deba@228
|
394 |
IntEdgeMap map(G, 42);
|
deba@228
|
395 |
for (EdgeIt it(G); it != INVALID; ++it) {
|
deba@228
|
396 |
check(map[it] == 42, "Wrong map constructor.");
|
deba@228
|
397 |
}
|
deba@228
|
398 |
int s = 0;
|
deba@228
|
399 |
for (EdgeIt it(G); it != INVALID; ++it) {
|
deba@228
|
400 |
map[it] = 0;
|
deba@228
|
401 |
check(map[it] == 0, "Wrong operator[].");
|
deba@228
|
402 |
map.set(it, s);
|
deba@228
|
403 |
check(map[it] == s, "Wrong set.");
|
deba@228
|
404 |
++s;
|
deba@228
|
405 |
}
|
deba@228
|
406 |
s = s * (s - 1) / 2;
|
deba@228
|
407 |
for (EdgeIt it(G); it != INVALID; ++it) {
|
deba@228
|
408 |
s -= map[it];
|
deba@228
|
409 |
}
|
deba@228
|
410 |
check(s == 0, "Wrong sum.");
|
deba@228
|
411 |
|
kpeter@263
|
412 |
// map = constMap<Edge>(12);
|
kpeter@263
|
413 |
// for (EdgeIt it(G); it != INVALID; ++it) {
|
kpeter@263
|
414 |
// check(map[it] == 12, "Wrong operator[].");
|
kpeter@263
|
415 |
// }
|
deba@228
|
416 |
}
|
deba@228
|
417 |
|
deba@228
|
418 |
|
kpeter@171
|
419 |
} //namespace lemon
|
kpeter@171
|
420 |
|
kpeter@171
|
421 |
#endif
|