COIN-OR::LEMON - Graph Library

Changeset 228:b6732e0d38c5 in lemon for test/graph_test.cc


Ignore:
Timestamp:
07/21/08 16:30:28 (11 years ago)
Author:
Balazs Dezso <deba@…>
Branch:
default
Children:
229:aebc0161f6e5, 230:af4e8ba94294
Phase:
public
Message:

Reworking graph testing

  • The graph tests check more graph functionality.
  • The petersen graph is too regular, therefore special graphs are used.
  • The graph_test.h contains just general tools to test graphs.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/graph_test.cc

    r209 r228  
    2525#include "test_tools.h"
    2626#include "graph_test.h"
    27 #include "graph_maps_test.h"
    2827
    2928using namespace lemon;
    3029using namespace lemon::concepts;
    3130
    32 void check_concepts() {
     31template <class Graph>
     32void checkGraph() {
     33  TEMPLATE_GRAPH_TYPEDEFS(Graph);
     34
     35  Graph G;
     36  checkGraphNodeList(G, 0);
     37  checkGraphEdgeList(G, 0);
     38
     39  Node
     40    n1 = G.addNode(),
     41    n2 = G.addNode(),
     42    n3 = G.addNode();
     43  checkGraphNodeList(G, 3);
     44  checkGraphEdgeList(G, 0);
     45
     46  Edge e1 = G.addEdge(n1, n2);
     47  check((G.u(e1) == n1 && G.v(e1) == n2) || (G.u(e1) == n2 && G.v(e1) == n1),
     48        "Wrong edge");
     49  checkGraphNodeList(G, 3);
     50  checkGraphArcList(G, 2);
     51  checkGraphEdgeList(G, 1);
     52
     53  checkGraphOutArcList(G, n1, 1);
     54  checkGraphOutArcList(G, n2, 1);
     55  checkGraphOutArcList(G, n3, 0);
     56
     57  checkGraphInArcList(G, n1, 1);
     58  checkGraphInArcList(G, n2, 1);
     59  checkGraphInArcList(G, n3, 0);
     60
     61  checkGraphIncEdgeList(G, n1, 1);
     62  checkGraphIncEdgeList(G, n2, 1);
     63  checkGraphIncEdgeList(G, n3, 0);
     64
     65  checkGraphConArcList(G, 2);
     66  checkGraphConEdgeList(G, 1);
     67
     68  Edge e2 = G.addEdge(n2, n1), e3 = G.addEdge(n2, n3);
     69  checkGraphNodeList(G, 3);
     70  checkGraphArcList(G, 6);
     71  checkGraphEdgeList(G, 3);
     72
     73  checkGraphOutArcList(G, n1, 2);
     74  checkGraphOutArcList(G, n2, 3);
     75  checkGraphOutArcList(G, n3, 1);
     76
     77  checkGraphInArcList(G, n1, 2);
     78  checkGraphInArcList(G, n2, 3);
     79  checkGraphInArcList(G, n3, 1);
     80
     81  checkGraphIncEdgeList(G, n1, 2);
     82  checkGraphIncEdgeList(G, n2, 3);
     83  checkGraphIncEdgeList(G, n3, 1);
     84
     85  checkGraphConArcList(G, 6);
     86  checkGraphConEdgeList(G, 3);
     87
     88  checkArcDirections(G);
     89
     90  checkNodeIds(G);
     91  checkArcIds(G);
     92  checkEdgeIds(G);
     93  checkGraphNodeMap(G);
     94  checkGraphArcMap(G);
     95  checkGraphEdgeMap(G);
     96}
     97
     98void checkConcepts() {
    3399  { // Checking graph components
    34100    checkConcept<BaseGraphComponent, BaseGraphComponent >();
     
    52118    checkConcept<ClearableGraphComponent<>, ListGraph>();
    53119    checkConcept<ErasableGraphComponent<>, ListGraph>();
    54     checkGraphIterators<ListGraph>();
    55120  }
    56121  { // Checking SmartGraph
     
    59124    checkConcept<ExtendableGraphComponent<>, SmartGraph>();
    60125    checkConcept<ClearableGraphComponent<>, SmartGraph>();
    61     checkGraphIterators<SmartGraph>();
    62126  }
    63127//  { // Checking FullGraph
     
    72136
    73137template <typename Graph>
    74 void check_graph_validity() {
     138void checkGraphValidity() {
    75139  TEMPLATE_GRAPH_TYPEDEFS(Graph);
    76140  Graph g;
     
    95159
    96160template <typename Graph>
    97 void check_graph_validity_erase() {
     161void checkGraphValidityErase() {
    98162  TEMPLATE_GRAPH_TYPEDEFS(Graph);
    99163  Graph g;
     
    169233// }
    170234
    171 void check_graphs() {
     235void checkGraphs() {
    172236  { // Checking ListGraph
    173237    checkGraph<ListGraph>();
    174     checkGraphNodeMap<ListGraph>();
    175     checkGraphEdgeMap<ListGraph>();
    176 
    177     check_graph_validity_erase<ListGraph>();
     238    checkGraphValidityErase<ListGraph>();
    178239  }
    179240  { // Checking SmartGraph
    180241    checkGraph<SmartGraph>();
    181     checkGraphNodeMap<SmartGraph>();
    182     checkGraphEdgeMap<SmartGraph>();
    183 
    184     check_graph_validity<SmartGraph>();
     242    checkGraphValidity<SmartGraph>();
    185243  }
    186244//   { // Checking FullGraph
     
    198256
    199257int main() {
    200   check_concepts();
    201   check_graphs();
     258  checkConcepts();
     259  checkGraphs();
    202260  return 0;
    203261}
Note: See TracChangeset for help on using the changeset viewer.