Several changes. \n If new map is added to mapstorage it emits signal with the name of the new map. This was important, because from now on not only tha mapwin should be updated. \n Furthermore algobox gets a pointer to mapstorage instead of only the mapnames from it. This is important because without it it would be complicated to pass all of the required maps to algobox.
2 * test/bfs_test.cc - Part of LEMON, a generic C++ optimization library
4 * Copyright (C) 2006 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5 * (Egervary Research Group on Combinatorial Optimization, 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 #include "test_tools.h"
18 #include <lemon/smart_graph.h>
19 #include <lemon/bfs.h>
20 #include <lemon/path.h>
21 #include<lemon/concept/graph.h>
23 using namespace lemon;
25 const int PET_SIZE =5;
28 void check_Bfs_Compile()
30 typedef concept::StaticGraph Graph;
32 typedef Graph::Edge Edge;
33 typedef Graph::Node Node;
34 typedef Graph::EdgeIt EdgeIt;
35 typedef Graph::NodeIt NodeIt;
37 typedef Bfs<Graph> BType;
46 // BType::PredNodeMap pn(G);
53 e = bfs_test.predEdge(n);
54 n = bfs_test.predNode(n);
55 d = bfs_test.distMap();
56 p = bfs_test.predMap();
57 // pn = bfs_test.predNodeMap();
58 b = bfs_test.reached(n);
61 bfs_test.getPath(pp,n);
64 void check_Bfs_Function_Compile()
67 typedef concept::StaticGraph Graph;
69 typedef Graph::Edge Edge;
70 typedef Graph::Node Node;
71 typedef Graph::EdgeIt EdgeIt;
72 typedef Graph::NodeIt NodeIt;
73 typedef concept::ReadMap<Edge,VType> LengthMap;
75 bfs(Graph(),Node()).run();
76 bfs(Graph()).source(Node()).run();
78 .predMap(concept::WriteMap<Node,Edge>())
79 .distMap(concept::WriteMap<Node,VType>())
80 .reachedMap(concept::ReadWriteMap<Node,bool>())
81 .processedMap(concept::WriteMap<Node,bool>())
89 typedef SmartGraph Graph;
91 typedef Graph::Edge Edge;
92 typedef Graph::Node Node;
93 typedef Graph::EdgeIt EdgeIt;
94 typedef Graph::NodeIt NodeIt;
95 typedef Graph::EdgeMap<int> LengthMap;
99 PetStruct<Graph> ps = addPetersen(G,PET_SIZE);
104 Bfs<Graph> bfs_test(G);
107 check(bfs_test.dist(t)==3,"Bfs found a wrong path. " << bfs_test.dist(t));
110 check(bfs_test.getPath(p,t),"getPath() failed to set the path.");
111 check(p.length()==3,"getPath() found a wrong path.");
114 for(EdgeIt e(G); e==INVALID; ++e) {
117 check( !bfs_test.reached(u) ||
118 (bfs_test.dist(v) > bfs_test.dist(u)+1),
122 for(NodeIt v(G); v==INVALID; ++v) {
123 check(bfs_test.reached(v),"Each node should be reached.");
124 if ( bfs_test.predEdge(v)!=INVALID ) {
125 Edge e=bfs_test.predEdge(v);
127 check(u==bfs_test.predNode(v),"Wrong tree.");
128 check(bfs_test.dist(v) - bfs_test.dist(u) == 1,
129 "Wrong distance. Difference: "
130 << std::abs(bfs_test.dist(v) - bfs_test.dist(u)