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