test/graph_test.cc
changeset 737 9d6c3e8b2421
parent 736 2e20aad15754
child 740 819ca5b50de0
equal deleted inserted replaced
17:99267d7ce885 18:4a0b1607d8b6
   268 void checkFullGraph(int num) {
   268 void checkFullGraph(int num) {
   269   typedef FullGraph Graph;
   269   typedef FullGraph Graph;
   270   GRAPH_TYPEDEFS(Graph);
   270   GRAPH_TYPEDEFS(Graph);
   271 
   271 
   272   Graph G(num);
   272   Graph G(num);
       
   273   check(G.nodeNum() == num && G.edgeNum() == num * (num - 1) / 2,
       
   274         "Wrong size");
       
   275 
       
   276   G.resize(num);
       
   277   check(G.nodeNum() == num && G.edgeNum() == num * (num - 1) / 2,
       
   278         "Wrong size");
       
   279 
   273   checkGraphNodeList(G, num);
   280   checkGraphNodeList(G, num);
   274   checkGraphEdgeList(G, num * (num - 1) / 2);
   281   checkGraphEdgeList(G, num * (num - 1) / 2);
   275 
   282 
   276   for (NodeIt n(G); n != INVALID; ++n) {
   283   for (NodeIt n(G); n != INVALID; ++n) {
   277     checkGraphOutArcList(G, n, num - 1);
   284     checkGraphOutArcList(G, n, num - 1);
   412   Graph G(width, height);
   419   Graph G(width, height);
   413 
   420 
   414   check(G.width() == width, "Wrong column number");
   421   check(G.width() == width, "Wrong column number");
   415   check(G.height() == height, "Wrong row number");
   422   check(G.height() == height, "Wrong row number");
   416 
   423 
       
   424   G.resize(width, height);
       
   425   check(G.width() == width, "Wrong column number");
       
   426   check(G.height() == height, "Wrong row number");
       
   427 
   417   for (int i = 0; i < width; ++i) {
   428   for (int i = 0; i < width; ++i) {
   418     for (int j = 0; j < height; ++j) {
   429     for (int j = 0; j < height; ++j) {
   419       check(G.col(G(i, j)) == i, "Wrong column");
   430       check(G.col(G(i, j)) == i, "Wrong column");
   420       check(G.row(G(i, j)) == j, "Wrong row");
   431       check(G.row(G(i, j)) == j, "Wrong row");
   421       check(G.pos(G(i, j)).x == i, "Wrong column");
   432       check(G.pos(G(i, j)).x == i, "Wrong column");
   487 
   498 
   488 void checkHypercubeGraph(int dim) {
   499 void checkHypercubeGraph(int dim) {
   489   GRAPH_TYPEDEFS(HypercubeGraph);
   500   GRAPH_TYPEDEFS(HypercubeGraph);
   490 
   501 
   491   HypercubeGraph G(dim);
   502   HypercubeGraph G(dim);
       
   503   check(G.dimension() == dim, "Wrong dimension");
       
   504 
       
   505   G.resize(dim);
       
   506   check(G.dimension() == dim, "Wrong dimension");
       
   507   
   492   checkGraphNodeList(G, 1 << dim);
   508   checkGraphNodeList(G, 1 << dim);
   493   checkGraphEdgeList(G, dim * (1 << (dim-1)));
   509   checkGraphEdgeList(G, dim * (1 << (dim-1)));
   494   checkGraphArcList(G, dim * (1 << dim));
   510   checkGraphArcList(G, dim * (1 << dim));
   495 
   511 
   496   Node n = G.nodeFromId(dim);
   512   Node n = G.nodeFromId(dim);