test/graph_test.h
author deba
Fri, 02 Mar 2007 18:04:28 +0000
changeset 2386 81b47fc5c444
parent 1875 98698b69a902
child 2391 14a343be7a5a
permissions -rw-r--r--
Hard Warning checking
- based on the remark of the ZIB user
- we do not use -Winline
     1 /* -*- C++ -*-
     2  *
     3  * This file is a part of LEMON, a generic C++ optimization library
     4  *
     5  * Copyright (C) 2003-2006
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     8  *
     9  * Permission to use, modify and distribute this software is granted
    10  * provided that this copyright notice appears in all copies. For
    11  * precise terms see the accompanying LICENSE file.
    12  *
    13  * This software is provided "AS IS" with no warranty of any kind,
    14  * express or implied, and with no claim as to its suitability for any
    15  * purpose.
    16  *
    17  */
    18 
    19 #ifndef LEMON_TEST_GRAPH_TEST_H
    20 #define LEMON_TEST_GRAPH_TEST_H
    21 
    22 #include <lemon/graph_utils.h>
    23 #include "test_tools.h"
    24 
    25 //! \ingroup misc
    26 //! \file
    27 //! \brief Some utility and test cases to test graph classes.
    28 namespace lemon {
    29 
    30   template<class Graph> void checkGraphNodeList(Graph &G, int nn)
    31   {
    32     typename Graph::NodeIt n(G);
    33     for(int i=0;i<nn;i++) {
    34       check(n!=INVALID,"Wrong Node list linking.");
    35       ++n;
    36     }
    37     check(n==INVALID,"Wrong Node list linking.");
    38   }
    39 
    40   template<class Graph>
    41   void checkGraphEdgeList(Graph &G, int nn)
    42   {
    43     typedef typename Graph::EdgeIt EdgeIt;
    44 
    45     EdgeIt e(G);
    46     for(int i=0;i<nn;i++) {
    47       check(e!=INVALID,"Wrong Edge list linking.");
    48       ++e;
    49     }
    50     check(e==INVALID,"Wrong Edge list linking.");
    51   }
    52 
    53   template<class Graph> 
    54   void checkGraphOutEdgeList(Graph &G, typename Graph::Node n, int nn)
    55   {
    56     typename Graph::OutEdgeIt e(G,n);
    57     for(int i=0;i<nn;i++) {
    58       check(e!=INVALID,"Wrong OutEdge list linking.");
    59       check(n==G.source(e), "Wrong OutEdge list linking.");
    60       ++e;
    61     }
    62     check(e==INVALID,"Wrong OutEdge list linking.");
    63   }
    64 
    65   template<class Graph> void 
    66   checkGraphInEdgeList(Graph &G, typename Graph::Node n, int nn)
    67   {
    68     typename Graph::InEdgeIt e(G,n);
    69     for(int i=0;i<nn;i++) {
    70       check(e!=INVALID,"Wrong InEdge list linking.");
    71       check(n==G.target(e), "Wrong InEdge list linking.");
    72       ++e;
    73     }
    74     check(e==INVALID,"Wrong InEdge list linking.");
    75   }
    76 
    77   template <class Graph> 
    78   void checkGraph() {
    79     const int num = 5;
    80     Graph G;
    81     addPetersen(G, num);
    82     bidirGraph(G);
    83     checkBidirPetersen(G, num);
    84   }
    85 
    86   template <class Graph> 
    87   void checkGraphIterators(const Graph& graph) {
    88     typedef typename Graph::Node Node;
    89     typedef typename Graph::NodeIt NodeIt;
    90     typedef typename Graph::Edge Edge;
    91     typedef typename Graph::EdgeIt EdgeIt;
    92     typedef typename Graph::InEdgeIt InEdgeIt;
    93     typedef typename Graph::OutEdgeIt OutEdgeIt;
    94     typedef ConEdgeIt<Graph> ConEdgeIt;
    95     
    96     for (NodeIt it(graph); it != INVALID; ++it) {}
    97   }
    98 
    99   ///\file
   100   ///\todo Check target(), source() as well;
   101 
   102   
   103 } //namespace lemon
   104 
   105 
   106 #endif