test/graph_test.cc
changeset 708 994c7df296c9
parent 375 2d87dbd7f8c8
child 792 761fe0846f49
     1.1 --- a/test/graph_test.cc	Fri Nov 13 12:33:33 2009 +0100
     1.2 +++ b/test/graph_test.cc	Thu Dec 10 17:05:35 2009 +0100
     1.3 @@ -2,7 +2,7 @@
     1.4   *
     1.5   * This file is a part of LEMON, a generic C++ optimization library.
     1.6   *
     1.7 - * Copyright (C) 2003-2008
     1.8 + * Copyright (C) 2003-2009
     1.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    1.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
    1.11   *
    1.12 @@ -19,8 +19,9 @@
    1.13  #include <lemon/concepts/graph.h>
    1.14  #include <lemon/list_graph.h>
    1.15  #include <lemon/smart_graph.h>
    1.16 -// #include <lemon/full_graph.h>
    1.17 -// #include <lemon/grid_graph.h>
    1.18 +#include <lemon/full_graph.h>
    1.19 +#include <lemon/grid_graph.h>
    1.20 +#include <lemon/hypercube_graph.h>
    1.21  
    1.22  #include "test_tools.h"
    1.23  #include "graph_test.h"
    1.24 @@ -29,12 +30,13 @@
    1.25  using namespace lemon::concepts;
    1.26  
    1.27  template <class Graph>
    1.28 -void checkGraph() {
    1.29 +void checkGraphBuild() {
    1.30    TEMPLATE_GRAPH_TYPEDEFS(Graph);
    1.31  
    1.32    Graph G;
    1.33    checkGraphNodeList(G, 0);
    1.34    checkGraphEdgeList(G, 0);
    1.35 +  checkGraphArcList(G, 0);
    1.36  
    1.37    Node
    1.38      n1 = G.addNode(),
    1.39 @@ -42,48 +44,36 @@
    1.40      n3 = G.addNode();
    1.41    checkGraphNodeList(G, 3);
    1.42    checkGraphEdgeList(G, 0);
    1.43 +  checkGraphArcList(G, 0);
    1.44  
    1.45    Edge e1 = G.addEdge(n1, n2);
    1.46    check((G.u(e1) == n1 && G.v(e1) == n2) || (G.u(e1) == n2 && G.v(e1) == n1),
    1.47          "Wrong edge");
    1.48 +
    1.49    checkGraphNodeList(G, 3);
    1.50 +  checkGraphEdgeList(G, 1);
    1.51    checkGraphArcList(G, 2);
    1.52 -  checkGraphEdgeList(G, 1);
    1.53  
    1.54 -  checkGraphOutArcList(G, n1, 1);
    1.55 -  checkGraphOutArcList(G, n2, 1);
    1.56 -  checkGraphOutArcList(G, n3, 0);
    1.57 +  checkGraphIncEdgeArcLists(G, n1, 1);
    1.58 +  checkGraphIncEdgeArcLists(G, n2, 1);
    1.59 +  checkGraphIncEdgeArcLists(G, n3, 0);
    1.60  
    1.61 -  checkGraphInArcList(G, n1, 1);
    1.62 -  checkGraphInArcList(G, n2, 1);
    1.63 -  checkGraphInArcList(G, n3, 0);
    1.64 +  checkGraphConEdgeList(G, 1);
    1.65 +  checkGraphConArcList(G, 2);
    1.66  
    1.67 -  checkGraphIncEdgeList(G, n1, 1);
    1.68 -  checkGraphIncEdgeList(G, n2, 1);
    1.69 -  checkGraphIncEdgeList(G, n3, 0);
    1.70 +  Edge e2 = G.addEdge(n2, n1),
    1.71 +       e3 = G.addEdge(n2, n3);
    1.72  
    1.73 -  checkGraphConArcList(G, 2);
    1.74 -  checkGraphConEdgeList(G, 1);
    1.75 +  checkGraphNodeList(G, 3);
    1.76 +  checkGraphEdgeList(G, 3);
    1.77 +  checkGraphArcList(G, 6);
    1.78  
    1.79 -  Edge e2 = G.addEdge(n2, n1), e3 = G.addEdge(n2, n3);
    1.80 -  checkGraphNodeList(G, 3);
    1.81 -  checkGraphArcList(G, 6);
    1.82 -  checkGraphEdgeList(G, 3);
    1.83 +  checkGraphIncEdgeArcLists(G, n1, 2);
    1.84 +  checkGraphIncEdgeArcLists(G, n2, 3);
    1.85 +  checkGraphIncEdgeArcLists(G, n3, 1);
    1.86  
    1.87 -  checkGraphOutArcList(G, n1, 2);
    1.88 -  checkGraphOutArcList(G, n2, 3);
    1.89 -  checkGraphOutArcList(G, n3, 1);
    1.90 -
    1.91 -  checkGraphInArcList(G, n1, 2);
    1.92 -  checkGraphInArcList(G, n2, 3);
    1.93 -  checkGraphInArcList(G, n3, 1);
    1.94 -
    1.95 -  checkGraphIncEdgeList(G, n1, 2);
    1.96 -  checkGraphIncEdgeList(G, n2, 3);
    1.97 -  checkGraphIncEdgeList(G, n3, 1);
    1.98 -
    1.99 +  checkGraphConEdgeList(G, 3);
   1.100    checkGraphConArcList(G, 6);
   1.101 -  checkGraphConEdgeList(G, 3);
   1.102  
   1.103    checkArcDirections(G);
   1.104  
   1.105 @@ -95,6 +85,230 @@
   1.106    checkGraphEdgeMap(G);
   1.107  }
   1.108  
   1.109 +template <class Graph>
   1.110 +void checkGraphAlter() {
   1.111 +  TEMPLATE_GRAPH_TYPEDEFS(Graph);
   1.112 +
   1.113 +  Graph G;
   1.114 +  Node n1 = G.addNode(), n2 = G.addNode(),
   1.115 +       n3 = G.addNode(), n4 = G.addNode();
   1.116 +  Edge e1 = G.addEdge(n1, n2), e2 = G.addEdge(n2, n1),
   1.117 +       e3 = G.addEdge(n2, n3), e4 = G.addEdge(n1, n4),
   1.118 +       e5 = G.addEdge(n4, n3);
   1.119 +
   1.120 +  checkGraphNodeList(G, 4);
   1.121 +  checkGraphEdgeList(G, 5);
   1.122 +  checkGraphArcList(G, 10);
   1.123 +
   1.124 +  // Check changeU() and changeV()
   1.125 +  if (G.u(e2) == n2) {
   1.126 +    G.changeU(e2, n3);
   1.127 +  } else {
   1.128 +    G.changeV(e2, n3);
   1.129 +  }
   1.130 +
   1.131 +  checkGraphNodeList(G, 4);
   1.132 +  checkGraphEdgeList(G, 5);
   1.133 +  checkGraphArcList(G, 10);
   1.134 +
   1.135 +  checkGraphIncEdgeArcLists(G, n1, 3);
   1.136 +  checkGraphIncEdgeArcLists(G, n2, 2);
   1.137 +  checkGraphIncEdgeArcLists(G, n3, 3);
   1.138 +  checkGraphIncEdgeArcLists(G, n4, 2);
   1.139 +
   1.140 +  checkGraphConEdgeList(G, 5);
   1.141 +  checkGraphConArcList(G, 10);
   1.142 +
   1.143 +  if (G.u(e2) == n1) {
   1.144 +    G.changeU(e2, n2);
   1.145 +  } else {
   1.146 +    G.changeV(e2, n2);
   1.147 +  }
   1.148 +
   1.149 +  checkGraphNodeList(G, 4);
   1.150 +  checkGraphEdgeList(G, 5);
   1.151 +  checkGraphArcList(G, 10);
   1.152 +
   1.153 +  checkGraphIncEdgeArcLists(G, n1, 2);
   1.154 +  checkGraphIncEdgeArcLists(G, n2, 3);
   1.155 +  checkGraphIncEdgeArcLists(G, n3, 3);
   1.156 +  checkGraphIncEdgeArcLists(G, n4, 2);
   1.157 +
   1.158 +  checkGraphConEdgeList(G, 5);
   1.159 +  checkGraphConArcList(G, 10);
   1.160 +
   1.161 +  // Check contract()
   1.162 +  G.contract(n1, n4, false);
   1.163 +
   1.164 +  checkGraphNodeList(G, 3);
   1.165 +  checkGraphEdgeList(G, 5);
   1.166 +  checkGraphArcList(G, 10);
   1.167 +
   1.168 +  checkGraphIncEdgeArcLists(G, n1, 4);
   1.169 +  checkGraphIncEdgeArcLists(G, n2, 3);
   1.170 +  checkGraphIncEdgeArcLists(G, n3, 3);
   1.171 +
   1.172 +  checkGraphConEdgeList(G, 5);
   1.173 +  checkGraphConArcList(G, 10);
   1.174 +
   1.175 +  G.contract(n2, n3);
   1.176 +
   1.177 +  checkGraphNodeList(G, 2);
   1.178 +  checkGraphEdgeList(G, 3);
   1.179 +  checkGraphArcList(G, 6);
   1.180 +
   1.181 +  checkGraphIncEdgeArcLists(G, n1, 4);
   1.182 +  checkGraphIncEdgeArcLists(G, n2, 2);
   1.183 +
   1.184 +  checkGraphConEdgeList(G, 3);
   1.185 +  checkGraphConArcList(G, 6);
   1.186 +}
   1.187 +
   1.188 +template <class Graph>
   1.189 +void checkGraphErase() {
   1.190 +  TEMPLATE_GRAPH_TYPEDEFS(Graph);
   1.191 +
   1.192 +  Graph G;
   1.193 +  Node n1 = G.addNode(), n2 = G.addNode(),
   1.194 +       n3 = G.addNode(), n4 = G.addNode();
   1.195 +  Edge e1 = G.addEdge(n1, n2), e2 = G.addEdge(n2, n1),
   1.196 +       e3 = G.addEdge(n2, n3), e4 = G.addEdge(n1, n4),
   1.197 +       e5 = G.addEdge(n4, n3);
   1.198 +
   1.199 +  // Check edge deletion
   1.200 +  G.erase(e2);
   1.201 +
   1.202 +  checkGraphNodeList(G, 4);
   1.203 +  checkGraphEdgeList(G, 4);
   1.204 +  checkGraphArcList(G, 8);
   1.205 +
   1.206 +  checkGraphIncEdgeArcLists(G, n1, 2);
   1.207 +  checkGraphIncEdgeArcLists(G, n2, 2);
   1.208 +  checkGraphIncEdgeArcLists(G, n3, 2);
   1.209 +  checkGraphIncEdgeArcLists(G, n4, 2);
   1.210 +
   1.211 +  checkGraphConEdgeList(G, 4);
   1.212 +  checkGraphConArcList(G, 8);
   1.213 +
   1.214 +  // Check node deletion
   1.215 +  G.erase(n3);
   1.216 +
   1.217 +  checkGraphNodeList(G, 3);
   1.218 +  checkGraphEdgeList(G, 2);
   1.219 +  checkGraphArcList(G, 4);
   1.220 +
   1.221 +  checkGraphIncEdgeArcLists(G, n1, 2);
   1.222 +  checkGraphIncEdgeArcLists(G, n2, 1);
   1.223 +  checkGraphIncEdgeArcLists(G, n4, 1);
   1.224 +
   1.225 +  checkGraphConEdgeList(G, 2);
   1.226 +  checkGraphConArcList(G, 4);
   1.227 +}
   1.228 +
   1.229 +
   1.230 +template <class Graph>
   1.231 +void checkGraphSnapshot() {
   1.232 +  TEMPLATE_GRAPH_TYPEDEFS(Graph);
   1.233 +
   1.234 +  Graph G;
   1.235 +  Node n1 = G.addNode(), n2 = G.addNode(), n3 = G.addNode();
   1.236 +  Edge e1 = G.addEdge(n1, n2), e2 = G.addEdge(n2, n1),
   1.237 +       e3 = G.addEdge(n2, n3);
   1.238 +
   1.239 +  checkGraphNodeList(G, 3);
   1.240 +  checkGraphEdgeList(G, 3);
   1.241 +  checkGraphArcList(G, 6);
   1.242 +
   1.243 +  typename Graph::Snapshot snapshot(G);
   1.244 +
   1.245 +  Node n = G.addNode();
   1.246 +  G.addEdge(n3, n);
   1.247 +  G.addEdge(n, n3);
   1.248 +  G.addEdge(n3, n2);
   1.249 +
   1.250 +  checkGraphNodeList(G, 4);
   1.251 +  checkGraphEdgeList(G, 6);
   1.252 +  checkGraphArcList(G, 12);
   1.253 +
   1.254 +  snapshot.restore();
   1.255 +
   1.256 +  checkGraphNodeList(G, 3);
   1.257 +  checkGraphEdgeList(G, 3);
   1.258 +  checkGraphArcList(G, 6);
   1.259 +
   1.260 +  checkGraphIncEdgeArcLists(G, n1, 2);
   1.261 +  checkGraphIncEdgeArcLists(G, n2, 3);
   1.262 +  checkGraphIncEdgeArcLists(G, n3, 1);
   1.263 +
   1.264 +  checkGraphConEdgeList(G, 3);
   1.265 +  checkGraphConArcList(G, 6);
   1.266 +
   1.267 +  checkNodeIds(G);
   1.268 +  checkEdgeIds(G);
   1.269 +  checkArcIds(G);
   1.270 +  checkGraphNodeMap(G);
   1.271 +  checkGraphEdgeMap(G);
   1.272 +  checkGraphArcMap(G);
   1.273 +
   1.274 +  G.addNode();
   1.275 +  snapshot.save(G);
   1.276 +
   1.277 +  G.addEdge(G.addNode(), G.addNode());
   1.278 +
   1.279 +  snapshot.restore();
   1.280 +
   1.281 +  checkGraphNodeList(G, 4);
   1.282 +  checkGraphEdgeList(G, 3);
   1.283 +  checkGraphArcList(G, 6);
   1.284 +}
   1.285 +
   1.286 +void checkFullGraph(int num) {
   1.287 +  typedef FullGraph Graph;
   1.288 +  GRAPH_TYPEDEFS(Graph);
   1.289 +
   1.290 +  Graph G(num);
   1.291 +  checkGraphNodeList(G, num);
   1.292 +  checkGraphEdgeList(G, num * (num - 1) / 2);
   1.293 +
   1.294 +  for (NodeIt n(G); n != INVALID; ++n) {
   1.295 +    checkGraphOutArcList(G, n, num - 1);
   1.296 +    checkGraphInArcList(G, n, num - 1);
   1.297 +    checkGraphIncEdgeList(G, n, num - 1);
   1.298 +  }
   1.299 +
   1.300 +  checkGraphConArcList(G, num * (num - 1));
   1.301 +  checkGraphConEdgeList(G, num * (num - 1) / 2);
   1.302 +
   1.303 +  checkArcDirections(G);
   1.304 +
   1.305 +  checkNodeIds(G);
   1.306 +  checkArcIds(G);
   1.307 +  checkEdgeIds(G);
   1.308 +  checkGraphNodeMap(G);
   1.309 +  checkGraphArcMap(G);
   1.310 +  checkGraphEdgeMap(G);
   1.311 +
   1.312 +
   1.313 +  for (int i = 0; i < G.nodeNum(); ++i) {
   1.314 +    check(G.index(G(i)) == i, "Wrong index");
   1.315 +  }
   1.316 +
   1.317 +  for (NodeIt u(G); u != INVALID; ++u) {
   1.318 +    for (NodeIt v(G); v != INVALID; ++v) {
   1.319 +      Edge e = G.edge(u, v);
   1.320 +      Arc a = G.arc(u, v);
   1.321 +      if (u == v) {
   1.322 +        check(e == INVALID, "Wrong edge lookup");
   1.323 +        check(a == INVALID, "Wrong arc lookup");
   1.324 +      } else {
   1.325 +        check((G.u(e) == u && G.v(e) == v) ||
   1.326 +              (G.u(e) == v && G.v(e) == u), "Wrong edge lookup");
   1.327 +        check(G.source(a) == u && G.target(a) == v, "Wrong arc lookup");
   1.328 +      }
   1.329 +    }
   1.330 +  }
   1.331 +}
   1.332 +
   1.333  void checkConcepts() {
   1.334    { // Checking graph components
   1.335      checkConcept<BaseGraphComponent, BaseGraphComponent >();
   1.336 @@ -124,14 +338,15 @@
   1.337      checkConcept<ExtendableGraphComponent<>, SmartGraph>();
   1.338      checkConcept<ClearableGraphComponent<>, SmartGraph>();
   1.339    }
   1.340 -//  { // Checking FullGraph
   1.341 -//    checkConcept<Graph, FullGraph>();
   1.342 -//    checkGraphIterators<FullGraph>();
   1.343 -//  }
   1.344 -//  { // Checking GridGraph
   1.345 -//    checkConcept<Graph, GridGraph>();
   1.346 -//    checkGraphIterators<GridGraph>();
   1.347 -//  }
   1.348 +  { // Checking FullGraph
   1.349 +    checkConcept<Graph, FullGraph>();
   1.350 +  }
   1.351 +  { // Checking GridGraph
   1.352 +    checkConcept<Graph, GridGraph>();
   1.353 +  }
   1.354 +  { // Checking HypercubeGraph
   1.355 +    checkConcept<Graph, HypercubeGraph>();
   1.356 +  }
   1.357  }
   1.358  
   1.359  template <typename Graph>
   1.360 @@ -188,70 +403,163 @@
   1.361    check(!g.valid(g.arcFromId(-1)), "Wrong validity check");
   1.362  }
   1.363  
   1.364 -// void checkGridGraph(const GridGraph& g, int w, int h) {
   1.365 -//   check(g.width() == w, "Wrong width");
   1.366 -//   check(g.height() == h, "Wrong height");
   1.367 +void checkGridGraph(int width, int height) {
   1.368 +  typedef GridGraph Graph;
   1.369 +  GRAPH_TYPEDEFS(Graph);
   1.370 +  Graph G(width, height);
   1.371  
   1.372 -//   for (int i = 0; i < w; ++i) {
   1.373 -//     for (int j = 0; j < h; ++j) {
   1.374 -//       check(g.col(g(i, j)) == i, "Wrong col");
   1.375 -//       check(g.row(g(i, j)) == j, "Wrong row");
   1.376 -//     }
   1.377 -//   }
   1.378 +  check(G.width() == width, "Wrong column number");
   1.379 +  check(G.height() == height, "Wrong row number");
   1.380  
   1.381 -//   for (int i = 0; i < w; ++i) {
   1.382 -//     for (int j = 0; j < h - 1; ++j) {
   1.383 -//       check(g.source(g.down(g(i, j))) == g(i, j), "Wrong down");
   1.384 -//       check(g.target(g.down(g(i, j))) == g(i, j + 1), "Wrong down");
   1.385 -//     }
   1.386 -//     check(g.down(g(i, h - 1)) == INVALID, "Wrong down");
   1.387 -//   }
   1.388 +  for (int i = 0; i < width; ++i) {
   1.389 +    for (int j = 0; j < height; ++j) {
   1.390 +      check(G.col(G(i, j)) == i, "Wrong column");
   1.391 +      check(G.row(G(i, j)) == j, "Wrong row");
   1.392 +      check(G.pos(G(i, j)).x == i, "Wrong column");
   1.393 +      check(G.pos(G(i, j)).y == j, "Wrong row");
   1.394 +    }
   1.395 +  }
   1.396  
   1.397 -//   for (int i = 0; i < w; ++i) {
   1.398 -//     for (int j = 1; j < h; ++j) {
   1.399 -//       check(g.source(g.up(g(i, j))) == g(i, j), "Wrong up");
   1.400 -//       check(g.target(g.up(g(i, j))) == g(i, j - 1), "Wrong up");
   1.401 -//     }
   1.402 -//     check(g.up(g(i, 0)) == INVALID, "Wrong up");
   1.403 -//   }
   1.404 +  for (int j = 0; j < height; ++j) {
   1.405 +    for (int i = 0; i < width - 1; ++i) {
   1.406 +      check(G.source(G.right(G(i, j))) == G(i, j), "Wrong right");
   1.407 +      check(G.target(G.right(G(i, j))) == G(i + 1, j), "Wrong right");
   1.408 +    }
   1.409 +    check(G.right(G(width - 1, j)) == INVALID, "Wrong right");
   1.410 +  }
   1.411  
   1.412 -//   for (int j = 0; j < h; ++j) {
   1.413 -//     for (int i = 0; i < w - 1; ++i) {
   1.414 -//       check(g.source(g.right(g(i, j))) == g(i, j), "Wrong right");
   1.415 -//       check(g.target(g.right(g(i, j))) == g(i + 1, j), "Wrong right");
   1.416 -//     }
   1.417 -//     check(g.right(g(w - 1, j)) == INVALID, "Wrong right");
   1.418 -//   }
   1.419 +  for (int j = 0; j < height; ++j) {
   1.420 +    for (int i = 1; i < width; ++i) {
   1.421 +      check(G.source(G.left(G(i, j))) == G(i, j), "Wrong left");
   1.422 +      check(G.target(G.left(G(i, j))) == G(i - 1, j), "Wrong left");
   1.423 +    }
   1.424 +    check(G.left(G(0, j)) == INVALID, "Wrong left");
   1.425 +  }
   1.426  
   1.427 -//   for (int j = 0; j < h; ++j) {
   1.428 -//     for (int i = 1; i < w; ++i) {
   1.429 -//       check(g.source(g.left(g(i, j))) == g(i, j), "Wrong left");
   1.430 -//       check(g.target(g.left(g(i, j))) == g(i - 1, j), "Wrong left");
   1.431 -//     }
   1.432 -//     check(g.left(g(0, j)) == INVALID, "Wrong left");
   1.433 -//   }
   1.434 -// }
   1.435 +  for (int i = 0; i < width; ++i) {
   1.436 +    for (int j = 0; j < height - 1; ++j) {
   1.437 +      check(G.source(G.up(G(i, j))) == G(i, j), "Wrong up");
   1.438 +      check(G.target(G.up(G(i, j))) == G(i, j + 1), "Wrong up");
   1.439 +    }
   1.440 +    check(G.up(G(i, height - 1)) == INVALID, "Wrong up");
   1.441 +  }
   1.442 +
   1.443 +  for (int i = 0; i < width; ++i) {
   1.444 +    for (int j = 1; j < height; ++j) {
   1.445 +      check(G.source(G.down(G(i, j))) == G(i, j), "Wrong down");
   1.446 +      check(G.target(G.down(G(i, j))) == G(i, j - 1), "Wrong down");
   1.447 +    }
   1.448 +    check(G.down(G(i, 0)) == INVALID, "Wrong down");
   1.449 +  }
   1.450 +
   1.451 +  checkGraphNodeList(G, width * height);
   1.452 +  checkGraphEdgeList(G, width * (height - 1) + (width - 1) * height);
   1.453 +  checkGraphArcList(G, 2 * (width * (height - 1) + (width - 1) * height));
   1.454 +
   1.455 +  for (NodeIt n(G); n != INVALID; ++n) {
   1.456 +    int nb = 4;
   1.457 +    if (G.col(n) == 0) --nb;
   1.458 +    if (G.col(n) == width - 1) --nb;
   1.459 +    if (G.row(n) == 0) --nb;
   1.460 +    if (G.row(n) == height - 1) --nb;
   1.461 +
   1.462 +    checkGraphOutArcList(G, n, nb);
   1.463 +    checkGraphInArcList(G, n, nb);
   1.464 +    checkGraphIncEdgeList(G, n, nb);
   1.465 +  }
   1.466 +
   1.467 +  checkArcDirections(G);
   1.468 +
   1.469 +  checkGraphConArcList(G, 2 * (width * (height - 1) + (width - 1) * height));
   1.470 +  checkGraphConEdgeList(G, width * (height - 1) + (width - 1) * height);
   1.471 +
   1.472 +  checkNodeIds(G);
   1.473 +  checkArcIds(G);
   1.474 +  checkEdgeIds(G);
   1.475 +  checkGraphNodeMap(G);
   1.476 +  checkGraphArcMap(G);
   1.477 +  checkGraphEdgeMap(G);
   1.478 +
   1.479 +}
   1.480 +
   1.481 +void checkHypercubeGraph(int dim) {
   1.482 +  GRAPH_TYPEDEFS(HypercubeGraph);
   1.483 +
   1.484 +  HypercubeGraph G(dim);
   1.485 +  checkGraphNodeList(G, 1 << dim);
   1.486 +  checkGraphEdgeList(G, dim * (1 << (dim-1)));
   1.487 +  checkGraphArcList(G, dim * (1 << dim));
   1.488 +
   1.489 +  Node n = G.nodeFromId(dim);
   1.490 +
   1.491 +  for (NodeIt n(G); n != INVALID; ++n) {
   1.492 +    checkGraphIncEdgeList(G, n, dim);
   1.493 +    for (IncEdgeIt e(G, n); e != INVALID; ++e) {
   1.494 +      check( (G.u(e) == n &&
   1.495 +              G.id(G.v(e)) == (G.id(n) ^ (1 << G.dimension(e)))) ||
   1.496 +             (G.v(e) == n &&
   1.497 +              G.id(G.u(e)) == (G.id(n) ^ (1 << G.dimension(e)))),
   1.498 +             "Wrong edge or wrong dimension");
   1.499 +    }
   1.500 +
   1.501 +    checkGraphOutArcList(G, n, dim);
   1.502 +    for (OutArcIt a(G, n); a != INVALID; ++a) {
   1.503 +      check(G.source(a) == n &&
   1.504 +            G.id(G.target(a)) == (G.id(n) ^ (1 << G.dimension(a))),
   1.505 +            "Wrong arc or wrong dimension");
   1.506 +    }
   1.507 +
   1.508 +    checkGraphInArcList(G, n, dim);
   1.509 +    for (InArcIt a(G, n); a != INVALID; ++a) {
   1.510 +      check(G.target(a) == n &&
   1.511 +            G.id(G.source(a)) == (G.id(n) ^ (1 << G.dimension(a))),
   1.512 +            "Wrong arc or wrong dimension");
   1.513 +    }
   1.514 +  }
   1.515 +
   1.516 +  checkGraphConArcList(G, (1 << dim) * dim);
   1.517 +  checkGraphConEdgeList(G, dim * (1 << (dim-1)));
   1.518 +
   1.519 +  checkArcDirections(G);
   1.520 +
   1.521 +  checkNodeIds(G);
   1.522 +  checkArcIds(G);
   1.523 +  checkEdgeIds(G);
   1.524 +  checkGraphNodeMap(G);
   1.525 +  checkGraphArcMap(G);
   1.526 +  checkGraphEdgeMap(G);
   1.527 +}
   1.528  
   1.529  void checkGraphs() {
   1.530    { // Checking ListGraph
   1.531 -    checkGraph<ListGraph>();
   1.532 +    checkGraphBuild<ListGraph>();
   1.533 +    checkGraphAlter<ListGraph>();
   1.534 +    checkGraphErase<ListGraph>();
   1.535 +    checkGraphSnapshot<ListGraph>();
   1.536      checkGraphValidityErase<ListGraph>();
   1.537    }
   1.538    { // Checking SmartGraph
   1.539 -    checkGraph<SmartGraph>();
   1.540 +    checkGraphBuild<SmartGraph>();
   1.541 +    checkGraphSnapshot<SmartGraph>();
   1.542      checkGraphValidity<SmartGraph>();
   1.543    }
   1.544 -//   { // Checking FullGraph
   1.545 -//     FullGraph g(5);
   1.546 -//     checkGraphNodeList(g, 5);
   1.547 -//     checkGraphEdgeList(g, 10);
   1.548 -//   }
   1.549 -//   { // Checking GridGraph
   1.550 -//     GridGraph g(5, 6);
   1.551 -//     checkGraphNodeList(g, 30);
   1.552 -//     checkGraphEdgeList(g, 49);
   1.553 -//     checkGridGraph(g, 5, 6);
   1.554 -//   }
   1.555 +  { // Checking FullGraph
   1.556 +    checkFullGraph(7);
   1.557 +    checkFullGraph(8);
   1.558 +  }
   1.559 +  { // Checking GridGraph
   1.560 +    checkGridGraph(5, 8);
   1.561 +    checkGridGraph(8, 5);
   1.562 +    checkGridGraph(5, 5);
   1.563 +    checkGridGraph(0, 0);
   1.564 +    checkGridGraph(1, 1);
   1.565 +  }
   1.566 +  { // Checking HypercubeGraph
   1.567 +    checkHypercubeGraph(1);
   1.568 +    checkHypercubeGraph(2);
   1.569 +    checkHypercubeGraph(3);
   1.570 +    checkHypercubeGraph(4);
   1.571 +  }
   1.572  }
   1.573  
   1.574  int main() {