1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/test/graph_test.h Mon May 23 04:48:14 2005 +0000
1.3 @@ -0,0 +1,90 @@
1.4 +/* -*- C++ -*-
1.5 + * test/graph_test.h - Part of LEMON, a generic C++ optimization library
1.6 + *
1.7 + * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.8 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
1.9 + *
1.10 + * Permission to use, modify and distribute this software is granted
1.11 + * provided that this copyright notice appears in all copies. For
1.12 + * precise terms see the accompanying LICENSE file.
1.13 + *
1.14 + * This software is provided "AS IS" with no warranty of any kind,
1.15 + * express or implied, and with no claim as to its suitability for any
1.16 + * purpose.
1.17 + *
1.18 + */
1.19 +#ifndef LEMON_TEST_GRAPH_TEST_H
1.20 +#define LEMON_TEST_GRAPH_TEST_H
1.21 +
1.22 +
1.23 +#include "test_tools.h"
1.24 +
1.25 +//! \ingroup misc
1.26 +//! \file
1.27 +//! \brief Some utility and test cases to test graph classes.
1.28 +namespace lemon {
1.29 +
1.30 + template<class Graph> void checkGraphNodeList(Graph &G, int nn)
1.31 + {
1.32 + typename Graph::NodeIt n(G);
1.33 + for(int i=0;i<nn;i++) {
1.34 + check(n!=INVALID,"Wrong Node list linking.");
1.35 + ++n;
1.36 + }
1.37 + check(n==INVALID,"Wrong Node list linking.");
1.38 + }
1.39 +
1.40 + template<class Graph>
1.41 + void checkGraphEdgeList(Graph &G, int nn)
1.42 + {
1.43 + typedef typename Graph::EdgeIt EdgeIt;
1.44 +
1.45 + EdgeIt e(G);
1.46 + for(int i=0;i<nn;i++) {
1.47 + check(e!=INVALID,"Wrong Edge list linking.");
1.48 + ++e;
1.49 + }
1.50 + check(e==INVALID,"Wrong Edge list linking.");
1.51 + }
1.52 +
1.53 + template<class Graph>
1.54 + void checkGraphOutEdgeList(Graph &G, typename Graph::Node n, int nn)
1.55 + {
1.56 + typename Graph::OutEdgeIt e(G,n);
1.57 + for(int i=0;i<nn;i++) {
1.58 + check(e!=INVALID,"Wrong OutEdge list linking.");
1.59 + check(n==G.source(e), "Wrong OutEdge list linking.");
1.60 + ++e;
1.61 + }
1.62 + check(e==INVALID,"Wrong OutEdge list linking.");
1.63 + }
1.64 +
1.65 + template<class Graph> void
1.66 + checkGraphInEdgeList(Graph &G, typename Graph::Node n, int nn)
1.67 + {
1.68 + typename Graph::InEdgeIt e(G,n);
1.69 + for(int i=0;i<nn;i++) {
1.70 + check(e!=INVALID,"Wrong InEdge list linking.");
1.71 + check(n==G.target(e), "Wrong InEdge list linking.");
1.72 + ++e;
1.73 + }
1.74 + check(e==INVALID,"Wrong InEdge list linking.");
1.75 + }
1.76 +
1.77 + template <class Graph>
1.78 + void checkGraph() {
1.79 + const int num = 5;
1.80 + Graph G;
1.81 + addPetersen(G, num);
1.82 + bidirGraph(G);
1.83 + checkBidirPetersen(G, num);
1.84 + }
1.85 +
1.86 + ///\file
1.87 + ///\todo Check target(), source() as well;
1.88 +
1.89 +
1.90 +} //namespace lemon
1.91 +
1.92 +
1.93 +#endif