test/graph_test.cc
changeset 964 2b6bffe0e7e8
parent 740 819ca5b50de0
child 998 7fdaa05a69a1
     1.1 --- a/test/graph_test.cc	Tue Dec 20 17:44:38 2011 +0100
     1.2 +++ b/test/graph_test.cc	Tue Dec 20 18:15:14 2011 +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-2009
     1.8 + * Copyright (C) 2003-2010
     1.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    1.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
    1.11   *
    1.12 @@ -38,6 +38,9 @@
    1.13    checkGraphEdgeList(G, 0);
    1.14    checkGraphArcList(G, 0);
    1.15  
    1.16 +  G.reserveNode(3);
    1.17 +  G.reserveEdge(3);
    1.18 +
    1.19    Node
    1.20      n1 = G.addNode(),
    1.21      n2 = G.addNode(),
    1.22 @@ -256,6 +259,15 @@
    1.23    G.addEdge(G.addNode(), G.addNode());
    1.24  
    1.25    snapshot.restore();
    1.26 +  snapshot.save(G);
    1.27 +
    1.28 +  checkGraphNodeList(G, 4);
    1.29 +  checkGraphEdgeList(G, 3);
    1.30 +  checkGraphArcList(G, 6);
    1.31 +
    1.32 +  G.addEdge(G.addNode(), G.addNode());
    1.33 +
    1.34 +  snapshot.restore();
    1.35  
    1.36    checkGraphNodeList(G, 4);
    1.37    checkGraphEdgeList(G, 3);
    1.38 @@ -267,6 +279,13 @@
    1.39    GRAPH_TYPEDEFS(Graph);
    1.40  
    1.41    Graph G(num);
    1.42 +  check(G.nodeNum() == num && G.edgeNum() == num * (num - 1) / 2,
    1.43 +        "Wrong size");
    1.44 +
    1.45 +  G.resize(num);
    1.46 +  check(G.nodeNum() == num && G.edgeNum() == num * (num - 1) / 2,
    1.47 +        "Wrong size");
    1.48 +
    1.49    checkGraphNodeList(G, num);
    1.50    checkGraphEdgeList(G, num * (num - 1) / 2);
    1.51  
    1.52 @@ -411,6 +430,10 @@
    1.53    check(G.width() == width, "Wrong column number");
    1.54    check(G.height() == height, "Wrong row number");
    1.55  
    1.56 +  G.resize(width, height);
    1.57 +  check(G.width() == width, "Wrong column number");
    1.58 +  check(G.height() == height, "Wrong row number");
    1.59 +
    1.60    for (int i = 0; i < width; ++i) {
    1.61      for (int j = 0; j < height; ++j) {
    1.62        check(G.col(G(i, j)) == i, "Wrong column");
    1.63 @@ -486,6 +509,11 @@
    1.64    GRAPH_TYPEDEFS(HypercubeGraph);
    1.65  
    1.66    HypercubeGraph G(dim);
    1.67 +  check(G.dimension() == dim, "Wrong dimension");
    1.68 +
    1.69 +  G.resize(dim);
    1.70 +  check(G.dimension() == dim, "Wrong dimension");
    1.71 +
    1.72    checkGraphNodeList(G, 1 << dim);
    1.73    checkGraphEdgeList(G, dim * (1 << (dim-1)));
    1.74    checkGraphArcList(G, dim * (1 << dim));