test/bpgraph_test.cc
changeset 1188 5ef0ab7b61cd
parent 1187 4c89e925cfe2
child 1189 a12cca3ad15a
equal deleted inserted replaced
1:9c673356757f 2:f8027b3b5079
    17  */
    17  */
    18 
    18 
    19 #include <lemon/concepts/bpgraph.h>
    19 #include <lemon/concepts/bpgraph.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 
    23 
    24 #include "test_tools.h"
    24 #include "test_tools.h"
    25 #include "graph_test.h"
    25 #include "graph_test.h"
    26 
    26 
    27 using namespace lemon;
    27 using namespace lemon;
   248     checkConcept<ExtendableBpGraphComponent<>, SmartBpGraph>();
   248     checkConcept<ExtendableBpGraphComponent<>, SmartBpGraph>();
   249     checkConcept<ClearableBpGraphComponent<>, SmartBpGraph>();
   249     checkConcept<ClearableBpGraphComponent<>, SmartBpGraph>();
   250   }
   250   }
   251 }
   251 }
   252 
   252 
       
   253 void checkFullBpGraph(int redNum, int blueNum) {
       
   254   typedef FullBpGraph BpGraph;
       
   255   BPGRAPH_TYPEDEFS(BpGraph);
       
   256 
       
   257   BpGraph G(redNum, blueNum);
       
   258   checkGraphNodeList(G, redNum + blueNum);
       
   259   checkGraphRedNodeList(G, redNum);
       
   260   checkGraphBlueNodeList(G, blueNum);
       
   261   checkGraphEdgeList(G, redNum * blueNum);
       
   262   checkGraphArcList(G, 2 * redNum * blueNum);
       
   263 
       
   264   G.resize(redNum, blueNum);
       
   265   checkGraphNodeList(G, redNum + blueNum);
       
   266   checkGraphRedNodeList(G, redNum);
       
   267   checkGraphBlueNodeList(G, blueNum);
       
   268   checkGraphEdgeList(G, redNum * blueNum);
       
   269   checkGraphArcList(G, 2 * redNum * blueNum);
       
   270 
       
   271   for (RedIt n(G); n != INVALID; ++n) {
       
   272     checkGraphOutArcList(G, n, blueNum);
       
   273     checkGraphInArcList(G, n, blueNum);
       
   274     checkGraphIncEdgeList(G, n, blueNum);
       
   275   }
       
   276 
       
   277   for (BlueIt n(G); n != INVALID; ++n) {
       
   278     checkGraphOutArcList(G, n, redNum);
       
   279     checkGraphInArcList(G, n, redNum);
       
   280     checkGraphIncEdgeList(G, n, redNum);
       
   281   }
       
   282 
       
   283   checkGraphConArcList(G, 2 * redNum * blueNum);
       
   284   checkGraphConEdgeList(G, redNum * blueNum);
       
   285 
       
   286   checkArcDirections(G);
       
   287 
       
   288   checkNodeIds(G);
       
   289   checkRedNodeIds(G);
       
   290   checkBlueNodeIds(G);
       
   291   checkArcIds(G);
       
   292   checkEdgeIds(G);
       
   293 
       
   294   checkGraphNodeMap(G);
       
   295   checkGraphRedMap(G);
       
   296   checkGraphBlueMap(G);
       
   297   checkGraphArcMap(G);
       
   298   checkGraphEdgeMap(G);
       
   299 
       
   300   for (int i = 0; i < G.redNum(); ++i) {
       
   301     check(G.red(G.redNode(i)), "Wrong node");
       
   302     check(G.redIndex(G.redNode(i)) == i, "Wrong index");
       
   303   }
       
   304 
       
   305   for (int i = 0; i < G.blueNum(); ++i) {
       
   306     check(G.blue(G.blueNode(i)), "Wrong node");
       
   307     check(G.blueIndex(G.blueNode(i)) == i, "Wrong index");
       
   308   }
       
   309 
       
   310   for (NodeIt u(G); u != INVALID; ++u) {
       
   311     for (NodeIt v(G); v != INVALID; ++v) {
       
   312       Edge e = G.edge(u, v);
       
   313       Arc a = G.arc(u, v);
       
   314       if (G.red(u) == G.red(v)) {
       
   315         check(e == INVALID, "Wrong edge lookup");
       
   316         check(a == INVALID, "Wrong arc lookup");
       
   317       } else {
       
   318         check((G.u(e) == u && G.v(e) == v) ||
       
   319               (G.u(e) == v && G.v(e) == u), "Wrong edge lookup");
       
   320         check(G.source(a) == u && G.target(a) == v, "Wrong arc lookup");
       
   321       }
       
   322     }
       
   323   }
       
   324 
       
   325 }
       
   326 
   253 void checkGraphs() {
   327 void checkGraphs() {
   254   { // Checking SmartGraph
   328   { // Checking SmartGraph
   255     checkBpGraphBuild<SmartBpGraph>();
   329     checkBpGraphBuild<SmartBpGraph>();
   256     checkBpGraphSnapshot<SmartBpGraph>();
   330     checkBpGraphSnapshot<SmartBpGraph>();
   257     checkBpGraphValidity<SmartBpGraph>();
   331     checkBpGraphValidity<SmartBpGraph>();
   258   }
   332   }
       
   333   { // Checking FullBpGraph
       
   334     checkFullBpGraph(6, 8);
       
   335     checkFullBpGraph(7, 4);
       
   336   }
   259 }
   337 }
   260 
   338 
   261 int main() {
   339 int main() {
   262   checkConcepts();
   340   checkConcepts();
   263   checkGraphs();
   341   checkGraphs();