Improved LEMON_FUNCTION_NAME macro.
It should work fine with GCC and the MS C++ compilers. Otherwise it reverts to
using the __func__ variable which is C99, but I couldn't find a better
alternative.
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 #include "test_tools.h"
20 //#include <lemon/smart_graph.h>
21 #include <lemon/list_graph.h>
22 #include <lemon/bfs.h>
23 #include <lemon/path.h>
24 #include<lemon/concepts/digraph.h>
26 using namespace lemon;
28 const int PET_SIZE =5;
31 void check_Bfs_Compile()
33 typedef concepts::Digraph Digraph;
35 typedef Digraph::Arc Arc;
36 typedef Digraph::Node Node;
37 typedef Digraph::ArcIt ArcIt;
38 typedef Digraph::NodeIt NodeIt;
40 typedef Bfs<Digraph> BType;
49 // BType::PredNodeMap pn(G);
56 e = bfs_test.predArc(n);
57 n = bfs_test.predNode(n);
58 d = bfs_test.distMap();
59 p = bfs_test.predMap();
60 // pn = bfs_test.predNodeMap();
61 b = bfs_test.reached(n);
63 Path<Digraph> pp = bfs_test.path(n);
66 void check_Bfs_Function_Compile()
69 typedef concepts::Digraph Digraph;
71 typedef Digraph::Arc Arc;
72 typedef Digraph::Node Node;
73 typedef Digraph::ArcIt ArcIt;
74 typedef Digraph::NodeIt NodeIt;
75 typedef concepts::ReadMap<Arc,VType> LengthMap;
79 bfs(g).source(Node()).run();
81 .predMap(concepts::WriteMap<Node,Arc>())
82 .distMap(concepts::WriteMap<Node,VType>())
83 .reachedMap(concepts::ReadWriteMap<Node,bool>())
84 .processedMap(concepts::WriteMap<Node,bool>())
92 // typedef SmartDigraph Digraph;
93 typedef ListDigraph Digraph;
95 typedef Digraph::Arc Arc;
96 typedef Digraph::Node Node;
97 typedef Digraph::ArcIt ArcIt;
98 typedef Digraph::NodeIt NodeIt;
99 typedef Digraph::ArcMap<int> LengthMap;
103 PetStruct<Digraph> ps = addPetersen(G,PET_SIZE);
108 Bfs<Digraph> bfs_test(G);
111 check(bfs_test.dist(t)==3,"Bfs found a wrong path. " << bfs_test.dist(t));
113 Path<Digraph> p = bfs_test.path(t);
114 check(p.length()==3,"getPath() found a wrong path.");
115 check(checkPath(G, p),"path() found a wrong path.");
116 check(pathSource(G, p) == s,"path() found a wrong path.");
117 check(pathTarget(G, p) == t,"path() found a wrong path.");
120 for(ArcIt e(G); e==INVALID; ++e) {
123 check( !bfs_test.reached(u) ||
124 (bfs_test.dist(v) > bfs_test.dist(u)+1),
128 for(NodeIt v(G); v==INVALID; ++v) {
129 check(bfs_test.reached(v),"Each node should be reached.");
130 if ( bfs_test.predArc(v)!=INVALID ) {
131 Arc e=bfs_test.predArc(v);
133 check(u==bfs_test.predNode(v),"Wrong tree.");
134 check(bfs_test.dist(v) - bfs_test.dist(u) == 1,
135 "Wrong distance. Difference: "
136 << std::abs(bfs_test.dist(v) - bfs_test.dist(u)