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@1092
|
5 |
* Copyright (C) 2003-2013
|
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@894
|
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@894
|
30 |
template <typename GR>
|
deba@200
|
31 |
void digraph_copy_test() {
|
deba@200
|
32 |
const int nn = 10;
|
deba@200
|
33 |
|
kpeter@890
|
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 |
}
|
alpar@1092
|
56 |
|
kpeter@894
|
57 |
// Test digraph copy
|
kpeter@894
|
58 |
GR to;
|
kpeter@894
|
59 |
typename GR::template NodeMap<int> tnm(to);
|
kpeter@894
|
60 |
typename GR::template ArcMap<int> tam(to);
|
kpeter@894
|
61 |
typename GR::Node tn;
|
kpeter@894
|
62 |
typename GR::Arc ta;
|
deba@200
|
63 |
|
kpeter@894
|
64 |
SmartDigraph::NodeMap<typename GR::Node> nr(from);
|
kpeter@894
|
65 |
SmartDigraph::ArcMap<typename GR::Arc> er(from);
|
deba@200
|
66 |
|
kpeter@894
|
67 |
typename GR::template NodeMap<SmartDigraph::Node> ncr(to);
|
kpeter@894
|
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();
|
alpar@1092
|
75 |
|
kpeter@890
|
76 |
check(countNodes(from) == countNodes(to), "Wrong copy.");
|
kpeter@890
|
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@894
|
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@894
|
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@890
|
100 |
|
kpeter@890
|
101 |
// Test repeated copy
|
kpeter@890
|
102 |
digraphCopy(from, to).run();
|
alpar@1092
|
103 |
|
kpeter@890
|
104 |
check(countNodes(from) == countNodes(to), "Wrong copy.");
|
kpeter@890
|
105 |
check(countArcs(from) == countArcs(to), "Wrong copy.");
|
deba@200
|
106 |
}
|
deba@200
|
107 |
|
kpeter@894
|
108 |
template <typename GR>
|
deba@200
|
109 |
void graph_copy_test() {
|
deba@200
|
110 |
const int nn = 10;
|
deba@200
|
111 |
|
kpeter@890
|
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@890
|
140 |
// Test graph copy
|
kpeter@894
|
141 |
GR to;
|
kpeter@894
|
142 |
typename GR::template NodeMap<int> tnm(to);
|
kpeter@894
|
143 |
typename GR::template ArcMap<int> tam(to);
|
kpeter@894
|
144 |
typename GR::template EdgeMap<int> tem(to);
|
kpeter@894
|
145 |
typename GR::Node tn;
|
kpeter@894
|
146 |
typename GR::Arc ta;
|
kpeter@894
|
147 |
typename GR::Edge te;
|
deba@200
|
148 |
|
kpeter@894
|
149 |
SmartGraph::NodeMap<typename GR::Node> nr(from);
|
kpeter@894
|
150 |
SmartGraph::ArcMap<typename GR::Arc> ar(from);
|
kpeter@894
|
151 |
SmartGraph::EdgeMap<typename GR::Edge> er(from);
|
deba@200
|
152 |
|
kpeter@894
|
153 |
typename GR::template NodeMap<SmartGraph::Node> ncr(to);
|
kpeter@894
|
154 |
typename GR::template ArcMap<SmartGraph::Arc> acr(to);
|
kpeter@894
|
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@890
|
163 |
check(countNodes(from) == countNodes(to), "Wrong copy.");
|
kpeter@890
|
164 |
check(countEdges(from) == countEdges(to), "Wrong copy.");
|
kpeter@890
|
165 |
check(countArcs(from) == countArcs(to), "Wrong copy.");
|
kpeter@890
|
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@894
|
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@894
|
194 |
for (typename GR::ArcIt it(to); it != INVALID; ++it) {
|
deba@200
|
195 |
check(ar[acr[it]] == it, "Wrong copy.");
|
deba@200
|
196 |
}
|
kpeter@894
|
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@890
|
203 |
|
kpeter@890
|
204 |
// Test repeated copy
|
kpeter@890
|
205 |
graphCopy(from, to).run();
|
alpar@1092
|
206 |
|
kpeter@890
|
207 |
check(countNodes(from) == countNodes(to), "Wrong copy.");
|
kpeter@890
|
208 |
check(countEdges(from) == countEdges(to), "Wrong copy.");
|
kpeter@890
|
209 |
check(countArcs(from) == countArcs(to), "Wrong copy.");
|
deba@200
|
210 |
}
|
deba@200
|
211 |
|
deba@1022
|
212 |
template <typename GR>
|
deba@1022
|
213 |
void bpgraph_copy_test() {
|
deba@1022
|
214 |
const int nn = 10;
|
deba@1022
|
215 |
|
deba@1022
|
216 |
// Build a graph
|
deba@1022
|
217 |
SmartBpGraph from;
|
deba@1022
|
218 |
SmartBpGraph::NodeMap<int> fnm(from);
|
deba@1026
|
219 |
SmartBpGraph::RedNodeMap<int> frnm(from);
|
deba@1026
|
220 |
SmartBpGraph::BlueNodeMap<int> fbnm(from);
|
deba@1022
|
221 |
SmartBpGraph::ArcMap<int> fam(from);
|
deba@1022
|
222 |
SmartBpGraph::EdgeMap<int> fem(from);
|
deba@1022
|
223 |
SmartBpGraph::Node fn = INVALID;
|
deba@1025
|
224 |
SmartBpGraph::RedNode frn = INVALID;
|
deba@1025
|
225 |
SmartBpGraph::BlueNode fbn = INVALID;
|
deba@1022
|
226 |
SmartBpGraph::Arc fa = INVALID;
|
deba@1022
|
227 |
SmartBpGraph::Edge fe = INVALID;
|
deba@1022
|
228 |
|
deba@1025
|
229 |
std::vector<SmartBpGraph::RedNode> frnv;
|
deba@1022
|
230 |
for (int i = 0; i < nn; ++i) {
|
deba@1025
|
231 |
SmartBpGraph::RedNode node = from.addRedNode();
|
deba@1022
|
232 |
frnv.push_back(node);
|
deba@1022
|
233 |
fnm[node] = i * i;
|
deba@1022
|
234 |
frnm[node] = i + i;
|
deba@1025
|
235 |
if (i == 0) {
|
deba@1025
|
236 |
fn = node;
|
deba@1025
|
237 |
frn = node;
|
deba@1025
|
238 |
}
|
deba@1022
|
239 |
}
|
deba@1022
|
240 |
|
deba@1025
|
241 |
std::vector<SmartBpGraph::BlueNode> fbnv;
|
deba@1022
|
242 |
for (int i = 0; i < nn; ++i) {
|
deba@1025
|
243 |
SmartBpGraph::BlueNode node = from.addBlueNode();
|
deba@1022
|
244 |
fbnv.push_back(node);
|
deba@1022
|
245 |
fnm[node] = i * i;
|
deba@1022
|
246 |
fbnm[node] = i + i;
|
deba@1025
|
247 |
if (i == 0) fbn = node;
|
deba@1022
|
248 |
}
|
deba@1022
|
249 |
|
deba@1022
|
250 |
for (int i = 0; i < nn; ++i) {
|
deba@1022
|
251 |
for (int j = 0; j < nn; ++j) {
|
deba@1022
|
252 |
SmartBpGraph::Edge edge = from.addEdge(frnv[i], fbnv[j]);
|
deba@1022
|
253 |
fem[edge] = i * i + j * j;
|
deba@1022
|
254 |
fam[from.direct(edge, true)] = i + j * j;
|
deba@1022
|
255 |
fam[from.direct(edge, false)] = i * i + j;
|
deba@1022
|
256 |
if (i == 0 && j == 0) fa = from.direct(edge, true);
|
deba@1022
|
257 |
if (i == 0 && j == 0) fe = edge;
|
deba@1022
|
258 |
}
|
deba@1022
|
259 |
}
|
deba@1022
|
260 |
|
deba@1022
|
261 |
// Test graph copy
|
deba@1022
|
262 |
GR to;
|
deba@1022
|
263 |
typename GR::template NodeMap<int> tnm(to);
|
deba@1026
|
264 |
typename GR::template RedNodeMap<int> trnm(to);
|
deba@1026
|
265 |
typename GR::template BlueNodeMap<int> tbnm(to);
|
deba@1022
|
266 |
typename GR::template ArcMap<int> tam(to);
|
deba@1022
|
267 |
typename GR::template EdgeMap<int> tem(to);
|
deba@1022
|
268 |
typename GR::Node tn;
|
deba@1025
|
269 |
typename GR::RedNode trn;
|
deba@1025
|
270 |
typename GR::BlueNode tbn;
|
deba@1022
|
271 |
typename GR::Arc ta;
|
deba@1022
|
272 |
typename GR::Edge te;
|
deba@1022
|
273 |
|
deba@1022
|
274 |
SmartBpGraph::NodeMap<typename GR::Node> nr(from);
|
deba@1026
|
275 |
SmartBpGraph::RedNodeMap<typename GR::RedNode> rnr(from);
|
deba@1026
|
276 |
SmartBpGraph::BlueNodeMap<typename GR::BlueNode> bnr(from);
|
deba@1022
|
277 |
SmartBpGraph::ArcMap<typename GR::Arc> ar(from);
|
deba@1022
|
278 |
SmartBpGraph::EdgeMap<typename GR::Edge> er(from);
|
deba@1022
|
279 |
|
deba@1022
|
280 |
typename GR::template NodeMap<SmartBpGraph::Node> ncr(to);
|
deba@1026
|
281 |
typename GR::template RedNodeMap<SmartBpGraph::RedNode> rncr(to);
|
deba@1026
|
282 |
typename GR::template BlueNodeMap<SmartBpGraph::BlueNode> bncr(to);
|
deba@1022
|
283 |
typename GR::template ArcMap<SmartBpGraph::Arc> acr(to);
|
deba@1022
|
284 |
typename GR::template EdgeMap<SmartBpGraph::Edge> ecr(to);
|
deba@1022
|
285 |
|
deba@1022
|
286 |
bpGraphCopy(from, to).
|
deba@1026
|
287 |
nodeMap(fnm, tnm).
|
deba@1026
|
288 |
redNodeMap(frnm, trnm).blueNodeMap(fbnm, tbnm).
|
deba@1022
|
289 |
arcMap(fam, tam).edgeMap(fem, tem).
|
deba@1022
|
290 |
nodeRef(nr).redRef(rnr).blueRef(bnr).
|
deba@1022
|
291 |
arcRef(ar).edgeRef(er).
|
deba@1022
|
292 |
nodeCrossRef(ncr).redCrossRef(rncr).blueCrossRef(bncr).
|
deba@1022
|
293 |
arcCrossRef(acr).edgeCrossRef(ecr).
|
deba@1025
|
294 |
node(fn, tn).redNode(frn, trn).blueNode(fbn, tbn).
|
deba@1025
|
295 |
arc(fa, ta).edge(fe, te).run();
|
deba@1022
|
296 |
|
deba@1022
|
297 |
check(countNodes(from) == countNodes(to), "Wrong copy.");
|
deba@1022
|
298 |
check(countRedNodes(from) == countRedNodes(to), "Wrong copy.");
|
deba@1022
|
299 |
check(countBlueNodes(from) == countBlueNodes(to), "Wrong copy.");
|
deba@1022
|
300 |
check(countEdges(from) == countEdges(to), "Wrong copy.");
|
deba@1022
|
301 |
check(countArcs(from) == countArcs(to), "Wrong copy.");
|
deba@1022
|
302 |
|
deba@1022
|
303 |
for (SmartBpGraph::NodeIt it(from); it != INVALID; ++it) {
|
deba@1022
|
304 |
check(ncr[nr[it]] == it, "Wrong copy.");
|
deba@1022
|
305 |
check(fnm[it] == tnm[nr[it]], "Wrong copy.");
|
deba@1025
|
306 |
}
|
deba@1025
|
307 |
|
deba@1026
|
308 |
for (SmartBpGraph::RedNodeIt it(from); it != INVALID; ++it) {
|
deba@1025
|
309 |
check(ncr[nr[it]] == it, "Wrong copy.");
|
deba@1025
|
310 |
check(fnm[it] == tnm[nr[it]], "Wrong copy.");
|
deba@1025
|
311 |
check(rnr[it] == nr[it], "Wrong copy.");
|
deba@1025
|
312 |
check(rncr[rnr[it]] == it, "Wrong copy.");
|
deba@1025
|
313 |
check(frnm[it] == trnm[rnr[it]], "Wrong copy.");
|
deba@1025
|
314 |
check(to.red(rnr[it]), "Wrong copy.");
|
deba@1025
|
315 |
}
|
deba@1025
|
316 |
|
deba@1026
|
317 |
for (SmartBpGraph::BlueNodeIt it(from); it != INVALID; ++it) {
|
deba@1025
|
318 |
check(ncr[nr[it]] == it, "Wrong copy.");
|
deba@1025
|
319 |
check(fnm[it] == tnm[nr[it]], "Wrong copy.");
|
deba@1025
|
320 |
check(bnr[it] == nr[it], "Wrong copy.");
|
deba@1025
|
321 |
check(bncr[bnr[it]] == it, "Wrong copy.");
|
deba@1025
|
322 |
check(fbnm[it] == tbnm[bnr[it]], "Wrong copy.");
|
deba@1025
|
323 |
check(to.blue(bnr[it]), "Wrong copy.");
|
deba@1022
|
324 |
}
|
deba@1022
|
325 |
|
deba@1022
|
326 |
for (SmartBpGraph::ArcIt it(from); it != INVALID; ++it) {
|
deba@1022
|
327 |
check(acr[ar[it]] == it, "Wrong copy.");
|
deba@1022
|
328 |
check(fam[it] == tam[ar[it]], "Wrong copy.");
|
deba@1022
|
329 |
check(nr[from.source(it)] == to.source(ar[it]), "Wrong copy.");
|
deba@1022
|
330 |
check(nr[from.target(it)] == to.target(ar[it]), "Wrong copy.");
|
deba@1022
|
331 |
}
|
deba@1022
|
332 |
|
deba@1022
|
333 |
for (SmartBpGraph::EdgeIt it(from); it != INVALID; ++it) {
|
deba@1022
|
334 |
check(ecr[er[it]] == it, "Wrong copy.");
|
deba@1022
|
335 |
check(fem[it] == tem[er[it]], "Wrong copy.");
|
deba@1022
|
336 |
check(nr[from.u(it)] == to.u(er[it]) || nr[from.u(it)] == to.v(er[it]),
|
deba@1022
|
337 |
"Wrong copy.");
|
deba@1022
|
338 |
check(nr[from.v(it)] == to.u(er[it]) || nr[from.v(it)] == to.v(er[it]),
|
deba@1022
|
339 |
"Wrong copy.");
|
deba@1022
|
340 |
check((from.u(it) != from.v(it)) == (to.u(er[it]) != to.v(er[it])),
|
deba@1022
|
341 |
"Wrong copy.");
|
deba@1022
|
342 |
}
|
deba@1022
|
343 |
|
deba@1022
|
344 |
for (typename GR::NodeIt it(to); it != INVALID; ++it) {
|
deba@1022
|
345 |
check(nr[ncr[it]] == it, "Wrong copy.");
|
deba@1022
|
346 |
}
|
deba@1026
|
347 |
for (typename GR::RedNodeIt it(to); it != INVALID; ++it) {
|
deba@1022
|
348 |
check(rncr[it] == ncr[it], "Wrong copy.");
|
deba@1022
|
349 |
check(rnr[rncr[it]] == it, "Wrong copy.");
|
deba@1022
|
350 |
}
|
deba@1026
|
351 |
for (typename GR::BlueNodeIt it(to); it != INVALID; ++it) {
|
deba@1022
|
352 |
check(bncr[it] == ncr[it], "Wrong copy.");
|
deba@1022
|
353 |
check(bnr[bncr[it]] == it, "Wrong copy.");
|
deba@1022
|
354 |
}
|
deba@1022
|
355 |
for (typename GR::ArcIt it(to); it != INVALID; ++it) {
|
deba@1022
|
356 |
check(ar[acr[it]] == it, "Wrong copy.");
|
deba@1022
|
357 |
}
|
deba@1022
|
358 |
for (typename GR::EdgeIt it(to); it != INVALID; ++it) {
|
deba@1022
|
359 |
check(er[ecr[it]] == it, "Wrong copy.");
|
deba@1022
|
360 |
}
|
deba@1022
|
361 |
check(tn == nr[fn], "Wrong copy.");
|
deba@1025
|
362 |
check(trn == rnr[frn], "Wrong copy.");
|
deba@1025
|
363 |
check(tbn == bnr[fbn], "Wrong copy.");
|
deba@1022
|
364 |
check(ta == ar[fa], "Wrong copy.");
|
deba@1022
|
365 |
check(te == er[fe], "Wrong copy.");
|
deba@1022
|
366 |
|
deba@1022
|
367 |
// Test repeated copy
|
deba@1022
|
368 |
bpGraphCopy(from, to).run();
|
alpar@1092
|
369 |
|
deba@1022
|
370 |
check(countNodes(from) == countNodes(to), "Wrong copy.");
|
deba@1022
|
371 |
check(countRedNodes(from) == countRedNodes(to), "Wrong copy.");
|
deba@1022
|
372 |
check(countBlueNodes(from) == countBlueNodes(to), "Wrong copy.");
|
deba@1022
|
373 |
check(countEdges(from) == countEdges(to), "Wrong copy.");
|
deba@1022
|
374 |
check(countArcs(from) == countArcs(to), "Wrong copy.");
|
deba@1022
|
375 |
}
|
deba@1022
|
376 |
|
deba@200
|
377 |
|
deba@200
|
378 |
int main() {
|
kpeter@894
|
379 |
digraph_copy_test<SmartDigraph>();
|
kpeter@894
|
380 |
digraph_copy_test<ListDigraph>();
|
kpeter@894
|
381 |
digraph_copy_test<StaticDigraph>();
|
kpeter@894
|
382 |
graph_copy_test<SmartGraph>();
|
kpeter@894
|
383 |
graph_copy_test<ListGraph>();
|
deba@1022
|
384 |
bpgraph_copy_test<SmartBpGraph>();
|
deba@1022
|
385 |
bpgraph_copy_test<ListBpGraph>();
|
deba@200
|
386 |
|
alpar@209
|
387 |
return 0;
|
deba@200
|
388 |
}
|