gravatar
kpeter (Peter Kovacs)
kpeter@inf.elte.hu
Extend test cases for graphs and digraphs (#172)
0 3 0
default
3 files changed with 431 insertions and 37 deletions:
↑ Collapse diff ↑
Show white space 512 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5 5
 * Copyright (C) 2003-2008
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#include <lemon/concepts/digraph.h>
20 20
#include <lemon/list_graph.h>
21 21
#include <lemon/smart_graph.h>
22 22
//#include <lemon/full_graph.h>
23 23
//#include <lemon/hypercube_graph.h>
24 24

	
25 25
#include "test_tools.h"
26 26
#include "graph_test.h"
27 27

	
28 28
using namespace lemon;
29 29
using namespace lemon::concepts;
30 30

	
31 31
template <class Digraph>
32
void checkDigraph() {
32
void checkDigraphBuild() {
33 33
  TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
34 34
  Digraph G;
35 35

	
36 36
  checkGraphNodeList(G, 0);
37 37
  checkGraphArcList(G, 0);
38 38

	
39 39
  Node
40 40
    n1 = G.addNode(),
41 41
    n2 = G.addNode(),
42 42
    n3 = G.addNode();
43 43
  checkGraphNodeList(G, 3);
44 44
  checkGraphArcList(G, 0);
45 45

	
46 46
  Arc a1 = G.addArc(n1, n2);
47 47
  check(G.source(a1) == n1 && G.target(a1) == n2, "Wrong arc");
48 48
  checkGraphNodeList(G, 3);
49 49
  checkGraphArcList(G, 1);
50 50

	
51 51
  checkGraphOutArcList(G, n1, 1);
52 52
  checkGraphOutArcList(G, n2, 0);
53 53
  checkGraphOutArcList(G, n3, 0);
54 54

	
55 55
  checkGraphInArcList(G, n1, 0);
56 56
  checkGraphInArcList(G, n2, 1);
57 57
  checkGraphInArcList(G, n3, 0);
58 58

	
59 59
  checkGraphConArcList(G, 1);
60 60

	
61
  Arc a2 = G.addArc(n2, n1), a3 = G.addArc(n2, n3), a4 = G.addArc(n2, n3);
61
  Arc a2 = G.addArc(n2, n1),
62
      a3 = G.addArc(n2, n3),
63
      a4 = G.addArc(n2, n3);
64

	
65
  checkGraphNodeList(G, 3);
66
  checkGraphArcList(G, 4);
67

	
68
  checkGraphOutArcList(G, n1, 1);
69
  checkGraphOutArcList(G, n2, 3);
70
  checkGraphOutArcList(G, n3, 0);
71

	
72
  checkGraphInArcList(G, n1, 1);
73
  checkGraphInArcList(G, n2, 1);
74
  checkGraphInArcList(G, n3, 2);
75

	
76
  checkGraphConArcList(G, 4);
77

	
78
  checkNodeIds(G);
79
  checkArcIds(G);
80
  checkGraphNodeMap(G);
81
  checkGraphArcMap(G);
82
}
83

	
84
template <class Digraph>
85
void checkDigraphSplit() {
86
  TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
87

	
88
  Digraph G;
89
  Node n1 = G.addNode(), n2 = G.addNode(), n3 = G.addNode();
90
  Arc a1 = G.addArc(n1, n2), a2 = G.addArc(n2, n1),
91
      a3 = G.addArc(n2, n3), a4 = G.addArc(n2, n3);
92

	
93
  Node n4 = G.split(n2);
94

	
95
  check(G.target(OutArcIt(G, n2)) == n4 &&
96
        G.source(InArcIt(G, n4)) == n2,
97
        "Wrong split.");
98

	
99
  checkGraphNodeList(G, 4);
100
  checkGraphArcList(G, 5);
101

	
102
  checkGraphOutArcList(G, n1, 1);
103
  checkGraphOutArcList(G, n2, 1);
104
  checkGraphOutArcList(G, n3, 0);
105
  checkGraphOutArcList(G, n4, 3);
106

	
107
  checkGraphInArcList(G, n1, 1);
108
  checkGraphInArcList(G, n2, 1);
109
  checkGraphInArcList(G, n3, 2);
110
  checkGraphInArcList(G, n4, 1);
111

	
112
  checkGraphConArcList(G, 5);
113
}
114

	
115
template <class Digraph>
116
void checkDigraphAlter() {
117
  TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
118

	
119
  Digraph G;
120
  Node n1 = G.addNode(), n2 = G.addNode(),
121
       n3 = G.addNode(), n4 = G.addNode();
122
  Arc a1 = G.addArc(n1, n2), a2 = G.addArc(n4, n1),
123
      a3 = G.addArc(n4, n3), a4 = G.addArc(n4, n3),
124
      a5 = G.addArc(n2, n4);
125

	
126
  checkGraphNodeList(G, 4);
127
  checkGraphArcList(G, 5);
128

	
129
  // Check changeSource() and changeTarget()
130
  G.changeTarget(a4, n1);
131

	
132
  checkGraphNodeList(G, 4);
133
  checkGraphArcList(G, 5);
134

	
135
  checkGraphOutArcList(G, n1, 1);
136
  checkGraphOutArcList(G, n2, 1);
137
  checkGraphOutArcList(G, n3, 0);
138
  checkGraphOutArcList(G, n4, 3);
139

	
140
  checkGraphInArcList(G, n1, 2);
141
  checkGraphInArcList(G, n2, 1);
142
  checkGraphInArcList(G, n3, 1);
143
  checkGraphInArcList(G, n4, 1);
144

	
145
  checkGraphConArcList(G, 5);
146

	
147
  G.changeSource(a4, n3);
148

	
149
  checkGraphNodeList(G, 4);
150
  checkGraphArcList(G, 5);
151

	
152
  checkGraphOutArcList(G, n1, 1);
153
  checkGraphOutArcList(G, n2, 1);
154
  checkGraphOutArcList(G, n3, 1);
155
  checkGraphOutArcList(G, n4, 2);
156

	
157
  checkGraphInArcList(G, n1, 2);
158
  checkGraphInArcList(G, n2, 1);
159
  checkGraphInArcList(G, n3, 1);
160
  checkGraphInArcList(G, n4, 1);
161

	
162
  checkGraphConArcList(G, 5);
163

	
164
  // Check contract()
165
  G.contract(n2, n4, false);
166

	
167
  checkGraphNodeList(G, 3);
168
  checkGraphArcList(G, 5);
169

	
170
  checkGraphOutArcList(G, n1, 1);
171
  checkGraphOutArcList(G, n2, 3);
172
  checkGraphOutArcList(G, n3, 1);
173

	
174
  checkGraphInArcList(G, n1, 2);
175
  checkGraphInArcList(G, n2, 2);
176
  checkGraphInArcList(G, n3, 1);
177

	
178
  checkGraphConArcList(G, 5);
179

	
180
  G.contract(n2, n1);
181

	
182
  checkGraphNodeList(G, 2);
183
  checkGraphArcList(G, 3);
184

	
185
  checkGraphOutArcList(G, n2, 2);
186
  checkGraphOutArcList(G, n3, 1);
187

	
188
  checkGraphInArcList(G, n2, 2);
189
  checkGraphInArcList(G, n3, 1);
190

	
191
  checkGraphConArcList(G, 3);
192
}
193

	
194
template <class Digraph>
195
void checkDigraphErase() {
196
  TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
197

	
198
  Digraph G;
199
  Node n1 = G.addNode(), n2 = G.addNode(),
200
       n3 = G.addNode(), n4 = G.addNode();
201
  Arc a1 = G.addArc(n1, n2), a2 = G.addArc(n4, n1),
202
      a3 = G.addArc(n4, n3), a4 = G.addArc(n3, n1),
203
      a5 = G.addArc(n2, n4);
204

	
205
  // Check arc deletion
206
  G.erase(a1);
207

	
208
  checkGraphNodeList(G, 4);
209
  checkGraphArcList(G, 4);
210

	
211
  checkGraphOutArcList(G, n1, 0);
212
  checkGraphOutArcList(G, n2, 1);
213
  checkGraphOutArcList(G, n3, 1);
214
  checkGraphOutArcList(G, n4, 2);
215

	
216
  checkGraphInArcList(G, n1, 2);
217
  checkGraphInArcList(G, n2, 0);
218
  checkGraphInArcList(G, n3, 1);
219
  checkGraphInArcList(G, n4, 1);
220

	
221
  checkGraphConArcList(G, 4);
222

	
223
  // Check node deletion
224
  G.erase(n4);
225

	
226
  checkGraphNodeList(G, 3);
227
  checkGraphArcList(G, 1);
228

	
229
  checkGraphOutArcList(G, n1, 0);
230
  checkGraphOutArcList(G, n2, 0);
231
  checkGraphOutArcList(G, n3, 1);
232
  checkGraphOutArcList(G, n4, 0);
233

	
234
  checkGraphInArcList(G, n1, 1);
235
  checkGraphInArcList(G, n2, 0);
236
  checkGraphInArcList(G, n3, 0);
237
  checkGraphInArcList(G, n4, 0);
238

	
239
  checkGraphConArcList(G, 1);
240
}
241

	
242

	
243
template <class Digraph>
244
void checkDigraphSnapshot() {
245
  TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
246

	
247
  Digraph G;
248
  Node n1 = G.addNode(), n2 = G.addNode(), n3 = G.addNode();
249
  Arc a1 = G.addArc(n1, n2), a2 = G.addArc(n2, n1),
250
      a3 = G.addArc(n2, n3), a4 = G.addArc(n2, n3);
251

	
252
  typename Digraph::Snapshot snapshot(G);
253

	
254
  Node n = G.addNode();
255
  G.addArc(n3, n);
256
  G.addArc(n, n3);
257

	
258
  checkGraphNodeList(G, 4);
259
  checkGraphArcList(G, 6);
260

	
261
  snapshot.restore();
262

	
62 263
  checkGraphNodeList(G, 3);
63 264
  checkGraphArcList(G, 4);
64 265

	
65 266
  checkGraphOutArcList(G, n1, 1);
66 267
  checkGraphOutArcList(G, n2, 3);
67 268
  checkGraphOutArcList(G, n3, 0);
68 269

	
69 270
  checkGraphInArcList(G, n1, 1);
70 271
  checkGraphInArcList(G, n2, 1);
71 272
  checkGraphInArcList(G, n3, 2);
72 273

	
73 274
  checkGraphConArcList(G, 4);
74 275

	
75 276
  checkNodeIds(G);
76 277
  checkArcIds(G);
77 278
  checkGraphNodeMap(G);
78 279
  checkGraphArcMap(G);
79 280

	
281
  G.addNode();
282
  snapshot.save(G);
283

	
284
  G.addArc(G.addNode(), G.addNode());
285

	
286
  snapshot.restore();
287

	
288
  checkGraphNodeList(G, 4);
289
  checkGraphArcList(G, 4);
80 290
}
81 291

	
82

	
83 292
void checkConcepts() {
84 293
  { // Checking digraph components
85 294
    checkConcept<BaseDigraphComponent, BaseDigraphComponent >();
86 295

	
87 296
    checkConcept<IDableDigraphComponent<>,
88 297
      IDableDigraphComponent<> >();
89 298

	
90 299
    checkConcept<IterableDigraphComponent<>,
91 300
      IterableDigraphComponent<> >();
92 301

	
93 302
    checkConcept<MappableDigraphComponent<>,
94 303
      MappableDigraphComponent<> >();
95 304
  }
96 305
  { // Checking skeleton digraph
97 306
    checkConcept<Digraph, Digraph>();
98 307
  }
99 308
  { // Checking ListDigraph
100 309
    checkConcept<Digraph, ListDigraph>();
101 310
    checkConcept<AlterableDigraphComponent<>, ListDigraph>();
102 311
    checkConcept<ExtendableDigraphComponent<>, ListDigraph>();
103 312
    checkConcept<ClearableDigraphComponent<>, ListDigraph>();
104 313
    checkConcept<ErasableDigraphComponent<>, ListDigraph>();
105 314
  }
106 315
  { // Checking SmartDigraph
107 316
    checkConcept<Digraph, SmartDigraph>();
108 317
    checkConcept<AlterableDigraphComponent<>, SmartDigraph>();
109 318
    checkConcept<ExtendableDigraphComponent<>, SmartDigraph>();
110 319
    checkConcept<ClearableDigraphComponent<>, SmartDigraph>();
111 320
  }
112 321
//  { // Checking FullDigraph
113 322
//    checkConcept<Digraph, FullDigraph>();
114 323
//  }
115 324
//  { // Checking HyperCubeDigraph
116 325
//    checkConcept<Digraph, HyperCubeDigraph>();
117 326
//  }
118 327
}
119 328

	
120 329
template <typename Digraph>
121 330
void checkDigraphValidity() {
122 331
  TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
123 332
  Digraph g;
124 333

	
125 334
  Node
126 335
    n1 = g.addNode(),
127 336
    n2 = g.addNode(),
128 337
    n3 = g.addNode();
129 338

	
130 339
  Arc
131 340
    e1 = g.addArc(n1, n2),
132 341
    e2 = g.addArc(n2, n3);
133 342

	
134 343
  check(g.valid(n1), "Wrong validity check");
135 344
  check(g.valid(e1), "Wrong validity check");
136 345

	
137 346
  check(!g.valid(g.nodeFromId(-1)), "Wrong validity check");
138 347
  check(!g.valid(g.arcFromId(-1)), "Wrong validity check");
139 348
}
140 349

	
141 350
template <typename Digraph>
142 351
void checkDigraphValidityErase() {
143 352
  TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
144 353
  Digraph g;
145 354

	
146 355
  Node
147 356
    n1 = g.addNode(),
148 357
    n2 = g.addNode(),
149 358
    n3 = g.addNode();
150 359

	
151 360
  Arc
152 361
    e1 = g.addArc(n1, n2),
153 362
    e2 = g.addArc(n2, n3);
154 363

	
155 364
  check(g.valid(n1), "Wrong validity check");
156 365
  check(g.valid(e1), "Wrong validity check");
157 366

	
158 367
  g.erase(n1);
159 368

	
160 369
  check(!g.valid(n1), "Wrong validity check");
161 370
  check(g.valid(n2), "Wrong validity check");
162 371
  check(g.valid(n3), "Wrong validity check");
163 372
  check(!g.valid(e1), "Wrong validity check");
164 373
  check(g.valid(e2), "Wrong validity check");
165 374

	
166 375
  check(!g.valid(g.nodeFromId(-1)), "Wrong validity check");
167 376
  check(!g.valid(g.arcFromId(-1)), "Wrong validity check");
168 377
}
169 378

	
170 379
void checkDigraphs() {
171 380
  { // Checking ListDigraph
172
    checkDigraph<ListDigraph>();
381
    checkDigraphBuild<ListDigraph>();
382
    checkDigraphSplit<ListDigraph>();
383
    checkDigraphAlter<ListDigraph>();
384
    checkDigraphErase<ListDigraph>();
385
    checkDigraphSnapshot<ListDigraph>();
173 386
    checkDigraphValidityErase<ListDigraph>();
174 387
  }
175 388
  { // Checking SmartDigraph
176
    checkDigraph<SmartDigraph>();
389
    checkDigraphBuild<SmartDigraph>();
390
    checkDigraphSplit<SmartDigraph>();
391
    checkDigraphSnapshot<SmartDigraph>();
177 392
    checkDigraphValidity<SmartDigraph>();
178 393
  }
179 394
}
180 395

	
181 396
int main() {
182 397
  checkDigraphs();
183 398
  checkConcepts();
184 399
  return 0;
185 400
}
Show white space 512 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5 5
 * Copyright (C) 2003-2008
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#include <lemon/concepts/graph.h>
20 20
#include <lemon/list_graph.h>
21 21
#include <lemon/smart_graph.h>
22 22
// #include <lemon/full_graph.h>
23 23
// #include <lemon/grid_graph.h>
24 24

	
25 25
#include "test_tools.h"
26 26
#include "graph_test.h"
27 27

	
28 28
using namespace lemon;
29 29
using namespace lemon::concepts;
30 30

	
31 31
template <class Graph>
32
void checkGraph() {
32
void checkGraphBuild() {
33 33
  TEMPLATE_GRAPH_TYPEDEFS(Graph);
34 34

	
35 35
  Graph G;
36 36
  checkGraphNodeList(G, 0);
37 37
  checkGraphEdgeList(G, 0);
38
  checkGraphArcList(G, 0);
38 39

	
39 40
  Node
40 41
    n1 = G.addNode(),
41 42
    n2 = G.addNode(),
42 43
    n3 = G.addNode();
43 44
  checkGraphNodeList(G, 3);
44 45
  checkGraphEdgeList(G, 0);
46
  checkGraphArcList(G, 0);
45 47

	
46 48
  Edge e1 = G.addEdge(n1, n2);
47 49
  check((G.u(e1) == n1 && G.v(e1) == n2) || (G.u(e1) == n2 && G.v(e1) == n1),
48 50
        "Wrong edge");
51

	
49 52
  checkGraphNodeList(G, 3);
53
  checkGraphEdgeList(G, 1);
50 54
  checkGraphArcList(G, 2);
51
  checkGraphEdgeList(G, 1);
52 55

	
53
  checkGraphOutArcList(G, n1, 1);
54
  checkGraphOutArcList(G, n2, 1);
55
  checkGraphOutArcList(G, n3, 0);
56
  checkGraphIncEdgeArcLists(G, n1, 1);
57
  checkGraphIncEdgeArcLists(G, n2, 1);
58
  checkGraphIncEdgeArcLists(G, n3, 0);
56 59

	
57
  checkGraphInArcList(G, n1, 1);
58
  checkGraphInArcList(G, n2, 1);
59
  checkGraphInArcList(G, n3, 0);
60
  checkGraphConEdgeList(G, 1);
61
  checkGraphConArcList(G, 2);
60 62

	
61
  checkGraphIncEdgeList(G, n1, 1);
62
  checkGraphIncEdgeList(G, n2, 1);
63
  checkGraphIncEdgeList(G, n3, 0);
63
  Edge e2 = G.addEdge(n2, n1),
64
       e3 = G.addEdge(n2, n3);
64 65

	
65
  checkGraphConArcList(G, 2);
66
  checkGraphConEdgeList(G, 1);
66
  checkGraphNodeList(G, 3);
67
  checkGraphEdgeList(G, 3);
68
  checkGraphArcList(G, 6);
67 69

	
68
  Edge e2 = G.addEdge(n2, n1), e3 = G.addEdge(n2, n3);
69
  checkGraphNodeList(G, 3);
70
  checkGraphArcList(G, 6);
71
  checkGraphEdgeList(G, 3);
70
  checkGraphIncEdgeArcLists(G, n1, 2);
71
  checkGraphIncEdgeArcLists(G, n2, 3);
72
  checkGraphIncEdgeArcLists(G, n3, 1);
72 73

	
73
  checkGraphOutArcList(G, n1, 2);
74
  checkGraphOutArcList(G, n2, 3);
75
  checkGraphOutArcList(G, n3, 1);
76

	
77
  checkGraphInArcList(G, n1, 2);
78
  checkGraphInArcList(G, n2, 3);
79
  checkGraphInArcList(G, n3, 1);
80

	
81
  checkGraphIncEdgeList(G, n1, 2);
82
  checkGraphIncEdgeList(G, n2, 3);
83
  checkGraphIncEdgeList(G, n3, 1);
84

	
74
  checkGraphConEdgeList(G, 3);
85 75
  checkGraphConArcList(G, 6);
86
  checkGraphConEdgeList(G, 3);
87 76

	
88 77
  checkArcDirections(G);
89 78

	
90 79
  checkNodeIds(G);
91 80
  checkArcIds(G);
92 81
  checkEdgeIds(G);
93 82
  checkGraphNodeMap(G);
94 83
  checkGraphArcMap(G);
95 84
  checkGraphEdgeMap(G);
96 85
}
97 86

	
87
template <class Graph>
88
void checkGraphAlter() {
89
  TEMPLATE_GRAPH_TYPEDEFS(Graph);
90

	
91
  Graph G;
92
  Node n1 = G.addNode(), n2 = G.addNode(),
93
       n3 = G.addNode(), n4 = G.addNode();
94
  Edge e1 = G.addEdge(n1, n2), e2 = G.addEdge(n2, n1),
95
       e3 = G.addEdge(n2, n3), e4 = G.addEdge(n1, n4),
96
       e5 = G.addEdge(n4, n3);
97

	
98
  checkGraphNodeList(G, 4);
99
  checkGraphEdgeList(G, 5);
100
  checkGraphArcList(G, 10);
101

	
102
  // Check changeU() and changeV()
103
  if (G.u(e2) == n2) {
104
    G.changeU(e2, n3);
105
  } else {
106
    G.changeV(e2, n3);
107
  }
108

	
109
  checkGraphNodeList(G, 4);
110
  checkGraphEdgeList(G, 5);
111
  checkGraphArcList(G, 10);
112

	
113
  checkGraphIncEdgeArcLists(G, n1, 3);
114
  checkGraphIncEdgeArcLists(G, n2, 2);
115
  checkGraphIncEdgeArcLists(G, n3, 3);
116
  checkGraphIncEdgeArcLists(G, n4, 2);
117

	
118
  checkGraphConEdgeList(G, 5);
119
  checkGraphConArcList(G, 10);
120

	
121
  if (G.u(e2) == n1) {
122
    G.changeU(e2, n2);
123
  } else {
124
    G.changeV(e2, n2);
125
  }
126

	
127
  checkGraphNodeList(G, 4);
128
  checkGraphEdgeList(G, 5);
129
  checkGraphArcList(G, 10);
130

	
131
  checkGraphIncEdgeArcLists(G, n1, 2);
132
  checkGraphIncEdgeArcLists(G, n2, 3);
133
  checkGraphIncEdgeArcLists(G, n3, 3);
134
  checkGraphIncEdgeArcLists(G, n4, 2);
135

	
136
  checkGraphConEdgeList(G, 5);
137
  checkGraphConArcList(G, 10);
138

	
139
  // Check contract()
140
  G.contract(n1, n4, false);
141

	
142
  checkGraphNodeList(G, 3);
143
  checkGraphEdgeList(G, 5);
144
  checkGraphArcList(G, 10);
145

	
146
  checkGraphIncEdgeArcLists(G, n1, 4);
147
  checkGraphIncEdgeArcLists(G, n2, 3);
148
  checkGraphIncEdgeArcLists(G, n3, 3);
149

	
150
  checkGraphConEdgeList(G, 5);
151
  checkGraphConArcList(G, 10);
152

	
153
  G.contract(n2, n3);
154

	
155
  checkGraphNodeList(G, 2);
156
  checkGraphEdgeList(G, 3);
157
  checkGraphArcList(G, 6);
158

	
159
  checkGraphIncEdgeArcLists(G, n1, 4);
160
  checkGraphIncEdgeArcLists(G, n2, 2);
161

	
162
  checkGraphConEdgeList(G, 3);
163
  checkGraphConArcList(G, 6);
164
}
165

	
166
template <class Graph>
167
void checkGraphErase() {
168
  TEMPLATE_GRAPH_TYPEDEFS(Graph);
169

	
170
  Graph G;
171
  Node n1 = G.addNode(), n2 = G.addNode(),
172
       n3 = G.addNode(), n4 = G.addNode();
173
  Edge e1 = G.addEdge(n1, n2), e2 = G.addEdge(n2, n1),
174
       e3 = G.addEdge(n2, n3), e4 = G.addEdge(n1, n4),
175
       e5 = G.addEdge(n4, n3);
176

	
177
  // Check edge deletion
178
  G.erase(e2);
179

	
180
  checkGraphNodeList(G, 4);
181
  checkGraphEdgeList(G, 4);
182
  checkGraphArcList(G, 8);
183

	
184
  checkGraphIncEdgeArcLists(G, n1, 2);
185
  checkGraphIncEdgeArcLists(G, n2, 2);
186
  checkGraphIncEdgeArcLists(G, n3, 2);
187
  checkGraphIncEdgeArcLists(G, n4, 2);
188

	
189
  checkGraphConEdgeList(G, 4);
190
  checkGraphConArcList(G, 8);
191

	
192
  // Check node deletion
193
  G.erase(n3);
194

	
195
  checkGraphNodeList(G, 3);
196
  checkGraphEdgeList(G, 2);
197
  checkGraphArcList(G, 4);
198

	
199
  checkGraphIncEdgeArcLists(G, n1, 2);
200
  checkGraphIncEdgeArcLists(G, n2, 1);
201
  checkGraphIncEdgeArcLists(G, n4, 1);
202

	
203
  checkGraphConEdgeList(G, 2);
204
  checkGraphConArcList(G, 4);
205
}
206

	
207

	
208
template <class Graph>
209
void checkGraphSnapshot() {
210
  TEMPLATE_GRAPH_TYPEDEFS(Graph);
211

	
212
  Graph G;
213
  Node n1 = G.addNode(), n2 = G.addNode(), n3 = G.addNode();
214
  Edge e1 = G.addEdge(n1, n2), e2 = G.addEdge(n2, n1),
215
       e3 = G.addEdge(n2, n3);
216

	
217
  checkGraphNodeList(G, 3);
218
  checkGraphEdgeList(G, 3);
219
  checkGraphArcList(G, 6);
220

	
221
  typename Graph::Snapshot snapshot(G);
222

	
223
  Node n = G.addNode();
224
  G.addEdge(n3, n);
225
  G.addEdge(n, n3);
226
  G.addEdge(n3, n2);
227

	
228
  checkGraphNodeList(G, 4);
229
  checkGraphEdgeList(G, 6);
230
  checkGraphArcList(G, 12);
231

	
232
  snapshot.restore();
233

	
234
  checkGraphNodeList(G, 3);
235
  checkGraphEdgeList(G, 3);
236
  checkGraphArcList(G, 6);
237

	
238
  checkGraphIncEdgeArcLists(G, n1, 2);
239
  checkGraphIncEdgeArcLists(G, n2, 3);
240
  checkGraphIncEdgeArcLists(G, n3, 1);
241

	
242
  checkGraphConEdgeList(G, 3);
243
  checkGraphConArcList(G, 6);
244

	
245
  checkNodeIds(G);
246
  checkEdgeIds(G);
247
  checkArcIds(G);
248
  checkGraphNodeMap(G);
249
  checkGraphEdgeMap(G);
250
  checkGraphArcMap(G);
251

	
252
  G.addNode();
253
  snapshot.save(G);
254

	
255
  G.addEdge(G.addNode(), G.addNode());
256

	
257
  snapshot.restore();
258

	
259
  checkGraphNodeList(G, 4);
260
  checkGraphEdgeList(G, 3);
261
  checkGraphArcList(G, 6);
262
}
263

	
98 264
void checkConcepts() {
99 265
  { // Checking graph components
100 266
    checkConcept<BaseGraphComponent, BaseGraphComponent >();
101 267

	
102 268
    checkConcept<IDableGraphComponent<>,
103 269
      IDableGraphComponent<> >();
104 270

	
105 271
    checkConcept<IterableGraphComponent<>,
106 272
      IterableGraphComponent<> >();
107 273

	
108 274
    checkConcept<MappableGraphComponent<>,
109 275
      MappableGraphComponent<> >();
110 276
  }
111 277
  { // Checking skeleton graph
112 278
    checkConcept<Graph, Graph>();
113 279
  }
114 280
  { // Checking ListGraph
115 281
    checkConcept<Graph, ListGraph>();
116 282
    checkConcept<AlterableGraphComponent<>, ListGraph>();
117 283
    checkConcept<ExtendableGraphComponent<>, ListGraph>();
118 284
    checkConcept<ClearableGraphComponent<>, ListGraph>();
119 285
    checkConcept<ErasableGraphComponent<>, ListGraph>();
120 286
  }
121 287
  { // Checking SmartGraph
122 288
    checkConcept<Graph, SmartGraph>();
123 289
    checkConcept<AlterableGraphComponent<>, SmartGraph>();
124 290
    checkConcept<ExtendableGraphComponent<>, SmartGraph>();
125 291
    checkConcept<ClearableGraphComponent<>, SmartGraph>();
126 292
  }
127 293
//  { // Checking FullGraph
128 294
//    checkConcept<Graph, FullGraph>();
129 295
//    checkGraphIterators<FullGraph>();
130 296
//  }
131 297
//  { // Checking GridGraph
132 298
//    checkConcept<Graph, GridGraph>();
133 299
//    checkGraphIterators<GridGraph>();
134 300
//  }
135 301
}
136 302

	
137 303
template <typename Graph>
138 304
void checkGraphValidity() {
139 305
  TEMPLATE_GRAPH_TYPEDEFS(Graph);
140 306
  Graph g;
141 307

	
142 308
  Node
143 309
    n1 = g.addNode(),
144 310
    n2 = g.addNode(),
145 311
    n3 = g.addNode();
146 312

	
147 313
  Edge
148 314
    e1 = g.addEdge(n1, n2),
149 315
    e2 = g.addEdge(n2, n3);
150 316

	
151 317
  check(g.valid(n1), "Wrong validity check");
152 318
  check(g.valid(e1), "Wrong validity check");
153 319
  check(g.valid(g.direct(e1, true)), "Wrong validity check");
154 320

	
155 321
  check(!g.valid(g.nodeFromId(-1)), "Wrong validity check");
156 322
  check(!g.valid(g.edgeFromId(-1)), "Wrong validity check");
157 323
  check(!g.valid(g.arcFromId(-1)), "Wrong validity check");
158 324
}
159 325

	
160 326
template <typename Graph>
161 327
void checkGraphValidityErase() {
162 328
  TEMPLATE_GRAPH_TYPEDEFS(Graph);
163 329
  Graph g;
164 330

	
165 331
  Node
166 332
    n1 = g.addNode(),
167 333
    n2 = g.addNode(),
168 334
    n3 = g.addNode();
169 335

	
170 336
  Edge
171 337
    e1 = g.addEdge(n1, n2),
172 338
    e2 = g.addEdge(n2, n3);
173 339

	
174 340
  check(g.valid(n1), "Wrong validity check");
175 341
  check(g.valid(e1), "Wrong validity check");
176 342
  check(g.valid(g.direct(e1, true)), "Wrong validity check");
177 343

	
178 344
  g.erase(n1);
179 345

	
180 346
  check(!g.valid(n1), "Wrong validity check");
181 347
  check(g.valid(n2), "Wrong validity check");
182 348
  check(g.valid(n3), "Wrong validity check");
183 349
  check(!g.valid(e1), "Wrong validity check");
184 350
  check(g.valid(e2), "Wrong validity check");
185 351

	
186 352
  check(!g.valid(g.nodeFromId(-1)), "Wrong validity check");
187 353
  check(!g.valid(g.edgeFromId(-1)), "Wrong validity check");
188 354
  check(!g.valid(g.arcFromId(-1)), "Wrong validity check");
189 355
}
190 356

	
191 357
// void checkGridGraph(const GridGraph& g, int w, int h) {
192 358
//   check(g.width() == w, "Wrong width");
193 359
//   check(g.height() == h, "Wrong height");
194 360

	
195 361
//   for (int i = 0; i < w; ++i) {
196 362
//     for (int j = 0; j < h; ++j) {
197 363
//       check(g.col(g(i, j)) == i, "Wrong col");
198 364
//       check(g.row(g(i, j)) == j, "Wrong row");
199 365
//     }
200 366
//   }
201 367

	
202 368
//   for (int i = 0; i < w; ++i) {
203 369
//     for (int j = 0; j < h - 1; ++j) {
204 370
//       check(g.source(g.down(g(i, j))) == g(i, j), "Wrong down");
205 371
//       check(g.target(g.down(g(i, j))) == g(i, j + 1), "Wrong down");
206 372
//     }
207 373
//     check(g.down(g(i, h - 1)) == INVALID, "Wrong down");
208 374
//   }
209 375

	
210 376
//   for (int i = 0; i < w; ++i) {
211 377
//     for (int j = 1; j < h; ++j) {
212 378
//       check(g.source(g.up(g(i, j))) == g(i, j), "Wrong up");
213 379
//       check(g.target(g.up(g(i, j))) == g(i, j - 1), "Wrong up");
214 380
//     }
215 381
//     check(g.up(g(i, 0)) == INVALID, "Wrong up");
216 382
//   }
217 383

	
218 384
//   for (int j = 0; j < h; ++j) {
219 385
//     for (int i = 0; i < w - 1; ++i) {
220 386
//       check(g.source(g.right(g(i, j))) == g(i, j), "Wrong right");
221 387
//       check(g.target(g.right(g(i, j))) == g(i + 1, j), "Wrong right");
222 388
//     }
223 389
//     check(g.right(g(w - 1, j)) == INVALID, "Wrong right");
224 390
//   }
225 391

	
226 392
//   for (int j = 0; j < h; ++j) {
227 393
//     for (int i = 1; i < w; ++i) {
228 394
//       check(g.source(g.left(g(i, j))) == g(i, j), "Wrong left");
229 395
//       check(g.target(g.left(g(i, j))) == g(i - 1, j), "Wrong left");
230 396
//     }
231 397
//     check(g.left(g(0, j)) == INVALID, "Wrong left");
232 398
//   }
233 399
// }
234 400

	
235 401
void checkGraphs() {
236 402
  { // Checking ListGraph
237
    checkGraph<ListGraph>();
403
    checkGraphBuild<ListGraph>();
404
    checkGraphAlter<ListGraph>();
405
    checkGraphErase<ListGraph>();
406
    checkGraphSnapshot<ListGraph>();
238 407
    checkGraphValidityErase<ListGraph>();
239 408
  }
240 409
  { // Checking SmartGraph
241
    checkGraph<SmartGraph>();
410
    checkGraphBuild<SmartGraph>();
411
    checkGraphSnapshot<SmartGraph>();
242 412
    checkGraphValidity<SmartGraph>();
243 413
  }
244 414
//   { // Checking FullGraph
245 415
//     FullGraph g(5);
246 416
//     checkGraphNodeList(g, 5);
247 417
//     checkGraphEdgeList(g, 10);
248 418
//   }
249 419
//   { // Checking GridGraph
250 420
//     GridGraph g(5, 6);
251 421
//     checkGraphNodeList(g, 30);
252 422
//     checkGraphEdgeList(g, 49);
253 423
//     checkGridGraph(g, 5, 6);
254 424
//   }
255 425
}
256 426

	
257 427
int main() {
258 428
  checkConcepts();
259 429
  checkGraphs();
260 430
  return 0;
261 431
}
Show white space 512 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5 5
 * Copyright (C) 2003-2008
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#ifndef LEMON_TEST_GRAPH_TEST_H
20 20
#define LEMON_TEST_GRAPH_TEST_H
21 21

	
22 22
#include <set>
23 23

	
24 24
#include <lemon/core.h>
25 25
#include <lemon/maps.h>
26 26

	
27 27
#include "test_tools.h"
28 28

	
29 29
namespace lemon {
30 30

	
31 31
  template<class Graph>
32 32
  void checkGraphNodeList(const Graph &G, int cnt)
33 33
  {
34 34
    typename Graph::NodeIt n(G);
35 35
    for(int i=0;i<cnt;i++) {
36 36
      check(n!=INVALID,"Wrong Node list linking.");
37 37
      ++n;
38 38
    }
39 39
    check(n==INVALID,"Wrong Node list linking.");
40 40
    check(countNodes(G)==cnt,"Wrong Node number.");
41 41
  }
42 42

	
43 43
  template<class Graph>
44 44
  void checkGraphArcList(const Graph &G, int cnt)
45 45
  {
46 46
    typename Graph::ArcIt e(G);
47 47
    for(int i=0;i<cnt;i++) {
48 48
      check(e!=INVALID,"Wrong Arc list linking.");
49 49
      check(G.oppositeNode(G.source(e), e) == G.target(e),
50 50
            "Wrong opposite node");
51 51
      check(G.oppositeNode(G.target(e), e) == G.source(e),
52 52
            "Wrong opposite node");
53 53
      ++e;
54 54
    }
55 55
    check(e==INVALID,"Wrong Arc list linking.");
56 56
    check(countArcs(G)==cnt,"Wrong Arc number.");
57 57
  }
58 58

	
59 59
  template<class Graph>
60 60
  void checkGraphOutArcList(const Graph &G, typename Graph::Node n, int cnt)
61 61
  {
62 62
    typename Graph::OutArcIt e(G,n);
63 63
    for(int i=0;i<cnt;i++) {
64 64
      check(e!=INVALID,"Wrong OutArc list linking.");
65 65
      check(n==G.source(e),"Wrong OutArc list linking.");
66 66
      check(n==G.baseNode(e),"Wrong OutArc list linking.");
67 67
      check(G.target(e)==G.runningNode(e),"Wrong OutArc list linking.");
68 68
      ++e;
69 69
    }
70 70
    check(e==INVALID,"Wrong OutArc list linking.");
71 71
    check(countOutArcs(G,n)==cnt,"Wrong OutArc number.");
72 72
  }
73 73

	
74 74
  template<class Graph>
75 75
  void checkGraphInArcList(const Graph &G, typename Graph::Node n, int cnt)
76 76
  {
77 77
    typename Graph::InArcIt e(G,n);
78 78
    for(int i=0;i<cnt;i++) {
79 79
      check(e!=INVALID,"Wrong InArc list linking.");
80 80
      check(n==G.target(e),"Wrong InArc list linking.");
81 81
      check(n==G.baseNode(e),"Wrong OutArc list linking.");
82 82
      check(G.source(e)==G.runningNode(e),"Wrong OutArc list linking.");
83 83
      ++e;
84 84
    }
85 85
    check(e==INVALID,"Wrong InArc list linking.");
86 86
    check(countInArcs(G,n)==cnt,"Wrong InArc number.");
87 87
  }
88 88

	
89 89
  template<class Graph>
90 90
  void checkGraphEdgeList(const Graph &G, int cnt)
91 91
  {
92 92
    typename Graph::EdgeIt e(G);
93 93
    for(int i=0;i<cnt;i++) {
94 94
      check(e!=INVALID,"Wrong Edge list linking.");
95 95
      check(G.oppositeNode(G.u(e), e) == G.v(e), "Wrong opposite node");
96 96
      check(G.oppositeNode(G.v(e), e) == G.u(e), "Wrong opposite node");
97 97
      ++e;
98 98
    }
99 99
    check(e==INVALID,"Wrong Edge list linking.");
100 100
    check(countEdges(G)==cnt,"Wrong Edge number.");
101 101
  }
102 102

	
103 103
  template<class Graph>
104 104
  void checkGraphIncEdgeList(const Graph &G, typename Graph::Node n, int cnt)
105 105
  {
106 106
    typename Graph::IncEdgeIt e(G,n);
107 107
    for(int i=0;i<cnt;i++) {
108 108
      check(e!=INVALID,"Wrong IncEdge list linking.");
109 109
      check(n==G.u(e) || n==G.v(e),"Wrong IncEdge list linking.");
110 110
      check(n==G.baseNode(e),"Wrong OutArc list linking.");
111 111
      check(G.u(e)==G.runningNode(e) || G.v(e)==G.runningNode(e),
112 112
            "Wrong OutArc list linking.");
113 113
      ++e;
114 114
    }
115 115
    check(e==INVALID,"Wrong IncEdge list linking.");
116 116
    check(countIncEdges(G,n)==cnt,"Wrong IncEdge number.");
117 117
  }
118 118

	
119 119
  template <class Graph>
120
  void checkGraphIncEdgeArcLists(const Graph &G, typename Graph::Node n,
121
                                 int cnt)
122
  {
123
    checkGraphIncEdgeList(G, n, cnt);
124
    checkGraphOutArcList(G, n, cnt);
125
    checkGraphInArcList(G, n, cnt);
126
  }
127

	
128
  template <class Graph>
120 129
  void checkGraphConArcList(const Graph &G, int cnt) {
121 130
    int i = 0;
122 131
    for (typename Graph::NodeIt u(G); u != INVALID; ++u) {
123 132
      for (typename Graph::NodeIt v(G); v != INVALID; ++v) {
124 133
        for (ConArcIt<Graph> a(G, u, v); a != INVALID; ++a) {
125 134
          check(G.source(a) == u, "Wrong iterator.");
126 135
          check(G.target(a) == v, "Wrong iterator.");
127 136
          ++i;
128 137
        }
129 138
      }
130 139
    }
131 140
    check(cnt == i, "Wrong iterator.");
132 141
  }
133 142

	
134 143
  template <class Graph>
135 144
  void checkGraphConEdgeList(const Graph &G, int cnt) {
136 145
    int i = 0;
137 146
    for (typename Graph::NodeIt u(G); u != INVALID; ++u) {
138 147
      for (typename Graph::NodeIt v(G); v != INVALID; ++v) {
139 148
        for (ConEdgeIt<Graph> e(G, u, v); e != INVALID; ++e) {
140 149
          check((G.u(e) == u && G.v(e) == v) ||
141 150
                (G.u(e) == v && G.v(e) == u), "Wrong iterator.");
142 151
          i += u == v ? 2 : 1;
143 152
        }
144 153
      }
145 154
    }
146 155
    check(2 * cnt == i, "Wrong iterator.");
147 156
  }
148 157

	
149 158
  template <typename Graph>
150 159
  void checkArcDirections(const Graph& G) {
151 160
    for (typename Graph::ArcIt a(G); a != INVALID; ++a) {
152 161
      check(G.source(a) == G.target(G.oppositeArc(a)), "Wrong direction");
153 162
      check(G.target(a) == G.source(G.oppositeArc(a)), "Wrong direction");
154 163
      check(G.direct(a, G.direction(a)) == a, "Wrong direction");
155 164
    }
156 165
  }
157 166

	
158 167
  template <typename Graph>
159 168
  void checkNodeIds(const Graph& G) {
160 169
    std::set<int> values;
161 170
    for (typename Graph::NodeIt n(G); n != INVALID; ++n) {
162 171
      check(G.nodeFromId(G.id(n)) == n, "Wrong id");
163 172
      check(values.find(G.id(n)) == values.end(), "Wrong id");
164 173
      check(G.id(n) <= G.maxNodeId(), "Wrong maximum id");
165 174
      values.insert(G.id(n));
166 175
    }
167 176
  }
168 177

	
169 178
  template <typename Graph>
170 179
  void checkArcIds(const Graph& G) {
171 180
    std::set<int> values;
172 181
    for (typename Graph::ArcIt a(G); a != INVALID; ++a) {
173 182
      check(G.arcFromId(G.id(a)) == a, "Wrong id");
174 183
      check(values.find(G.id(a)) == values.end(), "Wrong id");
175 184
      check(G.id(a) <= G.maxArcId(), "Wrong maximum id");
176 185
      values.insert(G.id(a));
177 186
    }
178 187
  }
179 188

	
180 189
  template <typename Graph>
181 190
  void checkEdgeIds(const Graph& G) {
182 191
    std::set<int> values;
183 192
    for (typename Graph::EdgeIt e(G); e != INVALID; ++e) {
184 193
      check(G.edgeFromId(G.id(e)) == e, "Wrong id");
185 194
      check(values.find(G.id(e)) == values.end(), "Wrong id");
186 195
      check(G.id(e) <= G.maxEdgeId(), "Wrong maximum id");
187 196
      values.insert(G.id(e));
188 197
    }
189 198
  }
190 199

	
191 200
  template <typename Graph>
192 201
  void checkGraphNodeMap(const Graph& G) {
193 202
    typedef typename Graph::Node Node;
194 203
    typedef typename Graph::NodeIt NodeIt;
195 204

	
196 205
    typedef typename Graph::template NodeMap<int> IntNodeMap;
197 206
    IntNodeMap map(G, 42);
198 207
    for (NodeIt it(G); it != INVALID; ++it) {
199 208
      check(map[it] == 42, "Wrong map constructor.");
200 209
    }
201 210
    int s = 0;
202 211
    for (NodeIt it(G); it != INVALID; ++it) {
203 212
      map[it] = 0;
204 213
      check(map[it] == 0, "Wrong operator[].");
205 214
      map.set(it, s);
206 215
      check(map[it] == s, "Wrong set.");
207 216
      ++s;
208 217
    }
209 218
    s = s * (s - 1) / 2;
210 219
    for (NodeIt it(G); it != INVALID; ++it) {
211 220
      s -= map[it];
212 221
    }
213 222
    check(s == 0, "Wrong sum.");
214 223

	
215 224
    // map = constMap<Node>(12);
216 225
    // for (NodeIt it(G); it != INVALID; ++it) {
217 226
    //   check(map[it] == 12, "Wrong operator[].");
218 227
    // }
219 228
  }
220 229

	
221 230
  template <typename Graph>
222 231
  void checkGraphArcMap(const Graph& G) {
223 232
    typedef typename Graph::Arc Arc;
224 233
    typedef typename Graph::ArcIt ArcIt;
225 234

	
226 235
    typedef typename Graph::template ArcMap<int> IntArcMap;
227 236
    IntArcMap map(G, 42);
228 237
    for (ArcIt it(G); it != INVALID; ++it) {
229 238
      check(map[it] == 42, "Wrong map constructor.");
230 239
    }
231 240
    int s = 0;
232 241
    for (ArcIt it(G); it != INVALID; ++it) {
233 242
      map[it] = 0;
234 243
      check(map[it] == 0, "Wrong operator[].");
235 244
      map.set(it, s);
236 245
      check(map[it] == s, "Wrong set.");
237 246
      ++s;
238 247
    }
239 248
    s = s * (s - 1) / 2;
240 249
    for (ArcIt it(G); it != INVALID; ++it) {
241 250
      s -= map[it];
242 251
    }
243 252
    check(s == 0, "Wrong sum.");
244 253

	
245 254
    // map = constMap<Arc>(12);
246 255
    // for (ArcIt it(G); it != INVALID; ++it) {
247 256
    //   check(map[it] == 12, "Wrong operator[].");
248 257
    // }
249 258
  }
250 259

	
251 260
  template <typename Graph>
252 261
  void checkGraphEdgeMap(const Graph& G) {
253 262
    typedef typename Graph::Edge Edge;
254 263
    typedef typename Graph::EdgeIt EdgeIt;
255 264

	
256 265
    typedef typename Graph::template EdgeMap<int> IntEdgeMap;
257 266
    IntEdgeMap map(G, 42);
258 267
    for (EdgeIt it(G); it != INVALID; ++it) {
259 268
      check(map[it] == 42, "Wrong map constructor.");
260 269
    }
261 270
    int s = 0;
262 271
    for (EdgeIt it(G); it != INVALID; ++it) {
263 272
      map[it] = 0;
264 273
      check(map[it] == 0, "Wrong operator[].");
265 274
      map.set(it, s);
266 275
      check(map[it] == s, "Wrong set.");
267 276
      ++s;
268 277
    }
269 278
    s = s * (s - 1) / 2;
270 279
    for (EdgeIt it(G); it != INVALID; ++it) {
271 280
      s -= map[it];
272 281
    }
273 282
    check(s == 0, "Wrong sum.");
274 283

	
275 284
    // map = constMap<Edge>(12);
276 285
    // for (EdgeIt it(G); it != INVALID; ++it) {
277 286
    //   check(map[it] == 12, "Wrong operator[].");
278 287
    // }
279 288
  }
280 289

	
281 290

	
282 291
} //namespace lemon
283 292

	
284 293
#endif
0 comments (0 inline)