test/graph_test.cc
changeset 370 636fa2f39f10
parent 348 052cecabcb71
parent 365 37557a46e298
child 377 a12eef1f82b2
equal deleted inserted replaced
9:66a8da2e39e9 11:5ec4464ecf18
    17  */
    17  */
    18 
    18 
    19 #include <lemon/concepts/graph.h>
    19 #include <lemon/concepts/graph.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/grid_graph.h>
    23 #include <lemon/grid_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 
    93   checkGraphNodeMap(G);
    93   checkGraphNodeMap(G);
    94   checkGraphArcMap(G);
    94   checkGraphArcMap(G);
    95   checkGraphEdgeMap(G);
    95   checkGraphEdgeMap(G);
    96 }
    96 }
    97 
    97 
       
    98 void checkFullGraph(int num) {
       
    99   typedef FullGraph Graph;
       
   100   GRAPH_TYPEDEFS(Graph);
       
   101 
       
   102   Graph G(num);
       
   103   checkGraphNodeList(G, num);
       
   104   checkGraphEdgeList(G, num * (num - 1) / 2);
       
   105 
       
   106   for (NodeIt n(G); n != INVALID; ++n) {
       
   107     checkGraphOutArcList(G, n, num - 1);    
       
   108     checkGraphInArcList(G, n, num - 1);    
       
   109     checkGraphIncEdgeList(G, n, num - 1);    
       
   110   }
       
   111 
       
   112   checkGraphConArcList(G, num * (num - 1));
       
   113   checkGraphConEdgeList(G, num * (num - 1) / 2);
       
   114 
       
   115   checkArcDirections(G);
       
   116 
       
   117   checkNodeIds(G);
       
   118   checkArcIds(G);
       
   119   checkEdgeIds(G);
       
   120   checkGraphNodeMap(G);
       
   121   checkGraphArcMap(G);
       
   122   checkGraphEdgeMap(G);
       
   123 
       
   124   
       
   125   for (int i = 0; i < G.nodeNum(); ++i) {
       
   126     check(G.index(G(i)) == i, "Wrong index");
       
   127   }
       
   128 
       
   129   for (NodeIt u(G); u != INVALID; ++u) {
       
   130     for (NodeIt v(G); v != INVALID; ++v) {
       
   131       Edge e = G.edge(u, v);
       
   132       Arc a = G.arc(u, v);
       
   133       if (u == v) {
       
   134         check(e == INVALID, "Wrong edge lookup");
       
   135         check(a == INVALID, "Wrong arc lookup");
       
   136       } else {
       
   137         check((G.u(e) == u && G.v(e) == v) ||
       
   138               (G.u(e) == v && G.v(e) == u), "Wrong edge lookup");
       
   139         check(G.source(a) == u && G.target(a) == v, "Wrong arc lookup");
       
   140       }
       
   141     }
       
   142   }
       
   143 }
       
   144 
    98 void checkConcepts() {
   145 void checkConcepts() {
    99   { // Checking graph components
   146   { // Checking graph components
   100     checkConcept<BaseGraphComponent, BaseGraphComponent >();
   147     checkConcept<BaseGraphComponent, BaseGraphComponent >();
   101 
   148 
   102     checkConcept<IDableGraphComponent<>,
   149     checkConcept<IDableGraphComponent<>,
   122     checkConcept<Graph, SmartGraph>();
   169     checkConcept<Graph, SmartGraph>();
   123     checkConcept<AlterableGraphComponent<>, SmartGraph>();
   170     checkConcept<AlterableGraphComponent<>, SmartGraph>();
   124     checkConcept<ExtendableGraphComponent<>, SmartGraph>();
   171     checkConcept<ExtendableGraphComponent<>, SmartGraph>();
   125     checkConcept<ClearableGraphComponent<>, SmartGraph>();
   172     checkConcept<ClearableGraphComponent<>, SmartGraph>();
   126   }
   173   }
   127 //  { // Checking FullGraph
   174   { // Checking FullGraph
   128 //    checkConcept<Graph, FullGraph>();
   175     checkConcept<Graph, FullGraph>();
   129 //    checkGraphIterators<FullGraph>();
   176   }
   130 //  }
       
   131   { // Checking GridGraph
   177   { // Checking GridGraph
   132     checkConcept<Graph, GridGraph>();
   178     checkConcept<Graph, GridGraph>();
   133   }
   179   }
   134 }
   180 }
   135 
   181 
   273   }
   319   }
   274   { // Checking SmartGraph
   320   { // Checking SmartGraph
   275     checkGraph<SmartGraph>();
   321     checkGraph<SmartGraph>();
   276     checkGraphValidity<SmartGraph>();
   322     checkGraphValidity<SmartGraph>();
   277   }
   323   }
   278 //   { // Checking FullGraph
   324   { // Checking FullGraph   
   279 //     FullGraph g(5);
   325     checkFullGraph(7);
   280 //     checkGraphNodeList(g, 5);
   326     checkFullGraph(8);
   281 //     checkGraphEdgeList(g, 10);
   327   }
   282 //   }
       
   283   { // Checking GridGraph
   328   { // Checking GridGraph
   284     checkGridGraph(5, 8);
   329     checkGridGraph(5, 8);
   285     checkGridGraph(8, 5);
   330     checkGridGraph(8, 5);
   286     checkGridGraph(5, 5);
   331     checkGridGraph(5, 5);
   287     checkGridGraph(0, 0);
   332     checkGridGraph(0, 0);