deba@1186
|
1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*-
|
deba@1186
|
2 |
*
|
deba@1186
|
3 |
* This file is a part of LEMON, a generic C++ optimization library.
|
deba@1186
|
4 |
*
|
alpar@1270
|
5 |
* Copyright (C) 2003-2013
|
deba@1186
|
6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
|
deba@1186
|
7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES).
|
deba@1186
|
8 |
*
|
deba@1186
|
9 |
* Permission to use, modify and distribute this software is granted
|
deba@1186
|
10 |
* provided that this copyright notice appears in all copies. For
|
deba@1186
|
11 |
* precise terms see the accompanying LICENSE file.
|
deba@1186
|
12 |
*
|
deba@1186
|
13 |
* This software is provided "AS IS" with no warranty of any kind,
|
deba@1186
|
14 |
* express or implied, and with no claim as to its suitability for any
|
deba@1186
|
15 |
* purpose.
|
deba@1186
|
16 |
*
|
deba@1186
|
17 |
*/
|
deba@1186
|
18 |
|
deba@1186
|
19 |
#include <lemon/concepts/bpgraph.h>
|
deba@1189
|
20 |
#include <lemon/list_graph.h>
|
deba@1187
|
21 |
#include <lemon/smart_graph.h>
|
deba@1188
|
22 |
#include <lemon/full_graph.h>
|
deba@1186
|
23 |
|
deba@1186
|
24 |
#include "test_tools.h"
|
deba@1186
|
25 |
#include "graph_test.h"
|
deba@1186
|
26 |
|
deba@1186
|
27 |
using namespace lemon;
|
deba@1186
|
28 |
using namespace lemon::concepts;
|
deba@1186
|
29 |
|
deba@1187
|
30 |
template <class BpGraph>
|
deba@1187
|
31 |
void checkBpGraphBuild() {
|
deba@1187
|
32 |
TEMPLATE_BPGRAPH_TYPEDEFS(BpGraph);
|
deba@1187
|
33 |
|
deba@1187
|
34 |
BpGraph G;
|
deba@1187
|
35 |
checkGraphNodeList(G, 0);
|
deba@1187
|
36 |
checkGraphRedNodeList(G, 0);
|
deba@1187
|
37 |
checkGraphBlueNodeList(G, 0);
|
deba@1187
|
38 |
checkGraphEdgeList(G, 0);
|
deba@1187
|
39 |
checkGraphArcList(G, 0);
|
deba@1187
|
40 |
|
deba@1187
|
41 |
G.reserveNode(3);
|
deba@1187
|
42 |
G.reserveEdge(3);
|
deba@1187
|
43 |
|
deba@1193
|
44 |
RedNode
|
deba@1187
|
45 |
rn1 = G.addRedNode();
|
deba@1187
|
46 |
checkGraphNodeList(G, 1);
|
deba@1187
|
47 |
checkGraphRedNodeList(G, 1);
|
deba@1187
|
48 |
checkGraphBlueNodeList(G, 0);
|
deba@1187
|
49 |
checkGraphEdgeList(G, 0);
|
deba@1187
|
50 |
checkGraphArcList(G, 0);
|
deba@1187
|
51 |
|
deba@1193
|
52 |
BlueNode
|
deba@1187
|
53 |
bn1 = G.addBlueNode(),
|
deba@1187
|
54 |
bn2 = G.addBlueNode();
|
deba@1187
|
55 |
checkGraphNodeList(G, 3);
|
deba@1187
|
56 |
checkGraphRedNodeList(G, 1);
|
deba@1187
|
57 |
checkGraphBlueNodeList(G, 2);
|
deba@1187
|
58 |
checkGraphEdgeList(G, 0);
|
deba@1187
|
59 |
checkGraphArcList(G, 0);
|
deba@1187
|
60 |
|
deba@1187
|
61 |
Edge e1 = G.addEdge(rn1, bn2);
|
deba@1187
|
62 |
check(G.redNode(e1) == rn1 && G.blueNode(e1) == bn2, "Wrong edge");
|
deba@1187
|
63 |
check(G.u(e1) == rn1 && G.v(e1) == bn2, "Wrong edge");
|
deba@1187
|
64 |
|
deba@1187
|
65 |
checkGraphNodeList(G, 3);
|
deba@1187
|
66 |
checkGraphRedNodeList(G, 1);
|
deba@1187
|
67 |
checkGraphBlueNodeList(G, 2);
|
deba@1187
|
68 |
checkGraphEdgeList(G, 1);
|
deba@1187
|
69 |
checkGraphArcList(G, 2);
|
deba@1187
|
70 |
|
deba@1187
|
71 |
checkGraphIncEdgeArcLists(G, rn1, 1);
|
deba@1187
|
72 |
checkGraphIncEdgeArcLists(G, bn1, 0);
|
deba@1187
|
73 |
checkGraphIncEdgeArcLists(G, bn2, 1);
|
deba@1187
|
74 |
|
deba@1187
|
75 |
checkGraphConEdgeList(G, 1);
|
deba@1187
|
76 |
checkGraphConArcList(G, 2);
|
deba@1187
|
77 |
|
deba@1187
|
78 |
Edge
|
deba@1193
|
79 |
e2 = G.addEdge(bn1, rn1),
|
deba@1187
|
80 |
e3 = G.addEdge(rn1, bn2);
|
alpar@1292
|
81 |
::lemon::ignore_unused_variable_warning(e2,e3);
|
deba@1187
|
82 |
|
deba@1187
|
83 |
checkGraphNodeList(G, 3);
|
deba@1187
|
84 |
checkGraphRedNodeList(G, 1);
|
deba@1187
|
85 |
checkGraphBlueNodeList(G, 2);
|
deba@1187
|
86 |
checkGraphEdgeList(G, 3);
|
deba@1187
|
87 |
checkGraphArcList(G, 6);
|
deba@1187
|
88 |
|
deba@1187
|
89 |
checkGraphIncEdgeArcLists(G, rn1, 3);
|
deba@1187
|
90 |
checkGraphIncEdgeArcLists(G, bn1, 1);
|
deba@1187
|
91 |
checkGraphIncEdgeArcLists(G, bn2, 2);
|
deba@1187
|
92 |
|
deba@1187
|
93 |
checkGraphConEdgeList(G, 3);
|
deba@1187
|
94 |
checkGraphConArcList(G, 6);
|
deba@1187
|
95 |
|
deba@1187
|
96 |
checkArcDirections(G);
|
deba@1187
|
97 |
|
deba@1187
|
98 |
checkNodeIds(G);
|
deba@1187
|
99 |
checkRedNodeIds(G);
|
deba@1187
|
100 |
checkBlueNodeIds(G);
|
deba@1187
|
101 |
checkArcIds(G);
|
deba@1187
|
102 |
checkEdgeIds(G);
|
deba@1187
|
103 |
|
deba@1187
|
104 |
checkGraphNodeMap(G);
|
deba@1194
|
105 |
checkGraphRedNodeMap(G);
|
deba@1194
|
106 |
checkGraphBlueNodeMap(G);
|
deba@1187
|
107 |
checkGraphArcMap(G);
|
deba@1187
|
108 |
checkGraphEdgeMap(G);
|
deba@1187
|
109 |
}
|
deba@1187
|
110 |
|
deba@1189
|
111 |
template <class BpGraph>
|
deba@1189
|
112 |
void checkBpGraphErase() {
|
deba@1189
|
113 |
TEMPLATE_BPGRAPH_TYPEDEFS(BpGraph);
|
deba@1189
|
114 |
|
deba@1189
|
115 |
BpGraph G;
|
deba@1193
|
116 |
RedNode
|
alpar@1270
|
117 |
n1 = G.addRedNode(), n4 = G.addRedNode();
|
deba@1193
|
118 |
BlueNode
|
deba@1193
|
119 |
n2 = G.addBlueNode(), n3 = G.addBlueNode();
|
deba@1189
|
120 |
Edge
|
deba@1189
|
121 |
e1 = G.addEdge(n1, n2), e2 = G.addEdge(n1, n3),
|
deba@1189
|
122 |
e3 = G.addEdge(n4, n2), e4 = G.addEdge(n4, n3);
|
alpar@1292
|
123 |
::lemon::ignore_unused_variable_warning(e1,e3,e4);
|
deba@1189
|
124 |
|
deba@1189
|
125 |
// Check edge deletion
|
deba@1189
|
126 |
G.erase(e2);
|
deba@1189
|
127 |
|
deba@1189
|
128 |
checkGraphNodeList(G, 4);
|
deba@1189
|
129 |
checkGraphRedNodeList(G, 2);
|
deba@1189
|
130 |
checkGraphBlueNodeList(G, 2);
|
deba@1189
|
131 |
checkGraphEdgeList(G, 3);
|
deba@1189
|
132 |
checkGraphArcList(G, 6);
|
deba@1189
|
133 |
|
deba@1189
|
134 |
checkGraphIncEdgeArcLists(G, n1, 1);
|
deba@1189
|
135 |
checkGraphIncEdgeArcLists(G, n2, 2);
|
deba@1189
|
136 |
checkGraphIncEdgeArcLists(G, n3, 1);
|
deba@1189
|
137 |
checkGraphIncEdgeArcLists(G, n4, 2);
|
deba@1189
|
138 |
|
deba@1189
|
139 |
checkGraphConEdgeList(G, 3);
|
deba@1189
|
140 |
checkGraphConArcList(G, 6);
|
deba@1189
|
141 |
|
deba@1189
|
142 |
// Check node deletion
|
deba@1189
|
143 |
G.erase(n3);
|
deba@1189
|
144 |
|
deba@1189
|
145 |
checkGraphNodeList(G, 3);
|
deba@1189
|
146 |
checkGraphRedNodeList(G, 2);
|
deba@1189
|
147 |
checkGraphBlueNodeList(G, 1);
|
deba@1189
|
148 |
checkGraphEdgeList(G, 2);
|
deba@1189
|
149 |
checkGraphArcList(G, 4);
|
deba@1189
|
150 |
|
deba@1189
|
151 |
checkGraphIncEdgeArcLists(G, n1, 1);
|
deba@1189
|
152 |
checkGraphIncEdgeArcLists(G, n2, 2);
|
deba@1189
|
153 |
checkGraphIncEdgeArcLists(G, n4, 1);
|
deba@1189
|
154 |
|
deba@1189
|
155 |
checkGraphConEdgeList(G, 2);
|
deba@1189
|
156 |
checkGraphConArcList(G, 4);
|
deba@1189
|
157 |
|
deba@1189
|
158 |
}
|
deba@1189
|
159 |
|
deba@1189
|
160 |
template <class BpGraph>
|
deba@1189
|
161 |
void checkBpGraphAlter() {
|
deba@1189
|
162 |
TEMPLATE_BPGRAPH_TYPEDEFS(BpGraph);
|
deba@1189
|
163 |
|
deba@1189
|
164 |
BpGraph G;
|
deba@1193
|
165 |
RedNode
|
alpar@1270
|
166 |
n1 = G.addRedNode(), n4 = G.addRedNode();
|
deba@1193
|
167 |
BlueNode
|
deba@1193
|
168 |
n2 = G.addBlueNode(), n3 = G.addBlueNode();
|
deba@1189
|
169 |
Edge
|
deba@1189
|
170 |
e1 = G.addEdge(n1, n2), e2 = G.addEdge(n1, n3),
|
deba@1189
|
171 |
e3 = G.addEdge(n4, n2), e4 = G.addEdge(n4, n3);
|
alpar@1292
|
172 |
::lemon::ignore_unused_variable_warning(e1,e3,e4);
|
deba@1189
|
173 |
|
deba@1189
|
174 |
G.changeRed(e2, n4);
|
deba@1189
|
175 |
check(G.redNode(e2) == n4, "Wrong red node");
|
deba@1189
|
176 |
check(G.blueNode(e2) == n3, "Wrong blue node");
|
deba@1189
|
177 |
|
deba@1189
|
178 |
checkGraphNodeList(G, 4);
|
deba@1189
|
179 |
checkGraphRedNodeList(G, 2);
|
deba@1189
|
180 |
checkGraphBlueNodeList(G, 2);
|
deba@1189
|
181 |
checkGraphEdgeList(G, 4);
|
deba@1189
|
182 |
checkGraphArcList(G, 8);
|
deba@1189
|
183 |
|
deba@1189
|
184 |
checkGraphIncEdgeArcLists(G, n1, 1);
|
deba@1189
|
185 |
checkGraphIncEdgeArcLists(G, n2, 2);
|
deba@1189
|
186 |
checkGraphIncEdgeArcLists(G, n3, 2);
|
deba@1189
|
187 |
checkGraphIncEdgeArcLists(G, n4, 3);
|
deba@1189
|
188 |
|
deba@1189
|
189 |
checkGraphConEdgeList(G, 4);
|
deba@1189
|
190 |
checkGraphConArcList(G, 8);
|
deba@1189
|
191 |
|
deba@1189
|
192 |
G.changeBlue(e2, n2);
|
deba@1189
|
193 |
check(G.redNode(e2) == n4, "Wrong red node");
|
deba@1189
|
194 |
check(G.blueNode(e2) == n2, "Wrong blue node");
|
deba@1189
|
195 |
|
deba@1189
|
196 |
checkGraphNodeList(G, 4);
|
deba@1189
|
197 |
checkGraphRedNodeList(G, 2);
|
deba@1189
|
198 |
checkGraphBlueNodeList(G, 2);
|
deba@1189
|
199 |
checkGraphEdgeList(G, 4);
|
deba@1189
|
200 |
checkGraphArcList(G, 8);
|
deba@1189
|
201 |
|
deba@1189
|
202 |
checkGraphIncEdgeArcLists(G, n1, 1);
|
deba@1189
|
203 |
checkGraphIncEdgeArcLists(G, n2, 3);
|
deba@1189
|
204 |
checkGraphIncEdgeArcLists(G, n3, 1);
|
deba@1189
|
205 |
checkGraphIncEdgeArcLists(G, n4, 3);
|
deba@1189
|
206 |
|
deba@1189
|
207 |
checkGraphConEdgeList(G, 4);
|
deba@1189
|
208 |
checkGraphConArcList(G, 8);
|
deba@1189
|
209 |
}
|
deba@1189
|
210 |
|
deba@1189
|
211 |
|
deba@1189
|
212 |
template <class BpGraph>
|
deba@1187
|
213 |
void checkBpGraphSnapshot() {
|
deba@1189
|
214 |
TEMPLATE_BPGRAPH_TYPEDEFS(BpGraph);
|
deba@1187
|
215 |
|
deba@1189
|
216 |
BpGraph G;
|
deba@1193
|
217 |
RedNode
|
deba@1193
|
218 |
n1 = G.addRedNode();
|
deba@1193
|
219 |
BlueNode
|
deba@1187
|
220 |
n2 = G.addBlueNode(),
|
deba@1187
|
221 |
n3 = G.addBlueNode();
|
alpar@1270
|
222 |
Edge
|
deba@1187
|
223 |
e1 = G.addEdge(n1, n2),
|
deba@1187
|
224 |
e2 = G.addEdge(n1, n3);
|
alpar@1292
|
225 |
::lemon::ignore_unused_variable_warning(e1,e2);
|
deba@1187
|
226 |
|
deba@1187
|
227 |
checkGraphNodeList(G, 3);
|
deba@1187
|
228 |
checkGraphRedNodeList(G, 1);
|
deba@1187
|
229 |
checkGraphBlueNodeList(G, 2);
|
deba@1187
|
230 |
checkGraphEdgeList(G, 2);
|
deba@1187
|
231 |
checkGraphArcList(G, 4);
|
deba@1187
|
232 |
|
deba@1189
|
233 |
typename BpGraph::Snapshot snapshot(G);
|
deba@1187
|
234 |
|
deba@1193
|
235 |
RedNode n4 = G.addRedNode();
|
deba@1187
|
236 |
G.addEdge(n4, n2);
|
deba@1187
|
237 |
G.addEdge(n4, n3);
|
deba@1187
|
238 |
|
deba@1187
|
239 |
checkGraphNodeList(G, 4);
|
deba@1187
|
240 |
checkGraphRedNodeList(G, 2);
|
deba@1187
|
241 |
checkGraphBlueNodeList(G, 2);
|
deba@1187
|
242 |
checkGraphEdgeList(G, 4);
|
deba@1187
|
243 |
checkGraphArcList(G, 8);
|
deba@1187
|
244 |
|
deba@1187
|
245 |
snapshot.restore();
|
deba@1187
|
246 |
|
deba@1187
|
247 |
checkGraphNodeList(G, 3);
|
deba@1187
|
248 |
checkGraphRedNodeList(G, 1);
|
deba@1187
|
249 |
checkGraphBlueNodeList(G, 2);
|
deba@1187
|
250 |
checkGraphEdgeList(G, 2);
|
deba@1187
|
251 |
checkGraphArcList(G, 4);
|
deba@1187
|
252 |
|
deba@1187
|
253 |
checkGraphIncEdgeArcLists(G, n1, 2);
|
deba@1187
|
254 |
checkGraphIncEdgeArcLists(G, n2, 1);
|
deba@1187
|
255 |
checkGraphIncEdgeArcLists(G, n3, 1);
|
deba@1187
|
256 |
|
deba@1187
|
257 |
checkGraphConEdgeList(G, 2);
|
deba@1187
|
258 |
checkGraphConArcList(G, 4);
|
deba@1187
|
259 |
|
deba@1187
|
260 |
checkNodeIds(G);
|
deba@1187
|
261 |
checkRedNodeIds(G);
|
deba@1187
|
262 |
checkBlueNodeIds(G);
|
deba@1187
|
263 |
checkArcIds(G);
|
deba@1187
|
264 |
checkEdgeIds(G);
|
deba@1187
|
265 |
|
deba@1187
|
266 |
checkGraphNodeMap(G);
|
deba@1194
|
267 |
checkGraphRedNodeMap(G);
|
deba@1194
|
268 |
checkGraphBlueNodeMap(G);
|
deba@1187
|
269 |
checkGraphArcMap(G);
|
deba@1187
|
270 |
checkGraphEdgeMap(G);
|
deba@1187
|
271 |
|
deba@1187
|
272 |
G.addRedNode();
|
deba@1187
|
273 |
snapshot.save(G);
|
deba@1187
|
274 |
|
deba@1187
|
275 |
G.addEdge(G.addRedNode(), G.addBlueNode());
|
deba@1187
|
276 |
|
deba@1187
|
277 |
snapshot.restore();
|
deba@1187
|
278 |
snapshot.save(G);
|
deba@1187
|
279 |
|
deba@1187
|
280 |
checkGraphNodeList(G, 4);
|
deba@1187
|
281 |
checkGraphRedNodeList(G, 2);
|
deba@1187
|
282 |
checkGraphBlueNodeList(G, 2);
|
deba@1187
|
283 |
checkGraphEdgeList(G, 2);
|
deba@1187
|
284 |
checkGraphArcList(G, 4);
|
deba@1187
|
285 |
|
deba@1187
|
286 |
G.addEdge(G.addRedNode(), G.addBlueNode());
|
deba@1187
|
287 |
|
deba@1187
|
288 |
snapshot.restore();
|
deba@1187
|
289 |
|
deba@1187
|
290 |
checkGraphNodeList(G, 4);
|
deba@1187
|
291 |
checkGraphRedNodeList(G, 2);
|
deba@1187
|
292 |
checkGraphBlueNodeList(G, 2);
|
deba@1187
|
293 |
checkGraphEdgeList(G, 2);
|
deba@1187
|
294 |
checkGraphArcList(G, 4);
|
deba@1187
|
295 |
}
|
deba@1187
|
296 |
|
deba@1189
|
297 |
template <typename BpGraph>
|
deba@1187
|
298 |
void checkBpGraphValidity() {
|
deba@1189
|
299 |
TEMPLATE_BPGRAPH_TYPEDEFS(BpGraph);
|
deba@1189
|
300 |
BpGraph g;
|
deba@1187
|
301 |
|
deba@1193
|
302 |
RedNode
|
deba@1193
|
303 |
n1 = g.addRedNode();
|
deba@1193
|
304 |
BlueNode
|
deba@1187
|
305 |
n2 = g.addBlueNode(),
|
deba@1187
|
306 |
n3 = g.addBlueNode();
|
deba@1187
|
307 |
|
deba@1187
|
308 |
Edge
|
deba@1187
|
309 |
e1 = g.addEdge(n1, n2),
|
deba@1187
|
310 |
e2 = g.addEdge(n1, n3);
|
alpar@1292
|
311 |
::lemon::ignore_unused_variable_warning(e2);
|
deba@1187
|
312 |
|
deba@1187
|
313 |
check(g.valid(n1), "Wrong validity check");
|
deba@1187
|
314 |
check(g.valid(e1), "Wrong validity check");
|
deba@1187
|
315 |
check(g.valid(g.direct(e1, true)), "Wrong validity check");
|
deba@1187
|
316 |
|
deba@1187
|
317 |
check(!g.valid(g.nodeFromId(-1)), "Wrong validity check");
|
deba@1187
|
318 |
check(!g.valid(g.edgeFromId(-1)), "Wrong validity check");
|
deba@1187
|
319 |
check(!g.valid(g.arcFromId(-1)), "Wrong validity check");
|
deba@1187
|
320 |
}
|
deba@1187
|
321 |
|
deba@1186
|
322 |
void checkConcepts() {
|
deba@1186
|
323 |
{ // Checking graph components
|
deba@1186
|
324 |
checkConcept<BaseBpGraphComponent, BaseBpGraphComponent >();
|
deba@1186
|
325 |
|
deba@1186
|
326 |
checkConcept<IDableBpGraphComponent<>,
|
deba@1186
|
327 |
IDableBpGraphComponent<> >();
|
deba@1186
|
328 |
|
deba@1186
|
329 |
checkConcept<IterableBpGraphComponent<>,
|
deba@1186
|
330 |
IterableBpGraphComponent<> >();
|
deba@1186
|
331 |
|
deba@1186
|
332 |
checkConcept<AlterableBpGraphComponent<>,
|
deba@1186
|
333 |
AlterableBpGraphComponent<> >();
|
deba@1186
|
334 |
|
deba@1186
|
335 |
checkConcept<MappableBpGraphComponent<>,
|
deba@1186
|
336 |
MappableBpGraphComponent<> >();
|
deba@1186
|
337 |
|
deba@1186
|
338 |
checkConcept<ExtendableBpGraphComponent<>,
|
deba@1186
|
339 |
ExtendableBpGraphComponent<> >();
|
deba@1186
|
340 |
|
deba@1186
|
341 |
checkConcept<ErasableBpGraphComponent<>,
|
deba@1186
|
342 |
ErasableBpGraphComponent<> >();
|
deba@1186
|
343 |
|
deba@1187
|
344 |
checkConcept<ClearableBpGraphComponent<>,
|
deba@1187
|
345 |
ClearableBpGraphComponent<> >();
|
deba@1186
|
346 |
|
deba@1186
|
347 |
}
|
deba@1186
|
348 |
{ // Checking skeleton graph
|
deba@1186
|
349 |
checkConcept<BpGraph, BpGraph>();
|
deba@1186
|
350 |
}
|
deba@1187
|
351 |
{ // Checking SmartBpGraph
|
deba@1187
|
352 |
checkConcept<BpGraph, SmartBpGraph>();
|
deba@1187
|
353 |
checkConcept<AlterableBpGraphComponent<>, SmartBpGraph>();
|
deba@1187
|
354 |
checkConcept<ExtendableBpGraphComponent<>, SmartBpGraph>();
|
deba@1187
|
355 |
checkConcept<ClearableBpGraphComponent<>, SmartBpGraph>();
|
deba@1187
|
356 |
}
|
deba@1186
|
357 |
}
|
deba@1186
|
358 |
|
deba@1188
|
359 |
void checkFullBpGraph(int redNum, int blueNum) {
|
deba@1188
|
360 |
typedef FullBpGraph BpGraph;
|
deba@1188
|
361 |
BPGRAPH_TYPEDEFS(BpGraph);
|
deba@1188
|
362 |
|
deba@1188
|
363 |
BpGraph G(redNum, blueNum);
|
deba@1188
|
364 |
checkGraphNodeList(G, redNum + blueNum);
|
deba@1188
|
365 |
checkGraphRedNodeList(G, redNum);
|
deba@1188
|
366 |
checkGraphBlueNodeList(G, blueNum);
|
deba@1188
|
367 |
checkGraphEdgeList(G, redNum * blueNum);
|
deba@1188
|
368 |
checkGraphArcList(G, 2 * redNum * blueNum);
|
deba@1188
|
369 |
|
deba@1188
|
370 |
G.resize(redNum, blueNum);
|
deba@1188
|
371 |
checkGraphNodeList(G, redNum + blueNum);
|
deba@1188
|
372 |
checkGraphRedNodeList(G, redNum);
|
deba@1188
|
373 |
checkGraphBlueNodeList(G, blueNum);
|
deba@1188
|
374 |
checkGraphEdgeList(G, redNum * blueNum);
|
deba@1188
|
375 |
checkGraphArcList(G, 2 * redNum * blueNum);
|
deba@1188
|
376 |
|
deba@1194
|
377 |
for (RedNodeIt n(G); n != INVALID; ++n) {
|
deba@1188
|
378 |
checkGraphOutArcList(G, n, blueNum);
|
deba@1188
|
379 |
checkGraphInArcList(G, n, blueNum);
|
deba@1188
|
380 |
checkGraphIncEdgeList(G, n, blueNum);
|
deba@1188
|
381 |
}
|
deba@1188
|
382 |
|
deba@1194
|
383 |
for (BlueNodeIt n(G); n != INVALID; ++n) {
|
deba@1188
|
384 |
checkGraphOutArcList(G, n, redNum);
|
deba@1188
|
385 |
checkGraphInArcList(G, n, redNum);
|
deba@1188
|
386 |
checkGraphIncEdgeList(G, n, redNum);
|
deba@1188
|
387 |
}
|
deba@1188
|
388 |
|
deba@1188
|
389 |
checkGraphConArcList(G, 2 * redNum * blueNum);
|
deba@1188
|
390 |
checkGraphConEdgeList(G, redNum * blueNum);
|
deba@1188
|
391 |
|
deba@1188
|
392 |
checkArcDirections(G);
|
deba@1188
|
393 |
|
deba@1188
|
394 |
checkNodeIds(G);
|
deba@1188
|
395 |
checkRedNodeIds(G);
|
deba@1188
|
396 |
checkBlueNodeIds(G);
|
deba@1188
|
397 |
checkArcIds(G);
|
deba@1188
|
398 |
checkEdgeIds(G);
|
deba@1188
|
399 |
|
deba@1188
|
400 |
checkGraphNodeMap(G);
|
deba@1194
|
401 |
checkGraphRedNodeMap(G);
|
deba@1194
|
402 |
checkGraphBlueNodeMap(G);
|
deba@1188
|
403 |
checkGraphArcMap(G);
|
deba@1188
|
404 |
checkGraphEdgeMap(G);
|
deba@1188
|
405 |
|
deba@1188
|
406 |
for (int i = 0; i < G.redNum(); ++i) {
|
deba@1188
|
407 |
check(G.red(G.redNode(i)), "Wrong node");
|
deba@1193
|
408 |
check(G.index(G.redNode(i)) == i, "Wrong index");
|
deba@1188
|
409 |
}
|
deba@1188
|
410 |
|
deba@1188
|
411 |
for (int i = 0; i < G.blueNum(); ++i) {
|
deba@1188
|
412 |
check(G.blue(G.blueNode(i)), "Wrong node");
|
deba@1193
|
413 |
check(G.index(G.blueNode(i)) == i, "Wrong index");
|
deba@1188
|
414 |
}
|
deba@1188
|
415 |
|
deba@1188
|
416 |
for (NodeIt u(G); u != INVALID; ++u) {
|
deba@1188
|
417 |
for (NodeIt v(G); v != INVALID; ++v) {
|
deba@1188
|
418 |
Edge e = G.edge(u, v);
|
deba@1188
|
419 |
Arc a = G.arc(u, v);
|
deba@1188
|
420 |
if (G.red(u) == G.red(v)) {
|
deba@1188
|
421 |
check(e == INVALID, "Wrong edge lookup");
|
deba@1188
|
422 |
check(a == INVALID, "Wrong arc lookup");
|
deba@1188
|
423 |
} else {
|
deba@1188
|
424 |
check((G.u(e) == u && G.v(e) == v) ||
|
deba@1188
|
425 |
(G.u(e) == v && G.v(e) == u), "Wrong edge lookup");
|
deba@1188
|
426 |
check(G.source(a) == u && G.target(a) == v, "Wrong arc lookup");
|
deba@1188
|
427 |
}
|
deba@1188
|
428 |
}
|
deba@1188
|
429 |
}
|
deba@1188
|
430 |
|
deba@1188
|
431 |
}
|
deba@1188
|
432 |
|
deba@1186
|
433 |
void checkGraphs() {
|
deba@1189
|
434 |
{ // Checking ListGraph
|
deba@1189
|
435 |
checkBpGraphBuild<ListBpGraph>();
|
deba@1189
|
436 |
checkBpGraphErase<ListBpGraph>();
|
deba@1189
|
437 |
checkBpGraphAlter<ListBpGraph>();
|
deba@1189
|
438 |
checkBpGraphSnapshot<ListBpGraph>();
|
deba@1189
|
439 |
checkBpGraphValidity<ListBpGraph>();
|
deba@1189
|
440 |
}
|
deba@1187
|
441 |
{ // Checking SmartGraph
|
deba@1187
|
442 |
checkBpGraphBuild<SmartBpGraph>();
|
deba@1187
|
443 |
checkBpGraphSnapshot<SmartBpGraph>();
|
deba@1187
|
444 |
checkBpGraphValidity<SmartBpGraph>();
|
deba@1187
|
445 |
}
|
deba@1188
|
446 |
{ // Checking FullBpGraph
|
deba@1188
|
447 |
checkFullBpGraph(6, 8);
|
deba@1188
|
448 |
checkFullBpGraph(7, 4);
|
deba@1188
|
449 |
}
|
deba@1186
|
450 |
}
|
deba@1186
|
451 |
|
deba@1186
|
452 |
int main() {
|
deba@1186
|
453 |
checkConcepts();
|
deba@1186
|
454 |
checkGraphs();
|
deba@1186
|
455 |
return 0;
|
deba@1186
|
456 |
}
|