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
|
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
|