[906] | 1 | /* -*- C++ -*- |
---|
| 2 | * |
---|
[1956] | 3 | * This file is a part of LEMON, a generic C++ optimization library |
---|
| 4 | * |
---|
[2553] | 5 | * Copyright (C) 2003-2008 |
---|
[1956] | 6 | * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
---|
[1359] | 7 | * (Egervary Research Group on Combinatorial Optimization, EGRES). |
---|
[906] | 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 | */ |
---|
[1956] | 18 | |
---|
[921] | 19 | #ifndef LEMON_TEST_GRAPH_TEST_H |
---|
| 20 | #define LEMON_TEST_GRAPH_TEST_H |
---|
[800] | 21 | |
---|
[1728] | 22 | #include <lemon/graph_utils.h> |
---|
[800] | 23 | #include "test_tools.h" |
---|
| 24 | |
---|
| 25 | //! \ingroup misc |
---|
| 26 | //! \file |
---|
[946] | 27 | //! \brief Some utility and test cases to test graph classes. |
---|
[921] | 28 | namespace lemon { |
---|
[800] | 29 | |
---|
[891] | 30 | template<class Graph> void checkGraphNodeList(Graph &G, int nn) |
---|
[946] | 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; |
---|
[891] | 36 | } |
---|
[946] | 37 | check(n==INVALID,"Wrong Node list linking."); |
---|
| 38 | } |
---|
[800] | 39 | |
---|
[946] | 40 | template<class Graph> |
---|
| 41 | void checkGraphEdgeList(Graph &G, int nn) |
---|
| 42 | { |
---|
| 43 | typedef typename Graph::EdgeIt EdgeIt; |
---|
[800] | 44 | |
---|
[946] | 45 | EdgeIt e(G); |
---|
| 46 | for(int i=0;i<nn;i++) { |
---|
| 47 | check(e!=INVALID,"Wrong Edge list linking."); |
---|
| 48 | ++e; |
---|
[891] | 49 | } |
---|
[946] | 50 | check(e==INVALID,"Wrong Edge list linking."); |
---|
| 51 | } |
---|
[800] | 52 | |
---|
[946] | 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."); |
---|
[986] | 59 | check(n==G.source(e), "Wrong OutEdge list linking."); |
---|
[946] | 60 | ++e; |
---|
[891] | 61 | } |
---|
[946] | 62 | check(e==INVALID,"Wrong OutEdge list linking."); |
---|
| 63 | } |
---|
[800] | 64 | |
---|
[946] | 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."); |
---|
[986] | 71 | check(n==G.target(e), "Wrong InEdge list linking."); |
---|
[946] | 72 | ++e; |
---|
[891] | 73 | } |
---|
[946] | 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 | } |
---|
[800] | 85 | |
---|
[1728] | 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 | |
---|
[891] | 99 | ///\file |
---|
[986] | 100 | ///\todo Check target(), source() as well; |
---|
[800] | 101 | |
---|
| 102 | |
---|
[921] | 103 | } //namespace lemon |
---|
[800] | 104 | |
---|
| 105 | |
---|
| 106 | #endif |
---|