Updated the makefile.
2 * src/test/test_tools.h - Part of LEMON, a generic C++ optimization library
4 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5 * (Egervary Combinatorial Optimization Research Group, EGRES).
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.
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
17 #ifndef LEMON_TEST_TEST_TOOLS_H
18 #define LEMON_TEST_TEST_TOOLS_H
22 //! \brief Some utility to write test programs.
28 ///If \c rc is fail, writes an error message end exit.
30 ///If \c rc is fail, writes an error message end exit.
31 ///The error message contains the file name and the line number of the
32 ///source code in a standard from, which makes it possible to go there
33 ///using good source browsers like e.g. \c emacs.
36 ///\code check(0==1,"This is obviously false.");\endcode will
37 ///print this (and then exits).
38 ///\verbatim graph_test.cc:123: error: This is obviously false. \endverbatim
40 ///\todo It should be in \c error.h
41 #define check(rc, msg) \
43 std::cerr << __FILE__ ":" << __LINE__ << ": error: " << msg << std::endl; \
47 ///Structure returned by \ref addPetersen().
49 ///Structure returned by \ref addPetersen().
51 template<class Graph> struct PetStruct
53 ///Vector containing the outer nodes.
54 std::vector<typename Graph::Node> outer;
55 ///Vector containing the inner nodes.
56 std::vector<typename Graph::Node> inner;
57 ///Vector containing the edges of the inner circle.
58 std::vector<typename Graph::Edge> incir;
59 ///Vector containing the edges of the outer circle.
60 std::vector<typename Graph::Edge> outcir;
61 ///Vector containing the chord edges.
62 std::vector<typename Graph::Edge> chords;
67 ///Adds a Petersen graph to \c G.
69 ///Adds a Petersen graph to \c G.
70 ///\return The nodes and edges of the generated graph.
72 template<typename Graph>
73 PetStruct<Graph> addPetersen(Graph &G,int num = 5)
77 for(int i=0;i<num;i++) {
78 n.outer.push_back(G.addNode());
79 n.inner.push_back(G.addNode());
82 for(int i=0;i<num;i++) {
83 n.chords.push_back(G.addEdge(n.outer[i],n.inner[i]));
84 n.outcir.push_back(G.addEdge(n.outer[i],n.outer[(i+1) % num]));
85 n.incir.push_back(G.addEdge(n.inner[i],n.inner[(i+2) % num]));
90 /// \brief Adds to the graph the reverse pair of all edge.
92 /// Adds to the graph the reverse pair of all edge.
94 template<class Graph> void bidirGraph(Graph &G)
96 typedef typename Graph::Edge Edge;
97 typedef typename Graph::EdgeIt EdgeIt;
101 for(EdgeIt e(G);e!=INVALID;++e) ee.push_back(e);
103 for(typename std::vector<Edge>::iterator p=ee.begin();p!=ee.end();p++)
104 G.addEdge(G.head(*p),G.tail(*p));
108 /// \brief Checks the bidirectioned Petersen graph.
110 /// Checks the bidirectioned Petersen graph.
112 template<class Graph> void checkBidirPetersen(Graph &G, int num = 5)
114 typedef typename Graph::Node Node;
116 typedef typename Graph::EdgeIt EdgeIt;
117 typedef typename Graph::NodeIt NodeIt;
119 checkGraphNodeList(G, 2 * num);
120 checkGraphEdgeList(G, 6 * num);
122 for(NodeIt n(G);n!=INVALID;++n) {
123 checkGraphInEdgeList(G, n, 3);
124 checkGraphOutEdgeList(G, n, 3);
128 ///Structure returned by \ref addSymPetersen().
130 ///Structure returned by \ref addSymPetersen().
132 template<class Graph> struct SymPetStruct
134 ///Vector containing the outer nodes.
135 std::vector<typename Graph::Node> outer;
136 ///Vector containing the inner nodes.
137 std::vector<typename Graph::Node> inner;
138 ///Vector containing the edges of the inner circle.
139 std::vector<typename Graph::SymEdge> incir;
140 ///Vector containing the edges of the outer circle.
141 std::vector<typename Graph::SymEdge> outcir;
142 ///Vector containing the chord edges.
143 std::vector<typename Graph::SymEdge> chords;
146 ///Adds a Petersen graph to the symmetric \c G.
148 ///Adds a Petersen graph to the symmetric \c G.
149 ///\return The nodes and edges of the generated graph.
151 template<typename Graph>
152 SymPetStruct<Graph> addSymPetersen(Graph &G,int num=5)
154 SymPetStruct<Graph> n;
156 for(int i=0;i<num;i++) {
157 n.outer.push_back(G.addNode());
158 n.inner.push_back(G.addNode());
161 for(int i=0;i<num;i++) {
162 n.chords.push_back(G.addEdge(n.outer[i],n.inner[i]));
163 n.outcir.push_back(G.addEdge(n.outer[i],n.outer[(i+1)%5]));
164 n.incir.push_back(G.addEdge(n.inner[i],n.inner[(i+2)%5]));