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