1.1 --- a/test/graph_test.cc Wed Nov 05 14:44:37 2008 +0000
1.2 +++ b/test/graph_test.cc Thu Nov 06 14:40:32 2008 +0000
1.3 @@ -21,6 +21,7 @@
1.4 #include <lemon/smart_graph.h>
1.5 #include <lemon/full_graph.h>
1.6 #include <lemon/grid_graph.h>
1.7 +#include <lemon/hypercube_graph.h>
1.8
1.9 #include "test_tools.h"
1.10 #include "graph_test.h"
1.11 @@ -104,9 +105,9 @@
1.12 checkGraphEdgeList(G, num * (num - 1) / 2);
1.13
1.14 for (NodeIt n(G); n != INVALID; ++n) {
1.15 - checkGraphOutArcList(G, n, num - 1);
1.16 - checkGraphInArcList(G, n, num - 1);
1.17 - checkGraphIncEdgeList(G, n, num - 1);
1.18 + checkGraphOutArcList(G, n, num - 1);
1.19 + checkGraphInArcList(G, n, num - 1);
1.20 + checkGraphIncEdgeList(G, n, num - 1);
1.21 }
1.22
1.23 checkGraphConArcList(G, num * (num - 1));
1.24 @@ -121,7 +122,7 @@
1.25 checkGraphArcMap(G);
1.26 checkGraphEdgeMap(G);
1.27
1.28 -
1.29 +
1.30 for (int i = 0; i < G.nodeNum(); ++i) {
1.31 check(G.index(G(i)) == i, "Wrong index");
1.32 }
1.33 @@ -177,6 +178,9 @@
1.34 { // Checking GridGraph
1.35 checkConcept<Graph, GridGraph>();
1.36 }
1.37 + { // Checking HypercubeGraph
1.38 + checkConcept<Graph, HypercubeGraph>();
1.39 + }
1.40 }
1.41
1.42 template <typename Graph>
1.43 @@ -312,6 +316,54 @@
1.44
1.45 }
1.46
1.47 +void checkHypercubeGraph(int dim) {
1.48 + GRAPH_TYPEDEFS(HypercubeGraph);
1.49 +
1.50 + HypercubeGraph G(dim);
1.51 + checkGraphNodeList(G, 1 << dim);
1.52 + checkGraphEdgeList(G, dim * (1 << dim-1));
1.53 + checkGraphArcList(G, dim * (1 << dim));
1.54 +
1.55 + Node n = G.nodeFromId(dim);
1.56 +
1.57 + for (NodeIt n(G); n != INVALID; ++n) {
1.58 + checkGraphIncEdgeList(G, n, dim);
1.59 + for (IncEdgeIt e(G, n); e != INVALID; ++e) {
1.60 + check( (G.u(e) == n &&
1.61 + G.id(G.v(e)) == G.id(n) ^ (1 << G.dimension(e))) ||
1.62 + (G.v(e) == n &&
1.63 + G.id(G.u(e)) == G.id(n) ^ (1 << G.dimension(e))),
1.64 + "Wrong edge or wrong dimension");
1.65 + }
1.66 +
1.67 + checkGraphOutArcList(G, n, dim);
1.68 + for (OutArcIt a(G, n); a != INVALID; ++a) {
1.69 + check(G.source(a) == n &&
1.70 + G.id(G.target(a)) == G.id(n) ^ (1 << G.dimension(a)),
1.71 + "Wrong arc or wrong dimension");
1.72 + }
1.73 +
1.74 + checkGraphInArcList(G, n, dim);
1.75 + for (InArcIt a(G, n); a != INVALID; ++a) {
1.76 + check(G.target(a) == n &&
1.77 + G.id(G.source(a)) == G.id(n) ^ (1 << G.dimension(a)),
1.78 + "Wrong arc or wrong dimension");
1.79 + }
1.80 + }
1.81 +
1.82 + checkGraphConArcList(G, (1 << dim) * dim);
1.83 + checkGraphConEdgeList(G, dim * (1 << dim-1));
1.84 +
1.85 + checkArcDirections(G);
1.86 +
1.87 + checkNodeIds(G);
1.88 + checkArcIds(G);
1.89 + checkEdgeIds(G);
1.90 + checkGraphNodeMap(G);
1.91 + checkGraphArcMap(G);
1.92 + checkGraphEdgeMap(G);
1.93 +}
1.94 +
1.95 void checkGraphs() {
1.96 { // Checking ListGraph
1.97 checkGraph<ListGraph>();
1.98 @@ -321,7 +373,7 @@
1.99 checkGraph<SmartGraph>();
1.100 checkGraphValidity<SmartGraph>();
1.101 }
1.102 - { // Checking FullGraph
1.103 + { // Checking FullGraph
1.104 checkFullGraph(7);
1.105 checkFullGraph(8);
1.106 }
1.107 @@ -332,6 +384,12 @@
1.108 checkGridGraph(0, 0);
1.109 checkGridGraph(1, 1);
1.110 }
1.111 + { // Checking HypercubeGraph
1.112 + checkHypercubeGraph(1);
1.113 + checkHypercubeGraph(2);
1.114 + checkHypercubeGraph(3);
1.115 + checkHypercubeGraph(4);
1.116 + }
1.117 }
1.118
1.119 int main() {