test/graph_test.h
author hegyi
Tue, 26 Jul 2005 21:19:41 +0000
changeset 1592 4708b716d2f4
parent 1359 1581f961cfaa
child 1728 eb8bb91ba9e2
permissions -rw-r--r--
EdgeMap and NodeMap creation is done, at last. Bach 4ever.
alpar@906
     1
/* -*- C++ -*-
ladanyi@1435
     2
 * test/graph_test.h - Part of LEMON, a generic C++ optimization library
alpar@906
     3
 *
alpar@1164
     4
 * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@1359
     5
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@906
     6
 *
alpar@906
     7
 * Permission to use, modify and distribute this software is granted
alpar@906
     8
 * provided that this copyright notice appears in all copies. For
alpar@906
     9
 * precise terms see the accompanying LICENSE file.
alpar@906
    10
 *
alpar@906
    11
 * This software is provided "AS IS" with no warranty of any kind,
alpar@906
    12
 * express or implied, and with no claim as to its suitability for any
alpar@906
    13
 * purpose.
alpar@906
    14
 *
alpar@906
    15
 */
alpar@921
    16
#ifndef LEMON_TEST_GRAPH_TEST_H
alpar@921
    17
#define LEMON_TEST_GRAPH_TEST_H
alpar@800
    18
alpar@800
    19
alpar@800
    20
#include "test_tools.h"
alpar@800
    21
alpar@800
    22
//! \ingroup misc
alpar@800
    23
//! \file
klao@946
    24
//! \brief Some utility and test cases to test graph classes.
alpar@921
    25
namespace lemon {
alpar@800
    26
deba@891
    27
  template<class Graph> void checkGraphNodeList(Graph &G, int nn)
klao@946
    28
  {
klao@946
    29
    typename Graph::NodeIt n(G);
klao@946
    30
    for(int i=0;i<nn;i++) {
klao@946
    31
      check(n!=INVALID,"Wrong Node list linking.");
klao@946
    32
      ++n;
deba@891
    33
    }
klao@946
    34
    check(n==INVALID,"Wrong Node list linking.");
klao@946
    35
  }
alpar@800
    36
klao@946
    37
  template<class Graph>
klao@946
    38
  void checkGraphEdgeList(Graph &G, int nn)
klao@946
    39
  {
klao@946
    40
    typedef typename Graph::EdgeIt EdgeIt;
alpar@800
    41
klao@946
    42
    EdgeIt e(G);
klao@946
    43
    for(int i=0;i<nn;i++) {
klao@946
    44
      check(e!=INVALID,"Wrong Edge list linking.");
klao@946
    45
      ++e;
deba@891
    46
    }
klao@946
    47
    check(e==INVALID,"Wrong Edge list linking.");
klao@946
    48
  }
alpar@800
    49
klao@946
    50
  template<class Graph> 
klao@946
    51
  void checkGraphOutEdgeList(Graph &G, typename Graph::Node n, int nn)
klao@946
    52
  {
klao@946
    53
    typename Graph::OutEdgeIt e(G,n);
klao@946
    54
    for(int i=0;i<nn;i++) {
klao@946
    55
      check(e!=INVALID,"Wrong OutEdge list linking.");
alpar@986
    56
      check(n==G.source(e), "Wrong OutEdge list linking.");
klao@946
    57
      ++e;
deba@891
    58
    }
klao@946
    59
    check(e==INVALID,"Wrong OutEdge list linking.");
klao@946
    60
  }
alpar@800
    61
klao@946
    62
  template<class Graph> void 
klao@946
    63
  checkGraphInEdgeList(Graph &G, typename Graph::Node n, int nn)
klao@946
    64
  {
klao@946
    65
    typename Graph::InEdgeIt e(G,n);
klao@946
    66
    for(int i=0;i<nn;i++) {
klao@946
    67
      check(e!=INVALID,"Wrong InEdge list linking.");
alpar@986
    68
      check(n==G.target(e), "Wrong InEdge list linking.");
klao@946
    69
      ++e;
deba@891
    70
    }
klao@946
    71
    check(e==INVALID,"Wrong InEdge list linking.");
klao@946
    72
  }
klao@946
    73
klao@946
    74
  template <class Graph> 
klao@946
    75
  void checkGraph() {
klao@946
    76
    const int num = 5;
klao@946
    77
    Graph G;
klao@946
    78
    addPetersen(G, num);
klao@946
    79
    bidirGraph(G);
klao@946
    80
    checkBidirPetersen(G, num);
klao@946
    81
  }
alpar@800
    82
deba@891
    83
  ///\file
alpar@986
    84
  ///\todo Check target(), source() as well;
alpar@800
    85
alpar@800
    86
  
alpar@921
    87
} //namespace lemon
alpar@800
    88
alpar@800
    89
alpar@800
    90
#endif