src/test/graph_test.h
author ladanyi
Mon, 11 Oct 2004 18:02:48 +0000
changeset 942 75fdd0c6866d
parent 937 d4e911acef3d
child 946 c94ef40a22ce
permissions -rw-r--r--
Naming and coding style fixes and various other changes.
alpar@906
     1
/* -*- C++ -*-
alpar@921
     2
 * src/test/graph_test.h - Part of LEMON, a generic C++ optimization library
alpar@906
     3
 *
alpar@906
     4
 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@906
     5
 * (Egervary Combinatorial Optimization Research Group, 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
alpar@800
    24
//! \brief Some utility to  test graph classes.
alpar@921
    25
namespace lemon {
alpar@800
    26
deba@891
    27
  template<class Graph> void checkGraphNodeList(Graph &G, int nn)
deba@891
    28
    {
deba@891
    29
      typename Graph::NodeIt n(G);
deba@891
    30
      for(int i=0;i<nn;i++) {
deba@891
    31
	check(n!=INVALID,"Wrong Node list linking.");
deba@891
    32
	++n;
deba@891
    33
      }
deba@891
    34
      check(n==INVALID,"Wrong Node list linking.");
deba@891
    35
    }
alpar@800
    36
deba@891
    37
  template<class Graph> void checkGraphEdgeList(Graph &G, int nn)
deba@891
    38
    {
deba@891
    39
      typedef typename Graph::EdgeIt EdgeIt;
alpar@800
    40
deba@891
    41
      EdgeIt e(G);
deba@891
    42
      for(int i=0;i<nn;i++) {
deba@891
    43
	check(e!=INVALID,"Wrong Edge list linking.");
deba@891
    44
	++e;
deba@891
    45
      }
deba@891
    46
      check(e==INVALID,"Wrong Edge list linking.");
deba@891
    47
    }
alpar@800
    48
deba@891
    49
  template<class Graph> void checkGraphOutEdgeList(Graph &G,
deba@891
    50
						   typename Graph::Node n,
deba@891
    51
						   int nn)
deba@891
    52
    {
deba@891
    53
      typename Graph::OutEdgeIt e(G,n);
deba@891
    54
      for(int i=0;i<nn;i++) {
deba@891
    55
	check(e!=INVALID,"Wrong OutEdge list linking.");
deba@937
    56
	check(n==G.tail(e), "Wrong OutEdge list linking.");
deba@891
    57
	++e;
deba@891
    58
      }
deba@891
    59
      check(e==INVALID,"Wrong OutEdge list linking.");
deba@891
    60
    }
alpar@800
    61
deba@891
    62
  template<class Graph> void checkGraphInEdgeList(Graph &G,
deba@891
    63
						  typename Graph::Node n,
deba@891
    64
						  int nn)
deba@891
    65
    {
deba@891
    66
      typename Graph::InEdgeIt e(G,n);
deba@891
    67
      for(int i=0;i<nn;i++) {
deba@891
    68
	check(e!=INVALID,"Wrong InEdge list linking.");
deba@937
    69
	check(n==G.head(e), "Wrong InEdge list linking.");
deba@891
    70
	++e;
deba@891
    71
      }
deba@891
    72
      check(e==INVALID,"Wrong InEdge list linking.");
deba@891
    73
    }
alpar@800
    74
deba@891
    75
  ///\file
deba@891
    76
  ///\todo Check head(), tail() as well;
alpar@800
    77
alpar@800
    78
  
alpar@921
    79
} //namespace lemon
alpar@800
    80
alpar@800
    81
alpar@800
    82
#endif