alpar@209
|
1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*-
|
deba@200
|
2 |
*
|
alpar@209
|
3 |
* This file is a part of LEMON, a generic C++ optimization library.
|
deba@200
|
4 |
*
|
alpar@463
|
5 |
* Copyright (C) 2003-2009
|
deba@200
|
6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
|
deba@200
|
7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES).
|
deba@200
|
8 |
*
|
deba@200
|
9 |
* Permission to use, modify and distribute this software is granted
|
deba@200
|
10 |
* provided that this copyright notice appears in all copies. For
|
deba@200
|
11 |
* precise terms see the accompanying LICENSE file.
|
deba@200
|
12 |
*
|
deba@200
|
13 |
* This software is provided "AS IS" with no warranty of any kind,
|
deba@200
|
14 |
* express or implied, and with no claim as to its suitability for any
|
deba@200
|
15 |
* purpose.
|
deba@200
|
16 |
*
|
deba@200
|
17 |
*/
|
deba@200
|
18 |
|
deba@200
|
19 |
#include <lemon/smart_graph.h>
|
deba@200
|
20 |
#include <lemon/list_graph.h>
|
kpeter@989
|
21 |
#include <lemon/static_graph.h>
|
deba@200
|
22 |
#include <lemon/lgf_reader.h>
|
deba@200
|
23 |
#include <lemon/error.h>
|
deba@200
|
24 |
|
deba@200
|
25 |
#include "test_tools.h"
|
deba@200
|
26 |
|
deba@200
|
27 |
using namespace std;
|
deba@200
|
28 |
using namespace lemon;
|
deba@200
|
29 |
|
kpeter@989
|
30 |
template <typename GR>
|
deba@200
|
31 |
void digraph_copy_test() {
|
deba@200
|
32 |
const int nn = 10;
|
deba@200
|
33 |
|
kpeter@980
|
34 |
// Build a digraph
|
deba@200
|
35 |
SmartDigraph from;
|
deba@200
|
36 |
SmartDigraph::NodeMap<int> fnm(from);
|
deba@200
|
37 |
SmartDigraph::ArcMap<int> fam(from);
|
deba@200
|
38 |
SmartDigraph::Node fn = INVALID;
|
deba@200
|
39 |
SmartDigraph::Arc fa = INVALID;
|
deba@200
|
40 |
|
deba@200
|
41 |
std::vector<SmartDigraph::Node> fnv;
|
deba@200
|
42 |
for (int i = 0; i < nn; ++i) {
|
deba@200
|
43 |
SmartDigraph::Node node = from.addNode();
|
deba@200
|
44 |
fnv.push_back(node);
|
deba@200
|
45 |
fnm[node] = i * i;
|
deba@200
|
46 |
if (i == 0) fn = node;
|
deba@200
|
47 |
}
|
deba@200
|
48 |
|
deba@200
|
49 |
for (int i = 0; i < nn; ++i) {
|
deba@200
|
50 |
for (int j = 0; j < nn; ++j) {
|
deba@200
|
51 |
SmartDigraph::Arc arc = from.addArc(fnv[i], fnv[j]);
|
deba@200
|
52 |
fam[arc] = i + j * j;
|
deba@200
|
53 |
if (i == 0 && j == 0) fa = arc;
|
deba@200
|
54 |
}
|
deba@200
|
55 |
}
|
kpeter@989
|
56 |
|
kpeter@989
|
57 |
// Test digraph copy
|
kpeter@989
|
58 |
GR to;
|
kpeter@989
|
59 |
typename GR::template NodeMap<int> tnm(to);
|
kpeter@989
|
60 |
typename GR::template ArcMap<int> tam(to);
|
kpeter@989
|
61 |
typename GR::Node tn;
|
kpeter@989
|
62 |
typename GR::Arc ta;
|
deba@200
|
63 |
|
kpeter@989
|
64 |
SmartDigraph::NodeMap<typename GR::Node> nr(from);
|
kpeter@989
|
65 |
SmartDigraph::ArcMap<typename GR::Arc> er(from);
|
deba@200
|
66 |
|
kpeter@989
|
67 |
typename GR::template NodeMap<SmartDigraph::Node> ncr(to);
|
kpeter@989
|
68 |
typename GR::template ArcMap<SmartDigraph::Arc> ecr(to);
|
deba@200
|
69 |
|
kpeter@282
|
70 |
digraphCopy(from, to).
|
kpeter@282
|
71 |
nodeMap(fnm, tnm).arcMap(fam, tam).
|
deba@200
|
72 |
nodeRef(nr).arcRef(er).
|
deba@200
|
73 |
nodeCrossRef(ncr).arcCrossRef(ecr).
|
kpeter@282
|
74 |
node(fn, tn).arc(fa, ta).run();
|
kpeter@980
|
75 |
|
kpeter@980
|
76 |
check(countNodes(from) == countNodes(to), "Wrong copy.");
|
kpeter@980
|
77 |
check(countArcs(from) == countArcs(to), "Wrong copy.");
|
deba@200
|
78 |
|
deba@200
|
79 |
for (SmartDigraph::NodeIt it(from); it != INVALID; ++it) {
|
deba@200
|
80 |
check(ncr[nr[it]] == it, "Wrong copy.");
|
deba@200
|
81 |
check(fnm[it] == tnm[nr[it]], "Wrong copy.");
|
deba@200
|
82 |
}
|
deba@200
|
83 |
|
deba@200
|
84 |
for (SmartDigraph::ArcIt it(from); it != INVALID; ++it) {
|
deba@200
|
85 |
check(ecr[er[it]] == it, "Wrong copy.");
|
deba@200
|
86 |
check(fam[it] == tam[er[it]], "Wrong copy.");
|
deba@200
|
87 |
check(nr[from.source(it)] == to.source(er[it]), "Wrong copy.");
|
deba@200
|
88 |
check(nr[from.target(it)] == to.target(er[it]), "Wrong copy.");
|
deba@200
|
89 |
}
|
deba@200
|
90 |
|
kpeter@989
|
91 |
for (typename GR::NodeIt it(to); it != INVALID; ++it) {
|
deba@200
|
92 |
check(nr[ncr[it]] == it, "Wrong copy.");
|
deba@200
|
93 |
}
|
deba@200
|
94 |
|
kpeter@989
|
95 |
for (typename GR::ArcIt it(to); it != INVALID; ++it) {
|
deba@200
|
96 |
check(er[ecr[it]] == it, "Wrong copy.");
|
deba@200
|
97 |
}
|
deba@200
|
98 |
check(tn == nr[fn], "Wrong copy.");
|
deba@200
|
99 |
check(ta == er[fa], "Wrong copy.");
|
kpeter@980
|
100 |
|
kpeter@980
|
101 |
// Test repeated copy
|
kpeter@980
|
102 |
digraphCopy(from, to).run();
|
kpeter@980
|
103 |
|
kpeter@980
|
104 |
check(countNodes(from) == countNodes(to), "Wrong copy.");
|
kpeter@980
|
105 |
check(countArcs(from) == countArcs(to), "Wrong copy.");
|
deba@200
|
106 |
}
|
deba@200
|
107 |
|
kpeter@989
|
108 |
template <typename GR>
|
deba@200
|
109 |
void graph_copy_test() {
|
deba@200
|
110 |
const int nn = 10;
|
deba@200
|
111 |
|
kpeter@980
|
112 |
// Build a graph
|
deba@200
|
113 |
SmartGraph from;
|
deba@200
|
114 |
SmartGraph::NodeMap<int> fnm(from);
|
deba@200
|
115 |
SmartGraph::ArcMap<int> fam(from);
|
deba@200
|
116 |
SmartGraph::EdgeMap<int> fem(from);
|
deba@200
|
117 |
SmartGraph::Node fn = INVALID;
|
deba@200
|
118 |
SmartGraph::Arc fa = INVALID;
|
deba@200
|
119 |
SmartGraph::Edge fe = INVALID;
|
deba@200
|
120 |
|
deba@200
|
121 |
std::vector<SmartGraph::Node> fnv;
|
deba@200
|
122 |
for (int i = 0; i < nn; ++i) {
|
deba@200
|
123 |
SmartGraph::Node node = from.addNode();
|
deba@200
|
124 |
fnv.push_back(node);
|
deba@200
|
125 |
fnm[node] = i * i;
|
deba@200
|
126 |
if (i == 0) fn = node;
|
deba@200
|
127 |
}
|
deba@200
|
128 |
|
deba@200
|
129 |
for (int i = 0; i < nn; ++i) {
|
deba@200
|
130 |
for (int j = 0; j < nn; ++j) {
|
deba@200
|
131 |
SmartGraph::Edge edge = from.addEdge(fnv[i], fnv[j]);
|
deba@200
|
132 |
fem[edge] = i * i + j * j;
|
deba@200
|
133 |
fam[from.direct(edge, true)] = i + j * j;
|
deba@200
|
134 |
fam[from.direct(edge, false)] = i * i + j;
|
deba@200
|
135 |
if (i == 0 && j == 0) fa = from.direct(edge, true);
|
deba@200
|
136 |
if (i == 0 && j == 0) fe = edge;
|
deba@200
|
137 |
}
|
deba@200
|
138 |
}
|
alpar@209
|
139 |
|
kpeter@980
|
140 |
// Test graph copy
|
kpeter@989
|
141 |
GR to;
|
kpeter@989
|
142 |
typename GR::template NodeMap<int> tnm(to);
|
kpeter@989
|
143 |
typename GR::template ArcMap<int> tam(to);
|
kpeter@989
|
144 |
typename GR::template EdgeMap<int> tem(to);
|
kpeter@989
|
145 |
typename GR::Node tn;
|
kpeter@989
|
146 |
typename GR::Arc ta;
|
kpeter@989
|
147 |
typename GR::Edge te;
|
deba@200
|
148 |
|
kpeter@989
|
149 |
SmartGraph::NodeMap<typename GR::Node> nr(from);
|
kpeter@989
|
150 |
SmartGraph::ArcMap<typename GR::Arc> ar(from);
|
kpeter@989
|
151 |
SmartGraph::EdgeMap<typename GR::Edge> er(from);
|
deba@200
|
152 |
|
kpeter@989
|
153 |
typename GR::template NodeMap<SmartGraph::Node> ncr(to);
|
kpeter@989
|
154 |
typename GR::template ArcMap<SmartGraph::Arc> acr(to);
|
kpeter@989
|
155 |
typename GR::template EdgeMap<SmartGraph::Edge> ecr(to);
|
deba@200
|
156 |
|
kpeter@282
|
157 |
graphCopy(from, to).
|
kpeter@282
|
158 |
nodeMap(fnm, tnm).arcMap(fam, tam).edgeMap(fem, tem).
|
deba@200
|
159 |
nodeRef(nr).arcRef(ar).edgeRef(er).
|
deba@200
|
160 |
nodeCrossRef(ncr).arcCrossRef(acr).edgeCrossRef(ecr).
|
kpeter@282
|
161 |
node(fn, tn).arc(fa, ta).edge(fe, te).run();
|
deba@200
|
162 |
|
kpeter@980
|
163 |
check(countNodes(from) == countNodes(to), "Wrong copy.");
|
kpeter@980
|
164 |
check(countEdges(from) == countEdges(to), "Wrong copy.");
|
kpeter@980
|
165 |
check(countArcs(from) == countArcs(to), "Wrong copy.");
|
kpeter@980
|
166 |
|
deba@200
|
167 |
for (SmartGraph::NodeIt it(from); it != INVALID; ++it) {
|
deba@200
|
168 |
check(ncr[nr[it]] == it, "Wrong copy.");
|
deba@200
|
169 |
check(fnm[it] == tnm[nr[it]], "Wrong copy.");
|
deba@200
|
170 |
}
|
deba@200
|
171 |
|
deba@200
|
172 |
for (SmartGraph::ArcIt it(from); it != INVALID; ++it) {
|
deba@200
|
173 |
check(acr[ar[it]] == it, "Wrong copy.");
|
deba@200
|
174 |
check(fam[it] == tam[ar[it]], "Wrong copy.");
|
deba@200
|
175 |
check(nr[from.source(it)] == to.source(ar[it]), "Wrong copy.");
|
deba@200
|
176 |
check(nr[from.target(it)] == to.target(ar[it]), "Wrong copy.");
|
deba@200
|
177 |
}
|
deba@200
|
178 |
|
deba@200
|
179 |
for (SmartGraph::EdgeIt it(from); it != INVALID; ++it) {
|
deba@200
|
180 |
check(ecr[er[it]] == it, "Wrong copy.");
|
deba@200
|
181 |
check(fem[it] == tem[er[it]], "Wrong copy.");
|
alpar@209
|
182 |
check(nr[from.u(it)] == to.u(er[it]) || nr[from.u(it)] == to.v(er[it]),
|
alpar@209
|
183 |
"Wrong copy.");
|
alpar@209
|
184 |
check(nr[from.v(it)] == to.u(er[it]) || nr[from.v(it)] == to.v(er[it]),
|
alpar@209
|
185 |
"Wrong copy.");
|
alpar@209
|
186 |
check((from.u(it) != from.v(it)) == (to.u(er[it]) != to.v(er[it])),
|
alpar@209
|
187 |
"Wrong copy.");
|
deba@200
|
188 |
}
|
deba@200
|
189 |
|
kpeter@989
|
190 |
for (typename GR::NodeIt it(to); it != INVALID; ++it) {
|
deba@200
|
191 |
check(nr[ncr[it]] == it, "Wrong copy.");
|
deba@200
|
192 |
}
|
deba@200
|
193 |
|
kpeter@989
|
194 |
for (typename GR::ArcIt it(to); it != INVALID; ++it) {
|
deba@200
|
195 |
check(ar[acr[it]] == it, "Wrong copy.");
|
deba@200
|
196 |
}
|
kpeter@989
|
197 |
for (typename GR::EdgeIt it(to); it != INVALID; ++it) {
|
deba@200
|
198 |
check(er[ecr[it]] == it, "Wrong copy.");
|
deba@200
|
199 |
}
|
deba@200
|
200 |
check(tn == nr[fn], "Wrong copy.");
|
deba@200
|
201 |
check(ta == ar[fa], "Wrong copy.");
|
deba@200
|
202 |
check(te == er[fe], "Wrong copy.");
|
kpeter@980
|
203 |
|
kpeter@980
|
204 |
// Test repeated copy
|
kpeter@980
|
205 |
graphCopy(from, to).run();
|
kpeter@980
|
206 |
|
kpeter@980
|
207 |
check(countNodes(from) == countNodes(to), "Wrong copy.");
|
kpeter@980
|
208 |
check(countEdges(from) == countEdges(to), "Wrong copy.");
|
kpeter@980
|
209 |
check(countArcs(from) == countArcs(to), "Wrong copy.");
|
deba@200
|
210 |
}
|
deba@200
|
211 |
|
deba@1190
|
212 |
template <typename GR>
|
deba@1190
|
213 |
void bpgraph_copy_test() {
|
deba@1190
|
214 |
const int nn = 10;
|
deba@1190
|
215 |
|
deba@1190
|
216 |
// Build a graph
|
deba@1190
|
217 |
SmartBpGraph from;
|
deba@1190
|
218 |
SmartBpGraph::NodeMap<int> fnm(from);
|
deba@1194
|
219 |
SmartBpGraph::RedNodeMap<int> frnm(from);
|
deba@1194
|
220 |
SmartBpGraph::BlueNodeMap<int> fbnm(from);
|
deba@1190
|
221 |
SmartBpGraph::ArcMap<int> fam(from);
|
deba@1190
|
222 |
SmartBpGraph::EdgeMap<int> fem(from);
|
deba@1190
|
223 |
SmartBpGraph::Node fn = INVALID;
|
deba@1193
|
224 |
SmartBpGraph::RedNode frn = INVALID;
|
deba@1193
|
225 |
SmartBpGraph::BlueNode fbn = INVALID;
|
deba@1190
|
226 |
SmartBpGraph::Arc fa = INVALID;
|
deba@1190
|
227 |
SmartBpGraph::Edge fe = INVALID;
|
deba@1190
|
228 |
|
deba@1193
|
229 |
std::vector<SmartBpGraph::RedNode> frnv;
|
deba@1190
|
230 |
for (int i = 0; i < nn; ++i) {
|
deba@1193
|
231 |
SmartBpGraph::RedNode node = from.addRedNode();
|
deba@1190
|
232 |
frnv.push_back(node);
|
deba@1190
|
233 |
fnm[node] = i * i;
|
deba@1190
|
234 |
frnm[node] = i + i;
|
deba@1193
|
235 |
if (i == 0) {
|
deba@1193
|
236 |
fn = node;
|
deba@1193
|
237 |
frn = node;
|
deba@1193
|
238 |
}
|
deba@1190
|
239 |
}
|
deba@1190
|
240 |
|
deba@1193
|
241 |
std::vector<SmartBpGraph::BlueNode> fbnv;
|
deba@1190
|
242 |
for (int i = 0; i < nn; ++i) {
|
deba@1193
|
243 |
SmartBpGraph::BlueNode node = from.addBlueNode();
|
deba@1190
|
244 |
fbnv.push_back(node);
|
deba@1190
|
245 |
fnm[node] = i * i;
|
deba@1190
|
246 |
fbnm[node] = i + i;
|
deba@1193
|
247 |
if (i == 0) fbn = node;
|
deba@1190
|
248 |
}
|
deba@1190
|
249 |
|
deba@1190
|
250 |
for (int i = 0; i < nn; ++i) {
|
deba@1190
|
251 |
for (int j = 0; j < nn; ++j) {
|
deba@1190
|
252 |
SmartBpGraph::Edge edge = from.addEdge(frnv[i], fbnv[j]);
|
deba@1190
|
253 |
fem[edge] = i * i + j * j;
|
deba@1190
|
254 |
fam[from.direct(edge, true)] = i + j * j;
|
deba@1190
|
255 |
fam[from.direct(edge, false)] = i * i + j;
|
deba@1190
|
256 |
if (i == 0 && j == 0) fa = from.direct(edge, true);
|
deba@1190
|
257 |
if (i == 0 && j == 0) fe = edge;
|
deba@1190
|
258 |
}
|
deba@1190
|
259 |
}
|
deba@1190
|
260 |
|
deba@1190
|
261 |
// Test graph copy
|
deba@1190
|
262 |
GR to;
|
deba@1190
|
263 |
typename GR::template NodeMap<int> tnm(to);
|
deba@1194
|
264 |
typename GR::template RedNodeMap<int> trnm(to);
|
deba@1194
|
265 |
typename GR::template BlueNodeMap<int> tbnm(to);
|
deba@1190
|
266 |
typename GR::template ArcMap<int> tam(to);
|
deba@1190
|
267 |
typename GR::template EdgeMap<int> tem(to);
|
deba@1190
|
268 |
typename GR::Node tn;
|
deba@1193
|
269 |
typename GR::RedNode trn;
|
deba@1193
|
270 |
typename GR::BlueNode tbn;
|
deba@1190
|
271 |
typename GR::Arc ta;
|
deba@1190
|
272 |
typename GR::Edge te;
|
deba@1190
|
273 |
|
deba@1190
|
274 |
SmartBpGraph::NodeMap<typename GR::Node> nr(from);
|
deba@1194
|
275 |
SmartBpGraph::RedNodeMap<typename GR::RedNode> rnr(from);
|
deba@1194
|
276 |
SmartBpGraph::BlueNodeMap<typename GR::BlueNode> bnr(from);
|
deba@1190
|
277 |
SmartBpGraph::ArcMap<typename GR::Arc> ar(from);
|
deba@1190
|
278 |
SmartBpGraph::EdgeMap<typename GR::Edge> er(from);
|
deba@1190
|
279 |
|
deba@1190
|
280 |
typename GR::template NodeMap<SmartBpGraph::Node> ncr(to);
|
deba@1194
|
281 |
typename GR::template RedNodeMap<SmartBpGraph::RedNode> rncr(to);
|
deba@1194
|
282 |
typename GR::template BlueNodeMap<SmartBpGraph::BlueNode> bncr(to);
|
deba@1190
|
283 |
typename GR::template ArcMap<SmartBpGraph::Arc> acr(to);
|
deba@1190
|
284 |
typename GR::template EdgeMap<SmartBpGraph::Edge> ecr(to);
|
deba@1190
|
285 |
|
deba@1190
|
286 |
bpGraphCopy(from, to).
|
deba@1194
|
287 |
nodeMap(fnm, tnm).
|
deba@1194
|
288 |
redNodeMap(frnm, trnm).blueNodeMap(fbnm, tbnm).
|
deba@1190
|
289 |
arcMap(fam, tam).edgeMap(fem, tem).
|
deba@1190
|
290 |
nodeRef(nr).redRef(rnr).blueRef(bnr).
|
deba@1190
|
291 |
arcRef(ar).edgeRef(er).
|
deba@1190
|
292 |
nodeCrossRef(ncr).redCrossRef(rncr).blueCrossRef(bncr).
|
deba@1190
|
293 |
arcCrossRef(acr).edgeCrossRef(ecr).
|
deba@1193
|
294 |
node(fn, tn).redNode(frn, trn).blueNode(fbn, tbn).
|
deba@1193
|
295 |
arc(fa, ta).edge(fe, te).run();
|
deba@1190
|
296 |
|
deba@1190
|
297 |
check(countNodes(from) == countNodes(to), "Wrong copy.");
|
deba@1190
|
298 |
check(countRedNodes(from) == countRedNodes(to), "Wrong copy.");
|
deba@1190
|
299 |
check(countBlueNodes(from) == countBlueNodes(to), "Wrong copy.");
|
deba@1190
|
300 |
check(countEdges(from) == countEdges(to), "Wrong copy.");
|
deba@1190
|
301 |
check(countArcs(from) == countArcs(to), "Wrong copy.");
|
deba@1190
|
302 |
|
deba@1190
|
303 |
for (SmartBpGraph::NodeIt it(from); it != INVALID; ++it) {
|
deba@1190
|
304 |
check(ncr[nr[it]] == it, "Wrong copy.");
|
deba@1190
|
305 |
check(fnm[it] == tnm[nr[it]], "Wrong copy.");
|
deba@1193
|
306 |
}
|
deba@1193
|
307 |
|
deba@1194
|
308 |
for (SmartBpGraph::RedNodeIt it(from); it != INVALID; ++it) {
|
deba@1193
|
309 |
check(ncr[nr[it]] == it, "Wrong copy.");
|
deba@1193
|
310 |
check(fnm[it] == tnm[nr[it]], "Wrong copy.");
|
deba@1193
|
311 |
check(rnr[it] == nr[it], "Wrong copy.");
|
deba@1193
|
312 |
check(rncr[rnr[it]] == it, "Wrong copy.");
|
deba@1193
|
313 |
check(frnm[it] == trnm[rnr[it]], "Wrong copy.");
|
deba@1193
|
314 |
check(to.red(rnr[it]), "Wrong copy.");
|
deba@1193
|
315 |
}
|
deba@1193
|
316 |
|
deba@1194
|
317 |
for (SmartBpGraph::BlueNodeIt it(from); it != INVALID; ++it) {
|
deba@1193
|
318 |
check(ncr[nr[it]] == it, "Wrong copy.");
|
deba@1193
|
319 |
check(fnm[it] == tnm[nr[it]], "Wrong copy.");
|
deba@1193
|
320 |
check(bnr[it] == nr[it], "Wrong copy.");
|
deba@1193
|
321 |
check(bncr[bnr[it]] == it, "Wrong copy.");
|
deba@1193
|
322 |
check(fbnm[it] == tbnm[bnr[it]], "Wrong copy.");
|
deba@1193
|
323 |
check(to.blue(bnr[it]), "Wrong copy.");
|
deba@1190
|
324 |
}
|
deba@1190
|
325 |
|
deba@1190
|
326 |
for (SmartBpGraph::ArcIt it(from); it != INVALID; ++it) {
|
deba@1190
|
327 |
check(acr[ar[it]] == it, "Wrong copy.");
|
deba@1190
|
328 |
check(fam[it] == tam[ar[it]], "Wrong copy.");
|
deba@1190
|
329 |
check(nr[from.source(it)] == to.source(ar[it]), "Wrong copy.");
|
deba@1190
|
330 |
check(nr[from.target(it)] == to.target(ar[it]), "Wrong copy.");
|
deba@1190
|
331 |
}
|
deba@1190
|
332 |
|
deba@1190
|
333 |
for (SmartBpGraph::EdgeIt it(from); it != INVALID; ++it) {
|
deba@1190
|
334 |
check(ecr[er[it]] == it, "Wrong copy.");
|
deba@1190
|
335 |
check(fem[it] == tem[er[it]], "Wrong copy.");
|
deba@1190
|
336 |
check(nr[from.u(it)] == to.u(er[it]) || nr[from.u(it)] == to.v(er[it]),
|
deba@1190
|
337 |
"Wrong copy.");
|
deba@1190
|
338 |
check(nr[from.v(it)] == to.u(er[it]) || nr[from.v(it)] == to.v(er[it]),
|
deba@1190
|
339 |
"Wrong copy.");
|
deba@1190
|
340 |
check((from.u(it) != from.v(it)) == (to.u(er[it]) != to.v(er[it])),
|
deba@1190
|
341 |
"Wrong copy.");
|
deba@1190
|
342 |
}
|
deba@1190
|
343 |
|
deba@1190
|
344 |
for (typename GR::NodeIt it(to); it != INVALID; ++it) {
|
deba@1190
|
345 |
check(nr[ncr[it]] == it, "Wrong copy.");
|
deba@1190
|
346 |
}
|
deba@1194
|
347 |
for (typename GR::RedNodeIt it(to); it != INVALID; ++it) {
|
deba@1190
|
348 |
check(rncr[it] == ncr[it], "Wrong copy.");
|
deba@1190
|
349 |
check(rnr[rncr[it]] == it, "Wrong copy.");
|
deba@1190
|
350 |
}
|
deba@1194
|
351 |
for (typename GR::BlueNodeIt it(to); it != INVALID; ++it) {
|
deba@1190
|
352 |
check(bncr[it] == ncr[it], "Wrong copy.");
|
deba@1190
|
353 |
check(bnr[bncr[it]] == it, "Wrong copy.");
|
deba@1190
|
354 |
}
|
deba@1190
|
355 |
for (typename GR::ArcIt it(to); it != INVALID; ++it) {
|
deba@1190
|
356 |
check(ar[acr[it]] == it, "Wrong copy.");
|
deba@1190
|
357 |
}
|
deba@1190
|
358 |
for (typename GR::EdgeIt it(to); it != INVALID; ++it) {
|
deba@1190
|
359 |
check(er[ecr[it]] == it, "Wrong copy.");
|
deba@1190
|
360 |
}
|
deba@1190
|
361 |
check(tn == nr[fn], "Wrong copy.");
|
deba@1193
|
362 |
check(trn == rnr[frn], "Wrong copy.");
|
deba@1193
|
363 |
check(tbn == bnr[fbn], "Wrong copy.");
|
deba@1190
|
364 |
check(ta == ar[fa], "Wrong copy.");
|
deba@1190
|
365 |
check(te == er[fe], "Wrong copy.");
|
deba@1190
|
366 |
|
deba@1190
|
367 |
// Test repeated copy
|
deba@1190
|
368 |
bpGraphCopy(from, to).run();
|
deba@1190
|
369 |
|
deba@1190
|
370 |
check(countNodes(from) == countNodes(to), "Wrong copy.");
|
deba@1190
|
371 |
check(countRedNodes(from) == countRedNodes(to), "Wrong copy.");
|
deba@1190
|
372 |
check(countBlueNodes(from) == countBlueNodes(to), "Wrong copy.");
|
deba@1190
|
373 |
check(countEdges(from) == countEdges(to), "Wrong copy.");
|
deba@1190
|
374 |
check(countArcs(from) == countArcs(to), "Wrong copy.");
|
deba@1190
|
375 |
}
|
deba@1190
|
376 |
|
deba@200
|
377 |
|
deba@200
|
378 |
int main() {
|
kpeter@989
|
379 |
digraph_copy_test<SmartDigraph>();
|
kpeter@989
|
380 |
digraph_copy_test<ListDigraph>();
|
kpeter@989
|
381 |
digraph_copy_test<StaticDigraph>();
|
kpeter@989
|
382 |
graph_copy_test<SmartGraph>();
|
kpeter@989
|
383 |
graph_copy_test<ListGraph>();
|
deba@1190
|
384 |
bpgraph_copy_test<SmartBpGraph>();
|
deba@1190
|
385 |
bpgraph_copy_test<ListBpGraph>();
|
deba@200
|
386 |
|
alpar@209
|
387 |
return 0;
|
deba@200
|
388 |
}
|