Properly detect the Intel C++ compiler (ticket #154).
1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
3 * This file is a part of LEMON, a generic C++ optimization library.
5 * Copyright (C) 2003-2008
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
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.
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
19 #ifndef LEMON_TEST_GRAPH_TEST_H
20 #define LEMON_TEST_GRAPH_TEST_H
24 #include <lemon/core.h>
25 #include <lemon/maps.h>
27 #include "test_tools.h"
32 void checkGraphNodeList(const Graph &G, int cnt)
34 typename Graph::NodeIt n(G);
35 for(int i=0;i<cnt;i++) {
36 check(n!=INVALID,"Wrong Node list linking.");
39 check(n==INVALID,"Wrong Node list linking.");
40 check(countNodes(G)==cnt,"Wrong Node number.");
44 void checkGraphArcList(const Graph &G, int cnt)
46 typename Graph::ArcIt e(G);
47 for(int i=0;i<cnt;i++) {
48 check(e!=INVALID,"Wrong Arc list linking.");
49 check(G.oppositeNode(G.source(e), e) == G.target(e),
50 "Wrong opposite node");
51 check(G.oppositeNode(G.target(e), e) == G.source(e),
52 "Wrong opposite node");
55 check(e==INVALID,"Wrong Arc list linking.");
56 check(countArcs(G)==cnt,"Wrong Arc number.");
60 void checkGraphOutArcList(const Graph &G, typename Graph::Node n, int cnt)
62 typename Graph::OutArcIt e(G,n);
63 for(int i=0;i<cnt;i++) {
64 check(e!=INVALID,"Wrong OutArc list linking.");
65 check(n==G.source(e),"Wrong OutArc list linking.");
66 check(n==G.baseNode(e),"Wrong OutArc list linking.");
67 check(G.target(e)==G.runningNode(e),"Wrong OutArc list linking.");
70 check(e==INVALID,"Wrong OutArc list linking.");
71 check(countOutArcs(G,n)==cnt,"Wrong OutArc number.");
75 void checkGraphInArcList(const Graph &G, typename Graph::Node n, int cnt)
77 typename Graph::InArcIt e(G,n);
78 for(int i=0;i<cnt;i++) {
79 check(e!=INVALID,"Wrong InArc list linking.");
80 check(n==G.target(e),"Wrong InArc list linking.");
81 check(n==G.baseNode(e),"Wrong OutArc list linking.");
82 check(G.source(e)==G.runningNode(e),"Wrong OutArc list linking.");
85 check(e==INVALID,"Wrong InArc list linking.");
86 check(countInArcs(G,n)==cnt,"Wrong InArc number.");
90 void checkGraphEdgeList(const Graph &G, int cnt)
92 typename Graph::EdgeIt e(G);
93 for(int i=0;i<cnt;i++) {
94 check(e!=INVALID,"Wrong Edge list linking.");
95 check(G.oppositeNode(G.u(e), e) == G.v(e), "Wrong opposite node");
96 check(G.oppositeNode(G.v(e), e) == G.u(e), "Wrong opposite node");
99 check(e==INVALID,"Wrong Edge list linking.");
100 check(countEdges(G)==cnt,"Wrong Edge number.");
103 template<class Graph>
104 void checkGraphIncEdgeList(const Graph &G, typename Graph::Node n, int cnt)
106 typename Graph::IncEdgeIt e(G,n);
107 for(int i=0;i<cnt;i++) {
108 check(e!=INVALID,"Wrong IncEdge list linking.");
109 check(n==G.u(e) || n==G.v(e),"Wrong IncEdge list linking.");
110 check(n==G.baseNode(e),"Wrong OutArc list linking.");
111 check(G.u(e)==G.runningNode(e) || G.v(e)==G.runningNode(e),
112 "Wrong OutArc list linking.");
115 check(e==INVALID,"Wrong IncEdge list linking.");
116 check(countIncEdges(G,n)==cnt,"Wrong IncEdge number.");
119 template <class Graph>
120 void checkGraphConArcList(const Graph &G, int cnt) {
122 for (typename Graph::NodeIt u(G); u != INVALID; ++u) {
123 for (typename Graph::NodeIt v(G); v != INVALID; ++v) {
124 for (ConArcIt<Graph> a(G, u, v); a != INVALID; ++a) {
125 check(G.source(a) == u, "Wrong iterator.");
126 check(G.target(a) == v, "Wrong iterator.");
131 check(cnt == i, "Wrong iterator.");
134 template <class Graph>
135 void checkGraphConEdgeList(const Graph &G, int cnt) {
137 for (typename Graph::NodeIt u(G); u != INVALID; ++u) {
138 for (typename Graph::NodeIt v(G); v != INVALID; ++v) {
139 for (ConEdgeIt<Graph> e(G, u, v); e != INVALID; ++e) {
140 check((G.u(e) == u && G.v(e) == v) ||
141 (G.u(e) == v && G.v(e) == u), "Wrong iterator.");
146 check(2 * cnt == i, "Wrong iterator.");
149 template <typename Graph>
150 void checkArcDirections(const Graph& G) {
151 for (typename Graph::ArcIt a(G); a != INVALID; ++a) {
152 check(G.source(a) == G.target(G.oppositeArc(a)), "Wrong direction");
153 check(G.target(a) == G.source(G.oppositeArc(a)), "Wrong direction");
154 check(G.direct(a, G.direction(a)) == a, "Wrong direction");
158 template <typename Graph>
159 void checkNodeIds(const Graph& G) {
160 std::set<int> values;
161 for (typename Graph::NodeIt n(G); n != INVALID; ++n) {
162 check(G.nodeFromId(G.id(n)) == n, "Wrong id");
163 check(values.find(G.id(n)) == values.end(), "Wrong id");
164 check(G.id(n) <= G.maxNodeId(), "Wrong maximum id");
165 values.insert(G.id(n));
169 template <typename Graph>
170 void checkArcIds(const Graph& G) {
171 std::set<int> values;
172 for (typename Graph::ArcIt a(G); a != INVALID; ++a) {
173 check(G.arcFromId(G.id(a)) == a, "Wrong id");
174 check(values.find(G.id(a)) == values.end(), "Wrong id");
175 check(G.id(a) <= G.maxArcId(), "Wrong maximum id");
176 values.insert(G.id(a));
180 template <typename Graph>
181 void checkEdgeIds(const Graph& G) {
182 std::set<int> values;
183 for (typename Graph::EdgeIt e(G); e != INVALID; ++e) {
184 check(G.edgeFromId(G.id(e)) == e, "Wrong id");
185 check(values.find(G.id(e)) == values.end(), "Wrong id");
186 check(G.id(e) <= G.maxEdgeId(), "Wrong maximum id");
187 values.insert(G.id(e));
191 template <typename Graph>
192 void checkGraphNodeMap(const Graph& G) {
193 typedef typename Graph::Node Node;
194 typedef typename Graph::NodeIt NodeIt;
196 typedef typename Graph::template NodeMap<int> IntNodeMap;
197 IntNodeMap map(G, 42);
198 for (NodeIt it(G); it != INVALID; ++it) {
199 check(map[it] == 42, "Wrong map constructor.");
202 for (NodeIt it(G); it != INVALID; ++it) {
204 check(map[it] == 0, "Wrong operator[].");
206 check(map[it] == s, "Wrong set.");
210 for (NodeIt it(G); it != INVALID; ++it) {
213 check(s == 0, "Wrong sum.");
215 // map = constMap<Node>(12);
216 // for (NodeIt it(G); it != INVALID; ++it) {
217 // check(map[it] == 12, "Wrong operator[].");
221 template <typename Graph>
222 void checkGraphArcMap(const Graph& G) {
223 typedef typename Graph::Arc Arc;
224 typedef typename Graph::ArcIt ArcIt;
226 typedef typename Graph::template ArcMap<int> IntArcMap;
227 IntArcMap map(G, 42);
228 for (ArcIt it(G); it != INVALID; ++it) {
229 check(map[it] == 42, "Wrong map constructor.");
232 for (ArcIt it(G); it != INVALID; ++it) {
234 check(map[it] == 0, "Wrong operator[].");
236 check(map[it] == s, "Wrong set.");
240 for (ArcIt it(G); it != INVALID; ++it) {
243 check(s == 0, "Wrong sum.");
245 // map = constMap<Arc>(12);
246 // for (ArcIt it(G); it != INVALID; ++it) {
247 // check(map[it] == 12, "Wrong operator[].");
251 template <typename Graph>
252 void checkGraphEdgeMap(const Graph& G) {
253 typedef typename Graph::Edge Edge;
254 typedef typename Graph::EdgeIt EdgeIt;
256 typedef typename Graph::template EdgeMap<int> IntEdgeMap;
257 IntEdgeMap map(G, 42);
258 for (EdgeIt it(G); it != INVALID; ++it) {
259 check(map[it] == 42, "Wrong map constructor.");
262 for (EdgeIt it(G); it != INVALID; ++it) {
264 check(map[it] == 0, "Wrong operator[].");
266 check(map[it] == s, "Wrong set.");
270 for (EdgeIt it(G); it != INVALID; ++it) {
273 check(s == 0, "Wrong sum.");
275 // map = constMap<Edge>(12);
276 // for (EdgeIt it(G); it != INVALID; ++it) {
277 // check(map[it] == 12, "Wrong operator[].");