186 check(!g.valid(g.nodeFromId(-1)), "Wrong validity check"); |
184 check(!g.valid(g.nodeFromId(-1)), "Wrong validity check"); |
187 check(!g.valid(g.edgeFromId(-1)), "Wrong validity check"); |
185 check(!g.valid(g.edgeFromId(-1)), "Wrong validity check"); |
188 check(!g.valid(g.arcFromId(-1)), "Wrong validity check"); |
186 check(!g.valid(g.arcFromId(-1)), "Wrong validity check"); |
189 } |
187 } |
190 |
188 |
191 // void checkGridGraph(const GridGraph& g, int w, int h) { |
189 void checkGridGraph(const GridGraph& g, int w, int h) { |
192 // check(g.width() == w, "Wrong width"); |
190 check(g.width() == w, "Wrong width"); |
193 // check(g.height() == h, "Wrong height"); |
191 check(g.height() == h, "Wrong height"); |
194 |
192 |
195 // for (int i = 0; i < w; ++i) { |
193 for (int i = 0; i < w; ++i) { |
196 // for (int j = 0; j < h; ++j) { |
194 for (int j = 0; j < h; ++j) { |
197 // check(g.col(g(i, j)) == i, "Wrong col"); |
195 check(g.col(g(i, j)) == i, "Wrong col"); |
198 // check(g.row(g(i, j)) == j, "Wrong row"); |
196 check(g.row(g(i, j)) == j, "Wrong row"); |
199 // } |
197 } |
200 // } |
198 } |
201 |
199 |
202 // for (int i = 0; i < w; ++i) { |
200 for (int i = 0; i < w; ++i) { |
203 // for (int j = 0; j < h - 1; ++j) { |
201 for (int j = 0; j < h - 1; ++j) { |
204 // check(g.source(g.down(g(i, j))) == g(i, j), "Wrong down"); |
202 check(g.source(g.down(g(i, j))) == g(i, j), "Wrong down"); |
205 // check(g.target(g.down(g(i, j))) == g(i, j + 1), "Wrong down"); |
203 check(g.target(g.down(g(i, j))) == g(i, j + 1), "Wrong down"); |
206 // } |
204 } |
207 // check(g.down(g(i, h - 1)) == INVALID, "Wrong down"); |
205 check(g.down(g(i, h - 1)) == INVALID, "Wrong down"); |
208 // } |
206 } |
209 |
207 |
210 // for (int i = 0; i < w; ++i) { |
208 for (int i = 0; i < w; ++i) { |
211 // for (int j = 1; j < h; ++j) { |
209 for (int j = 1; j < h; ++j) { |
212 // check(g.source(g.up(g(i, j))) == g(i, j), "Wrong up"); |
210 check(g.source(g.up(g(i, j))) == g(i, j), "Wrong up"); |
213 // check(g.target(g.up(g(i, j))) == g(i, j - 1), "Wrong up"); |
211 check(g.target(g.up(g(i, j))) == g(i, j - 1), "Wrong up"); |
214 // } |
212 } |
215 // check(g.up(g(i, 0)) == INVALID, "Wrong up"); |
213 check(g.up(g(i, 0)) == INVALID, "Wrong up"); |
216 // } |
214 } |
217 |
215 |
218 // for (int j = 0; j < h; ++j) { |
216 for (int j = 0; j < h; ++j) { |
219 // for (int i = 0; i < w - 1; ++i) { |
217 for (int i = 0; i < w - 1; ++i) { |
220 // check(g.source(g.right(g(i, j))) == g(i, j), "Wrong right"); |
218 check(g.source(g.right(g(i, j))) == g(i, j), "Wrong right"); |
221 // check(g.target(g.right(g(i, j))) == g(i + 1, j), "Wrong right"); |
219 check(g.target(g.right(g(i, j))) == g(i + 1, j), "Wrong right"); |
222 // } |
220 } |
223 // check(g.right(g(w - 1, j)) == INVALID, "Wrong right"); |
221 check(g.right(g(w - 1, j)) == INVALID, "Wrong right"); |
224 // } |
222 } |
225 |
223 |
226 // for (int j = 0; j < h; ++j) { |
224 for (int j = 0; j < h; ++j) { |
227 // for (int i = 1; i < w; ++i) { |
225 for (int i = 1; i < w; ++i) { |
228 // check(g.source(g.left(g(i, j))) == g(i, j), "Wrong left"); |
226 check(g.source(g.left(g(i, j))) == g(i, j), "Wrong left"); |
229 // check(g.target(g.left(g(i, j))) == g(i - 1, j), "Wrong left"); |
227 check(g.target(g.left(g(i, j))) == g(i - 1, j), "Wrong left"); |
230 // } |
228 } |
231 // check(g.left(g(0, j)) == INVALID, "Wrong left"); |
229 check(g.left(g(0, j)) == INVALID, "Wrong left"); |
232 // } |
230 } |
233 // } |
231 |
|
232 checkGraphNodeList(g, w*h); |
|
233 checkGraphArcList(g, 2*(2*w*h-w-h)); |
|
234 checkGraphEdgeList(g, 2*w*h-w-h); |
|
235 |
|
236 checkGraphOutArcList(g, g(0,0), 2); |
|
237 checkGraphOutArcList(g, g(0,1), 3); |
|
238 checkGraphOutArcList(g, g(w-2,h-2), 4); |
|
239 |
|
240 checkGraphInArcList(g, g(0,0), 2); |
|
241 checkGraphInArcList(g, g(0,1), 3); |
|
242 checkGraphInArcList(g, g(w-2,h-2), 4); |
|
243 |
|
244 checkGraphIncEdgeList(g, g(0,0), 2); |
|
245 checkGraphIncEdgeList(g, g(0,1), 3); |
|
246 checkGraphIncEdgeList(g, g(w-2,h-2), 4); |
|
247 |
|
248 checkGraphConArcList(g, 2*(2*w*h-w-h)); |
|
249 checkGraphConEdgeList(g, 2*w*h-w-h); |
|
250 |
|
251 checkArcDirections(g); |
|
252 |
|
253 checkNodeIds(g); |
|
254 checkArcIds(g); |
|
255 checkEdgeIds(g); |
|
256 checkGraphNodeMap(g); |
|
257 checkGraphArcMap(g); |
|
258 checkGraphEdgeMap(g); |
|
259 } |
234 |
260 |
235 void checkGraphs() { |
261 void checkGraphs() { |
236 { // Checking ListGraph |
262 { // Checking ListGraph |
237 checkGraph<ListGraph>(); |
263 checkGraph<ListGraph>(); |
238 checkGraphValidityErase<ListGraph>(); |
264 checkGraphValidityErase<ListGraph>(); |