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 |
*
|
deba@1186
|
5 |
* Copyright (C) 2003-2010
|
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);
|
deba@1187
|
81 |
|
deba@1187
|
82 |
checkGraphNodeList(G, 3);
|
deba@1187
|
83 |
checkGraphRedNodeList(G, 1);
|
deba@1187
|
84 |
checkGraphBlueNodeList(G, 2);
|
deba@1187
|
85 |
checkGraphEdgeList(G, 3);
|
deba@1187
|
86 |
checkGraphArcList(G, 6);
|
deba@1187
|
87 |
|
deba@1187
|
88 |
checkGraphIncEdgeArcLists(G, rn1, 3);
|
deba@1187
|
89 |
checkGraphIncEdgeArcLists(G, bn1, 1);
|
deba@1187
|
90 |
checkGraphIncEdgeArcLists(G, bn2, 2);
|
deba@1187
|
91 |
|
deba@1187
|
92 |
checkGraphConEdgeList(G, 3);
|
deba@1187
|
93 |
checkGraphConArcList(G, 6);
|
deba@1187
|
94 |
|
deba@1187
|
95 |
checkArcDirections(G);
|
deba@1187
|
96 |
|
deba@1187
|
97 |
checkNodeIds(G);
|
deba@1187
|
98 |
checkRedNodeIds(G);
|
deba@1187
|
99 |
checkBlueNodeIds(G);
|
deba@1187
|
100 |
checkArcIds(G);
|
deba@1187
|
101 |
checkEdgeIds(G);
|
deba@1187
|
102 |
|
deba@1187
|
103 |
checkGraphNodeMap(G);
|
deba@1194
|
104 |
checkGraphRedNodeMap(G);
|
deba@1194
|
105 |
checkGraphBlueNodeMap(G);
|
deba@1187
|
106 |
checkGraphArcMap(G);
|
deba@1187
|
107 |
checkGraphEdgeMap(G);
|
deba@1187
|
108 |
}
|
deba@1187
|
109 |
|
deba@1189
|
110 |
template <class BpGraph>
|
deba@1189
|
111 |
void checkBpGraphErase() {
|
deba@1189
|
112 |
TEMPLATE_BPGRAPH_TYPEDEFS(BpGraph);
|
deba@1189
|
113 |
|
deba@1189
|
114 |
BpGraph G;
|
deba@1193
|
115 |
RedNode
|
deba@1193
|
116 |
n1 = G.addRedNode(), n4 = G.addRedNode();
|
deba@1193
|
117 |
BlueNode
|
deba@1193
|
118 |
n2 = G.addBlueNode(), n3 = G.addBlueNode();
|
deba@1189
|
119 |
Edge
|
deba@1189
|
120 |
e1 = G.addEdge(n1, n2), e2 = G.addEdge(n1, n3),
|
deba@1189
|
121 |
e3 = G.addEdge(n4, n2), e4 = G.addEdge(n4, n3);
|
deba@1189
|
122 |
|
deba@1189
|
123 |
// Check edge deletion
|
deba@1189
|
124 |
G.erase(e2);
|
deba@1189
|
125 |
|
deba@1189
|
126 |
checkGraphNodeList(G, 4);
|
deba@1189
|
127 |
checkGraphRedNodeList(G, 2);
|
deba@1189
|
128 |
checkGraphBlueNodeList(G, 2);
|
deba@1189
|
129 |
checkGraphEdgeList(G, 3);
|
deba@1189
|
130 |
checkGraphArcList(G, 6);
|
deba@1189
|
131 |
|
deba@1189
|
132 |
checkGraphIncEdgeArcLists(G, n1, 1);
|
deba@1189
|
133 |
checkGraphIncEdgeArcLists(G, n2, 2);
|
deba@1189
|
134 |
checkGraphIncEdgeArcLists(G, n3, 1);
|
deba@1189
|
135 |
checkGraphIncEdgeArcLists(G, n4, 2);
|
deba@1189
|
136 |
|
deba@1189
|
137 |
checkGraphConEdgeList(G, 3);
|
deba@1189
|
138 |
checkGraphConArcList(G, 6);
|
deba@1189
|
139 |
|
deba@1189
|
140 |
// Check node deletion
|
deba@1189
|
141 |
G.erase(n3);
|
deba@1189
|
142 |
|
deba@1189
|
143 |
checkGraphNodeList(G, 3);
|
deba@1189
|
144 |
checkGraphRedNodeList(G, 2);
|
deba@1189
|
145 |
checkGraphBlueNodeList(G, 1);
|
deba@1189
|
146 |
checkGraphEdgeList(G, 2);
|
deba@1189
|
147 |
checkGraphArcList(G, 4);
|
deba@1189
|
148 |
|
deba@1189
|
149 |
checkGraphIncEdgeArcLists(G, n1, 1);
|
deba@1189
|
150 |
checkGraphIncEdgeArcLists(G, n2, 2);
|
deba@1189
|
151 |
checkGraphIncEdgeArcLists(G, n4, 1);
|
deba@1189
|
152 |
|
deba@1189
|
153 |
checkGraphConEdgeList(G, 2);
|
deba@1189
|
154 |
checkGraphConArcList(G, 4);
|
deba@1189
|
155 |
|
deba@1189
|
156 |
}
|
deba@1189
|
157 |
|
deba@1189
|
158 |
template <class BpGraph>
|
deba@1189
|
159 |
void checkBpGraphAlter() {
|
deba@1189
|
160 |
TEMPLATE_BPGRAPH_TYPEDEFS(BpGraph);
|
deba@1189
|
161 |
|
deba@1189
|
162 |
BpGraph G;
|
deba@1193
|
163 |
RedNode
|
deba@1193
|
164 |
n1 = G.addRedNode(), n4 = G.addRedNode();
|
deba@1193
|
165 |
BlueNode
|
deba@1193
|
166 |
n2 = G.addBlueNode(), n3 = G.addBlueNode();
|
deba@1189
|
167 |
Edge
|
deba@1189
|
168 |
e1 = G.addEdge(n1, n2), e2 = G.addEdge(n1, n3),
|
deba@1189
|
169 |
e3 = G.addEdge(n4, n2), e4 = G.addEdge(n4, n3);
|
deba@1189
|
170 |
|
deba@1189
|
171 |
G.changeRed(e2, n4);
|
deba@1189
|
172 |
check(G.redNode(e2) == n4, "Wrong red node");
|
deba@1189
|
173 |
check(G.blueNode(e2) == n3, "Wrong blue node");
|
deba@1189
|
174 |
|
deba@1189
|
175 |
checkGraphNodeList(G, 4);
|
deba@1189
|
176 |
checkGraphRedNodeList(G, 2);
|
deba@1189
|
177 |
checkGraphBlueNodeList(G, 2);
|
deba@1189
|
178 |
checkGraphEdgeList(G, 4);
|
deba@1189
|
179 |
checkGraphArcList(G, 8);
|
deba@1189
|
180 |
|
deba@1189
|
181 |
checkGraphIncEdgeArcLists(G, n1, 1);
|
deba@1189
|
182 |
checkGraphIncEdgeArcLists(G, n2, 2);
|
deba@1189
|
183 |
checkGraphIncEdgeArcLists(G, n3, 2);
|
deba@1189
|
184 |
checkGraphIncEdgeArcLists(G, n4, 3);
|
deba@1189
|
185 |
|
deba@1189
|
186 |
checkGraphConEdgeList(G, 4);
|
deba@1189
|
187 |
checkGraphConArcList(G, 8);
|
deba@1189
|
188 |
|
deba@1189
|
189 |
G.changeBlue(e2, n2);
|
deba@1189
|
190 |
check(G.redNode(e2) == n4, "Wrong red node");
|
deba@1189
|
191 |
check(G.blueNode(e2) == n2, "Wrong blue node");
|
deba@1189
|
192 |
|
deba@1189
|
193 |
checkGraphNodeList(G, 4);
|
deba@1189
|
194 |
checkGraphRedNodeList(G, 2);
|
deba@1189
|
195 |
checkGraphBlueNodeList(G, 2);
|
deba@1189
|
196 |
checkGraphEdgeList(G, 4);
|
deba@1189
|
197 |
checkGraphArcList(G, 8);
|
deba@1189
|
198 |
|
deba@1189
|
199 |
checkGraphIncEdgeArcLists(G, n1, 1);
|
deba@1189
|
200 |
checkGraphIncEdgeArcLists(G, n2, 3);
|
deba@1189
|
201 |
checkGraphIncEdgeArcLists(G, n3, 1);
|
deba@1189
|
202 |
checkGraphIncEdgeArcLists(G, n4, 3);
|
deba@1189
|
203 |
|
deba@1189
|
204 |
checkGraphConEdgeList(G, 4);
|
deba@1189
|
205 |
checkGraphConArcList(G, 8);
|
deba@1189
|
206 |
}
|
deba@1189
|
207 |
|
deba@1189
|
208 |
|
deba@1189
|
209 |
template <class BpGraph>
|
deba@1187
|
210 |
void checkBpGraphSnapshot() {
|
deba@1189
|
211 |
TEMPLATE_BPGRAPH_TYPEDEFS(BpGraph);
|
deba@1187
|
212 |
|
deba@1189
|
213 |
BpGraph G;
|
deba@1193
|
214 |
RedNode
|
deba@1193
|
215 |
n1 = G.addRedNode();
|
deba@1193
|
216 |
BlueNode
|
deba@1187
|
217 |
n2 = G.addBlueNode(),
|
deba@1187
|
218 |
n3 = G.addBlueNode();
|
deba@1187
|
219 |
Edge
|
deba@1187
|
220 |
e1 = G.addEdge(n1, n2),
|
deba@1187
|
221 |
e2 = G.addEdge(n1, n3);
|
deba@1187
|
222 |
|
deba@1187
|
223 |
checkGraphNodeList(G, 3);
|
deba@1187
|
224 |
checkGraphRedNodeList(G, 1);
|
deba@1187
|
225 |
checkGraphBlueNodeList(G, 2);
|
deba@1187
|
226 |
checkGraphEdgeList(G, 2);
|
deba@1187
|
227 |
checkGraphArcList(G, 4);
|
deba@1187
|
228 |
|
deba@1189
|
229 |
typename BpGraph::Snapshot snapshot(G);
|
deba@1187
|
230 |
|
deba@1193
|
231 |
RedNode n4 = G.addRedNode();
|
deba@1187
|
232 |
G.addEdge(n4, n2);
|
deba@1187
|
233 |
G.addEdge(n4, n3);
|
deba@1187
|
234 |
|
deba@1187
|
235 |
checkGraphNodeList(G, 4);
|
deba@1187
|
236 |
checkGraphRedNodeList(G, 2);
|
deba@1187
|
237 |
checkGraphBlueNodeList(G, 2);
|
deba@1187
|
238 |
checkGraphEdgeList(G, 4);
|
deba@1187
|
239 |
checkGraphArcList(G, 8);
|
deba@1187
|
240 |
|
deba@1187
|
241 |
snapshot.restore();
|
deba@1187
|
242 |
|
deba@1187
|
243 |
checkGraphNodeList(G, 3);
|
deba@1187
|
244 |
checkGraphRedNodeList(G, 1);
|
deba@1187
|
245 |
checkGraphBlueNodeList(G, 2);
|
deba@1187
|
246 |
checkGraphEdgeList(G, 2);
|
deba@1187
|
247 |
checkGraphArcList(G, 4);
|
deba@1187
|
248 |
|
deba@1187
|
249 |
checkGraphIncEdgeArcLists(G, n1, 2);
|
deba@1187
|
250 |
checkGraphIncEdgeArcLists(G, n2, 1);
|
deba@1187
|
251 |
checkGraphIncEdgeArcLists(G, n3, 1);
|
deba@1187
|
252 |
|
deba@1187
|
253 |
checkGraphConEdgeList(G, 2);
|
deba@1187
|
254 |
checkGraphConArcList(G, 4);
|
deba@1187
|
255 |
|
deba@1187
|
256 |
checkNodeIds(G);
|
deba@1187
|
257 |
checkRedNodeIds(G);
|
deba@1187
|
258 |
checkBlueNodeIds(G);
|
deba@1187
|
259 |
checkArcIds(G);
|
deba@1187
|
260 |
checkEdgeIds(G);
|
deba@1187
|
261 |
|
deba@1187
|
262 |
checkGraphNodeMap(G);
|
deba@1194
|
263 |
checkGraphRedNodeMap(G);
|
deba@1194
|
264 |
checkGraphBlueNodeMap(G);
|
deba@1187
|
265 |
checkGraphArcMap(G);
|
deba@1187
|
266 |
checkGraphEdgeMap(G);
|
deba@1187
|
267 |
|
deba@1187
|
268 |
G.addRedNode();
|
deba@1187
|
269 |
snapshot.save(G);
|
deba@1187
|
270 |
|
deba@1187
|
271 |
G.addEdge(G.addRedNode(), G.addBlueNode());
|
deba@1187
|
272 |
|
deba@1187
|
273 |
snapshot.restore();
|
deba@1187
|
274 |
snapshot.save(G);
|
deba@1187
|
275 |
|
deba@1187
|
276 |
checkGraphNodeList(G, 4);
|
deba@1187
|
277 |
checkGraphRedNodeList(G, 2);
|
deba@1187
|
278 |
checkGraphBlueNodeList(G, 2);
|
deba@1187
|
279 |
checkGraphEdgeList(G, 2);
|
deba@1187
|
280 |
checkGraphArcList(G, 4);
|
deba@1187
|
281 |
|
deba@1187
|
282 |
G.addEdge(G.addRedNode(), G.addBlueNode());
|
deba@1187
|
283 |
|
deba@1187
|
284 |
snapshot.restore();
|
deba@1187
|
285 |
|
deba@1187
|
286 |
checkGraphNodeList(G, 4);
|
deba@1187
|
287 |
checkGraphRedNodeList(G, 2);
|
deba@1187
|
288 |
checkGraphBlueNodeList(G, 2);
|
deba@1187
|
289 |
checkGraphEdgeList(G, 2);
|
deba@1187
|
290 |
checkGraphArcList(G, 4);
|
deba@1187
|
291 |
}
|
deba@1187
|
292 |
|
deba@1189
|
293 |
template <typename BpGraph>
|
deba@1187
|
294 |
void checkBpGraphValidity() {
|
deba@1189
|
295 |
TEMPLATE_BPGRAPH_TYPEDEFS(BpGraph);
|
deba@1189
|
296 |
BpGraph g;
|
deba@1187
|
297 |
|
deba@1193
|
298 |
RedNode
|
deba@1193
|
299 |
n1 = g.addRedNode();
|
deba@1193
|
300 |
BlueNode
|
deba@1187
|
301 |
n2 = g.addBlueNode(),
|
deba@1187
|
302 |
n3 = g.addBlueNode();
|
deba@1187
|
303 |
|
deba@1187
|
304 |
Edge
|
deba@1187
|
305 |
e1 = g.addEdge(n1, n2),
|
deba@1187
|
306 |
e2 = g.addEdge(n1, n3);
|
deba@1187
|
307 |
|
deba@1187
|
308 |
check(g.valid(n1), "Wrong validity check");
|
deba@1187
|
309 |
check(g.valid(e1), "Wrong validity check");
|
deba@1187
|
310 |
check(g.valid(g.direct(e1, true)), "Wrong validity check");
|
deba@1187
|
311 |
|
deba@1187
|
312 |
check(!g.valid(g.nodeFromId(-1)), "Wrong validity check");
|
deba@1187
|
313 |
check(!g.valid(g.edgeFromId(-1)), "Wrong validity check");
|
deba@1187
|
314 |
check(!g.valid(g.arcFromId(-1)), "Wrong validity check");
|
deba@1187
|
315 |
}
|
deba@1187
|
316 |
|
deba@1186
|
317 |
void checkConcepts() {
|
deba@1186
|
318 |
{ // Checking graph components
|
deba@1186
|
319 |
checkConcept<BaseBpGraphComponent, BaseBpGraphComponent >();
|
deba@1186
|
320 |
|
deba@1186
|
321 |
checkConcept<IDableBpGraphComponent<>,
|
deba@1186
|
322 |
IDableBpGraphComponent<> >();
|
deba@1186
|
323 |
|
deba@1186
|
324 |
checkConcept<IterableBpGraphComponent<>,
|
deba@1186
|
325 |
IterableBpGraphComponent<> >();
|
deba@1186
|
326 |
|
deba@1186
|
327 |
checkConcept<AlterableBpGraphComponent<>,
|
deba@1186
|
328 |
AlterableBpGraphComponent<> >();
|
deba@1186
|
329 |
|
deba@1186
|
330 |
checkConcept<MappableBpGraphComponent<>,
|
deba@1186
|
331 |
MappableBpGraphComponent<> >();
|
deba@1186
|
332 |
|
deba@1186
|
333 |
checkConcept<ExtendableBpGraphComponent<>,
|
deba@1186
|
334 |
ExtendableBpGraphComponent<> >();
|
deba@1186
|
335 |
|
deba@1186
|
336 |
checkConcept<ErasableBpGraphComponent<>,
|
deba@1186
|
337 |
ErasableBpGraphComponent<> >();
|
deba@1186
|
338 |
|
deba@1187
|
339 |
checkConcept<ClearableBpGraphComponent<>,
|
deba@1187
|
340 |
ClearableBpGraphComponent<> >();
|
deba@1186
|
341 |
|
deba@1186
|
342 |
}
|
deba@1186
|
343 |
{ // Checking skeleton graph
|
deba@1186
|
344 |
checkConcept<BpGraph, BpGraph>();
|
deba@1186
|
345 |
}
|
deba@1187
|
346 |
{ // Checking SmartBpGraph
|
deba@1187
|
347 |
checkConcept<BpGraph, SmartBpGraph>();
|
deba@1187
|
348 |
checkConcept<AlterableBpGraphComponent<>, SmartBpGraph>();
|
deba@1187
|
349 |
checkConcept<ExtendableBpGraphComponent<>, SmartBpGraph>();
|
deba@1187
|
350 |
checkConcept<ClearableBpGraphComponent<>, SmartBpGraph>();
|
deba@1187
|
351 |
}
|
deba@1186
|
352 |
}
|
deba@1186
|
353 |
|
deba@1188
|
354 |
void checkFullBpGraph(int redNum, int blueNum) {
|
deba@1188
|
355 |
typedef FullBpGraph BpGraph;
|
deba@1188
|
356 |
BPGRAPH_TYPEDEFS(BpGraph);
|
deba@1188
|
357 |
|
deba@1188
|
358 |
BpGraph G(redNum, blueNum);
|
deba@1188
|
359 |
checkGraphNodeList(G, redNum + blueNum);
|
deba@1188
|
360 |
checkGraphRedNodeList(G, redNum);
|
deba@1188
|
361 |
checkGraphBlueNodeList(G, blueNum);
|
deba@1188
|
362 |
checkGraphEdgeList(G, redNum * blueNum);
|
deba@1188
|
363 |
checkGraphArcList(G, 2 * redNum * blueNum);
|
deba@1188
|
364 |
|
deba@1188
|
365 |
G.resize(redNum, blueNum);
|
deba@1188
|
366 |
checkGraphNodeList(G, redNum + blueNum);
|
deba@1188
|
367 |
checkGraphRedNodeList(G, redNum);
|
deba@1188
|
368 |
checkGraphBlueNodeList(G, blueNum);
|
deba@1188
|
369 |
checkGraphEdgeList(G, redNum * blueNum);
|
deba@1188
|
370 |
checkGraphArcList(G, 2 * redNum * blueNum);
|
deba@1188
|
371 |
|
deba@1194
|
372 |
for (RedNodeIt n(G); n != INVALID; ++n) {
|
deba@1188
|
373 |
checkGraphOutArcList(G, n, blueNum);
|
deba@1188
|
374 |
checkGraphInArcList(G, n, blueNum);
|
deba@1188
|
375 |
checkGraphIncEdgeList(G, n, blueNum);
|
deba@1188
|
376 |
}
|
deba@1188
|
377 |
|
deba@1194
|
378 |
for (BlueNodeIt n(G); n != INVALID; ++n) {
|
deba@1188
|
379 |
checkGraphOutArcList(G, n, redNum);
|
deba@1188
|
380 |
checkGraphInArcList(G, n, redNum);
|
deba@1188
|
381 |
checkGraphIncEdgeList(G, n, redNum);
|
deba@1188
|
382 |
}
|
deba@1188
|
383 |
|
deba@1188
|
384 |
checkGraphConArcList(G, 2 * redNum * blueNum);
|
deba@1188
|
385 |
checkGraphConEdgeList(G, redNum * blueNum);
|
deba@1188
|
386 |
|
deba@1188
|
387 |
checkArcDirections(G);
|
deba@1188
|
388 |
|
deba@1188
|
389 |
checkNodeIds(G);
|
deba@1188
|
390 |
checkRedNodeIds(G);
|
deba@1188
|
391 |
checkBlueNodeIds(G);
|
deba@1188
|
392 |
checkArcIds(G);
|
deba@1188
|
393 |
checkEdgeIds(G);
|
deba@1188
|
394 |
|
deba@1188
|
395 |
checkGraphNodeMap(G);
|
deba@1194
|
396 |
checkGraphRedNodeMap(G);
|
deba@1194
|
397 |
checkGraphBlueNodeMap(G);
|
deba@1188
|
398 |
checkGraphArcMap(G);
|
deba@1188
|
399 |
checkGraphEdgeMap(G);
|
deba@1188
|
400 |
|
deba@1188
|
401 |
for (int i = 0; i < G.redNum(); ++i) {
|
deba@1188
|
402 |
check(G.red(G.redNode(i)), "Wrong node");
|
deba@1193
|
403 |
check(G.index(G.redNode(i)) == i, "Wrong index");
|
deba@1188
|
404 |
}
|
deba@1188
|
405 |
|
deba@1188
|
406 |
for (int i = 0; i < G.blueNum(); ++i) {
|
deba@1188
|
407 |
check(G.blue(G.blueNode(i)), "Wrong node");
|
deba@1193
|
408 |
check(G.index(G.blueNode(i)) == i, "Wrong index");
|
deba@1188
|
409 |
}
|
deba@1188
|
410 |
|
deba@1188
|
411 |
for (NodeIt u(G); u != INVALID; ++u) {
|
deba@1188
|
412 |
for (NodeIt v(G); v != INVALID; ++v) {
|
deba@1188
|
413 |
Edge e = G.edge(u, v);
|
deba@1188
|
414 |
Arc a = G.arc(u, v);
|
deba@1188
|
415 |
if (G.red(u) == G.red(v)) {
|
deba@1188
|
416 |
check(e == INVALID, "Wrong edge lookup");
|
deba@1188
|
417 |
check(a == INVALID, "Wrong arc lookup");
|
deba@1188
|
418 |
} else {
|
deba@1188
|
419 |
check((G.u(e) == u && G.v(e) == v) ||
|
deba@1188
|
420 |
(G.u(e) == v && G.v(e) == u), "Wrong edge lookup");
|
deba@1188
|
421 |
check(G.source(a) == u && G.target(a) == v, "Wrong arc lookup");
|
deba@1188
|
422 |
}
|
deba@1188
|
423 |
}
|
deba@1188
|
424 |
}
|
deba@1188
|
425 |
|
deba@1188
|
426 |
}
|
deba@1188
|
427 |
|
deba@1186
|
428 |
void checkGraphs() {
|
deba@1189
|
429 |
{ // Checking ListGraph
|
deba@1189
|
430 |
checkBpGraphBuild<ListBpGraph>();
|
deba@1189
|
431 |
checkBpGraphErase<ListBpGraph>();
|
deba@1189
|
432 |
checkBpGraphAlter<ListBpGraph>();
|
deba@1189
|
433 |
checkBpGraphSnapshot<ListBpGraph>();
|
deba@1189
|
434 |
checkBpGraphValidity<ListBpGraph>();
|
deba@1189
|
435 |
}
|
deba@1187
|
436 |
{ // Checking SmartGraph
|
deba@1187
|
437 |
checkBpGraphBuild<SmartBpGraph>();
|
deba@1187
|
438 |
checkBpGraphSnapshot<SmartBpGraph>();
|
deba@1187
|
439 |
checkBpGraphValidity<SmartBpGraph>();
|
deba@1187
|
440 |
}
|
deba@1188
|
441 |
{ // Checking FullBpGraph
|
deba@1188
|
442 |
checkFullBpGraph(6, 8);
|
deba@1188
|
443 |
checkFullBpGraph(7, 4);
|
deba@1188
|
444 |
}
|
deba@1186
|
445 |
}
|
deba@1186
|
446 |
|
deba@1186
|
447 |
int main() {
|
deba@1186
|
448 |
checkConcepts();
|
deba@1186
|
449 |
checkGraphs();
|
deba@1186
|
450 |
return 0;
|
deba@1186
|
451 |
}
|