test/digraph_test.cc
changeset 365 a12eef1f82b2
parent 364 b4a01426c0d9
child 375 2d87dbd7f8c8
equal deleted inserted replaced
7:e663a7b05ff3 8:50a41b945d1f
    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>
       
    24 
    23 
    25 #include "test_tools.h"
    24 #include "test_tools.h"
    26 #include "graph_test.h"
    25 #include "graph_test.h"
    27 
    26 
    28 using namespace lemon;
    27 using namespace lemon;
   110     }
   109     }
   111   }
   110   }
   112 
   111 
   113 }
   112 }
   114 
   113 
   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 
       
   144 
       
   145 void checkConcepts() {
   114 void checkConcepts() {
   146   { // Checking digraph components
   115   { // Checking digraph components
   147     checkConcept<BaseDigraphComponent, BaseDigraphComponent >();
   116     checkConcept<BaseDigraphComponent, BaseDigraphComponent >();
   148 
   117 
   149     checkConcept<IDableDigraphComponent<>,
   118     checkConcept<IDableDigraphComponent<>,
   172     checkConcept<ClearableDigraphComponent<>, SmartDigraph>();
   141     checkConcept<ClearableDigraphComponent<>, SmartDigraph>();
   173   }
   142   }
   174   { // Checking FullDigraph
   143   { // Checking FullDigraph
   175     checkConcept<Digraph, FullDigraph>();
   144     checkConcept<Digraph, FullDigraph>();
   176   }
   145   }
   177   { // Checking HypercubeDigraph
       
   178     checkConcept<Digraph, HypercubeDigraph>();
       
   179   }
       
   180 }
   146 }
   181 
   147 
   182 template <typename Digraph>
   148 template <typename Digraph>
   183 void checkDigraphValidity() {
   149 void checkDigraphValidity() {
   184   TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
   150   TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
   239     checkDigraphValidity<SmartDigraph>();
   205     checkDigraphValidity<SmartDigraph>();
   240   }
   206   }
   241   { // Checking FullDigraph
   207   { // Checking FullDigraph
   242     checkFullDigraph(8);
   208     checkFullDigraph(8);
   243   }
   209   }
   244   { // Checking HypercubeDigraph
       
   245     checkHypercubeDigraph(1);
       
   246     checkHypercubeDigraph(2);
       
   247     checkHypercubeDigraph(3);
       
   248     checkHypercubeDigraph(4);
       
   249   }
       
   250 }
   210 }
   251 
   211 
   252 int main() {
   212 int main() {
   253   checkDigraphs();
   213   checkDigraphs();
   254   checkConcepts();
   214   checkConcepts();