test/graph_test.cc
changeset 353 37557a46e298
parent 228 b6732e0d38c5
child 356 99f1bdf8f7db
     1.1 --- a/test/graph_test.cc	Mon Aug 04 22:00:36 2008 +0200
     1.2 +++ b/test/graph_test.cc	Thu Aug 14 21:49:39 2008 +0200
     1.3 @@ -19,7 +19,7 @@
     1.4  #include <lemon/concepts/graph.h>
     1.5  #include <lemon/list_graph.h>
     1.6  #include <lemon/smart_graph.h>
     1.7 -// #include <lemon/full_graph.h>
     1.8 +#include <lemon/full_graph.h>
     1.9  // #include <lemon/grid_graph.h>
    1.10  
    1.11  #include "test_tools.h"
    1.12 @@ -95,6 +95,53 @@
    1.13    checkGraphEdgeMap(G);
    1.14  }
    1.15  
    1.16 +void checkFullGraph(int num) {
    1.17 +  typedef FullGraph Graph;
    1.18 +  GRAPH_TYPEDEFS(Graph);
    1.19 +
    1.20 +  Graph G(num);
    1.21 +  checkGraphNodeList(G, num);
    1.22 +  checkGraphEdgeList(G, num * (num - 1) / 2);
    1.23 +
    1.24 +  for (NodeIt n(G); n != INVALID; ++n) {
    1.25 +    checkGraphOutArcList(G, n, num - 1);    
    1.26 +    checkGraphInArcList(G, n, num - 1);    
    1.27 +    checkGraphIncEdgeList(G, n, num - 1);    
    1.28 +  }
    1.29 +
    1.30 +  checkGraphConArcList(G, num * (num - 1));
    1.31 +  checkGraphConEdgeList(G, num * (num - 1) / 2);
    1.32 +
    1.33 +  checkArcDirections(G);
    1.34 +
    1.35 +  checkNodeIds(G);
    1.36 +  checkArcIds(G);
    1.37 +  checkEdgeIds(G);
    1.38 +  checkGraphNodeMap(G);
    1.39 +  checkGraphArcMap(G);
    1.40 +  checkGraphEdgeMap(G);
    1.41 +
    1.42 +  
    1.43 +  for (int i = 0; i < G.nodeNum(); ++i) {
    1.44 +    check(G.index(G(i)) == i, "Wrong index");
    1.45 +  }
    1.46 +
    1.47 +  for (NodeIt u(G); u != INVALID; ++u) {
    1.48 +    for (NodeIt v(G); v != INVALID; ++v) {
    1.49 +      Edge e = G.edge(u, v);
    1.50 +      Arc a = G.arc(u, v);
    1.51 +      if (u == v) {
    1.52 +        check(e == INVALID, "Wrong edge lookup");
    1.53 +        check(a == INVALID, "Wrong arc lookup");
    1.54 +      } else {
    1.55 +        check((G.u(e) == u && G.v(e) == v) ||
    1.56 +              (G.u(e) == v && G.v(e) == u), "Wrong edge lookup");
    1.57 +        check(G.source(a) == u && G.target(a) == v, "Wrong arc lookup");
    1.58 +      }
    1.59 +    }
    1.60 +  }
    1.61 +}
    1.62 +
    1.63  void checkConcepts() {
    1.64    { // Checking graph components
    1.65      checkConcept<BaseGraphComponent, BaseGraphComponent >();
    1.66 @@ -124,14 +171,12 @@
    1.67      checkConcept<ExtendableGraphComponent<>, SmartGraph>();
    1.68      checkConcept<ClearableGraphComponent<>, SmartGraph>();
    1.69    }
    1.70 -//  { // Checking FullGraph
    1.71 -//    checkConcept<Graph, FullGraph>();
    1.72 -//    checkGraphIterators<FullGraph>();
    1.73 -//  }
    1.74 -//  { // Checking GridGraph
    1.75 -//    checkConcept<Graph, GridGraph>();
    1.76 -//    checkGraphIterators<GridGraph>();
    1.77 -//  }
    1.78 +  { // Checking FullGraph
    1.79 +    checkConcept<Graph, FullGraph>();
    1.80 +  }
    1.81 +//   { // Checking GridGraph
    1.82 +//     checkConcept<Graph, GridGraph>();
    1.83 +//   }
    1.84  }
    1.85  
    1.86  template <typename Graph>
    1.87 @@ -241,11 +286,10 @@
    1.88      checkGraph<SmartGraph>();
    1.89      checkGraphValidity<SmartGraph>();
    1.90    }
    1.91 -//   { // Checking FullGraph
    1.92 -//     FullGraph g(5);
    1.93 -//     checkGraphNodeList(g, 5);
    1.94 -//     checkGraphEdgeList(g, 10);
    1.95 -//   }
    1.96 +  { // Checking FullGraph   
    1.97 +    checkFullGraph(7);
    1.98 +    checkFullGraph(8);
    1.99 +  }
   1.100  //   { // Checking GridGraph
   1.101  //     GridGraph g(5, 6);
   1.102  //     checkGraphNodeList(g, 30);