test/digraph_test.cc
changeset 376 b4a01426c0d9
parent 366 80a4d0742e98
child 377 a12eef1f82b2
equal deleted inserted replaced
6:f0247a9dceb9 7:e663a7b05ff3
    18 
    18 
    19 #include <lemon/concepts/digraph.h>
    19 #include <lemon/concepts/digraph.h>
    20 #include <lemon/list_graph.h>
    20 #include <lemon/list_graph.h>
    21 #include <lemon/smart_graph.h>
    21 #include <lemon/smart_graph.h>
    22 #include <lemon/full_graph.h>
    22 #include <lemon/full_graph.h>
    23 //#include <lemon/hypercube_graph.h>
    23 #include <lemon/hypercube_graph.h>
    24 
    24 
    25 #include "test_tools.h"
    25 #include "test_tools.h"
    26 #include "graph_test.h"
    26 #include "graph_test.h"
    27 
    27 
    28 using namespace lemon;
    28 using namespace lemon;
   110     }
   110     }
   111   }
   111   }
   112 
   112 
   113 }
   113 }
   114 
   114 
       
   115 void checkHypercubeDigraph(int dim) {
       
   116   DIGRAPH_TYPEDEFS(HypercubeDigraph);
       
   117 
       
   118   HypercubeDigraph G(dim);
       
   119   checkGraphNodeList(G, 1 << dim);
       
   120   checkGraphArcList(G, (1 << dim) * dim);
       
   121 
       
   122   Node n = G.nodeFromId(dim);
       
   123 
       
   124   checkGraphOutArcList(G, n, dim);
       
   125   for (OutArcIt a(G, n); a != INVALID; ++a)
       
   126     check(G.source(a) == n &&
       
   127           G.id(G.target(a)) == G.id(n) ^ (1 << G.dimension(a)),
       
   128           "Wrong arc");
       
   129 
       
   130   checkGraphInArcList(G, n, dim);
       
   131   for (InArcIt a(G, n); a != INVALID; ++a)
       
   132     check(G.target(a) == n &&
       
   133           G.id(G.source(a)) == G.id(n) ^ (1 << G.dimension(a)),
       
   134           "Wrong arc");
       
   135 
       
   136   checkGraphConArcList(G, (1 << dim) * dim);
       
   137 
       
   138   checkNodeIds(G);
       
   139   checkArcIds(G);
       
   140   checkGraphNodeMap(G);
       
   141   checkGraphArcMap(G);
       
   142 }
       
   143 
   115 
   144 
   116 void checkConcepts() {
   145 void checkConcepts() {
   117   { // Checking digraph components
   146   { // Checking digraph components
   118     checkConcept<BaseDigraphComponent, BaseDigraphComponent >();
   147     checkConcept<BaseDigraphComponent, BaseDigraphComponent >();
   119 
   148 
   143     checkConcept<ClearableDigraphComponent<>, SmartDigraph>();
   172     checkConcept<ClearableDigraphComponent<>, SmartDigraph>();
   144   }
   173   }
   145   { // Checking FullDigraph
   174   { // Checking FullDigraph
   146     checkConcept<Digraph, FullDigraph>();
   175     checkConcept<Digraph, FullDigraph>();
   147   }
   176   }
   148 //  { // Checking HyperCubeDigraph
   177   { // Checking HypercubeDigraph
   149 //    checkConcept<Digraph, HyperCubeDigraph>();
   178     checkConcept<Digraph, HypercubeDigraph>();
   150 //  }
   179   }
   151 }
   180 }
   152 
   181 
   153 template <typename Digraph>
   182 template <typename Digraph>
   154 void checkDigraphValidity() {
   183 void checkDigraphValidity() {
   155   TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
   184   TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
   210     checkDigraphValidity<SmartDigraph>();
   239     checkDigraphValidity<SmartDigraph>();
   211   }
   240   }
   212   { // Checking FullDigraph
   241   { // Checking FullDigraph
   213     checkFullDigraph(8);
   242     checkFullDigraph(8);
   214   }
   243   }
       
   244   { // Checking HypercubeDigraph
       
   245     checkHypercubeDigraph(1);
       
   246     checkHypercubeDigraph(2);
       
   247     checkHypercubeDigraph(3);
       
   248     checkHypercubeDigraph(4);
       
   249   }
   215 }
   250 }
   216 
   251 
   217 int main() {
   252 int main() {
   218   checkDigraphs();
   253   checkDigraphs();
   219   checkConcepts();
   254   checkConcepts();