Ticket #363: lemon_rev973_4e27249fd00f.patch
File lemon_rev973_4e27249fd00f.patch, 21.3 KB (added by , 15 years ago) |
---|
-
test/CMakeLists.txt
# HG changeset patch # User gyorokp # Date 1269722063 -3600 # Node ID 4e27249fd00f82efa5a0d0c2380427e346fc3e4a # Parent 941e63d323f17b503f4d85fc5ec8a9c476672e8a Added planar_graph_test (Snapshot broken) (#363) diff -r 941e63d323f1 -r 4e27249fd00f test/CMakeLists.txt
a b 35 35 min_cost_flow_test 36 36 min_mean_cycle_test 37 37 path_test 38 planar_graph_test 38 39 planarity_test 39 40 preflow_test 40 41 radix_sort_test -
test/Makefile.am
diff -r 941e63d323f1 -r 4e27249fd00f test/Makefile.am
a b 37 37 test/min_cost_flow_test \ 38 38 test/min_mean_cycle_test \ 39 39 test/path_test \ 40 test/planar_graph_test \ 40 41 test/planarity_test \ 41 42 test/preflow_test \ 42 43 test/radix_sort_test \ … … 88 89 test_min_cost_flow_test_SOURCES = test/min_cost_flow_test.cc 89 90 test_min_mean_cycle_test_SOURCES = test/min_mean_cycle_test.cc 90 91 test_path_test_SOURCES = test/path_test.cc 92 test_planar_graph_test_SOURCES = test/digraph_test.cc 91 93 test_planarity_test_SOURCES = test/planarity_test.cc 92 94 test_preflow_test_SOURCES = test/preflow_test.cc 93 95 test_radix_sort_test_SOURCES = test/radix_sort_test.cc -
new file test/planar_graph_test.cc
diff -r 941e63d323f1 -r 4e27249fd00f test/planar_graph_test.cc
- + 1 /* -*- mode: C++; indent-tabs-mode: nil; -*- 2 * 3 * This file is a part of LEMON, a generic C++ optimization library. 4 * 5 * Copyright (C) 2003-2010 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). 8 * 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. 12 * 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 15 * purpose. 16 * 17 */ 18 19 #include <lemon/concepts/graph.h> 20 #include <lemon/planar_graph.h> 21 22 #include "test_tools.h" 23 #include "planar_graph_test.h" 24 25 using namespace lemon; 26 using namespace lemon::concepts; 27 28 template <class Graph> 29 void checkGraphBuild() { 30 TEMPLATE_GRAPH_TYPEDEFS(Graph); 31 32 Graph G; 33 checkGraphNodeList(G, 0); 34 checkGraphEdgeList(G, 0); 35 checkGraphArcList(G, 0); 36 checkGraphFaceList(G, 0); 37 38 G.reserveNode(3); 39 G.reserveEdge(3); 40 41 Node 42 n1 = G.addNode(), 43 n2 = G.addNode(), 44 n3 = G.addNode(); 45 checkGraphNodeList(G, 3); 46 checkGraphEdgeList(G, 0); 47 checkGraphArcList(G, 0); 48 checkGraphFaceList(G, 3); 49 50 Edge e1 = G.addEdge(n1, n2, INVALID, INVALID); 51 check((G.u(e1) == n1 && G.v(e1) == n2) || (G.u(e1) == n2 && G.v(e1) == n1), 52 "Wrong edge"); 53 54 checkGraphNodeList(G, 3); 55 checkGraphEdgeList(G, 1); 56 checkGraphArcList(G, 2); 57 checkGraphFaceList(G, 2); 58 59 checkGraphIncEdgeArcLists(G, n1, 1); 60 checkGraphIncEdgeArcLists(G, n2, 1); 61 checkGraphIncEdgeArcLists(G, n3, 0); 62 63 checkGraphConEdgeList(G, 1); 64 checkGraphConArcList(G, 2); 65 66 Edge e2 = G.addEdge(n2, n1, e1, e1), 67 e3 = G.addEdge(n2, n3, e1, INVALID); 68 69 checkGraphNodeList(G, 3); 70 checkGraphEdgeList(G, 3); 71 checkGraphArcList(G, 6); 72 checkGraphFaceList(G, 2); 73 74 checkGraphIncEdgeArcLists(G, n1, 2); 75 checkGraphIncEdgeArcLists(G, n2, 3); 76 checkGraphIncEdgeArcLists(G, n3, 1); 77 78 checkGraphConEdgeList(G, 3); 79 checkGraphConArcList(G, 6); 80 81 checkArcDirections(G); 82 83 checkNodeIds(G); 84 checkArcIds(G); 85 checkEdgeIds(G); 86 checkFaceIds(G); 87 checkGraphNodeMap(G); 88 checkGraphArcMap(G); 89 checkGraphFaceMap(G); 90 } 91 92 template <class Graph> 93 void checkGraphArcSplit() { 94 TEMPLATE_GRAPH_TYPEDEFS(Graph); 95 96 Graph G; 97 Node n0 = G.addNode(), 98 n1 = G.addNode(), 99 n2 = G.addNode(), 100 n3 = G.addNode(); 101 Edge a0 = G.addEdge(n0,n1,INVALID,INVALID), 102 a1 = G.addEdge(n0,n3,a0,INVALID), 103 a2 = G.addEdge(n0,n2,a0,INVALID), 104 a3 = G.addEdge(n1,n3,a0,a1), 105 a4 = G.addEdge(n3,n2,a1,a2); 106 107 checkGraphNodeList(G, 4); 108 checkGraphEdgeList(G, 5); 109 checkGraphArcList(G, 10); 110 checkGraphFaceList(G, 3); 111 112 G.split(a1); 113 114 checkGraphNodeList(G, 5); 115 checkGraphEdgeList(G, 6); 116 checkGraphArcList(G, 12); 117 checkGraphFaceList(G, 3); 118 119 checkGraphIncEdgeArcLists(G, n0, 3); 120 checkGraphIncEdgeArcLists(G, n1, 2); 121 checkGraphIncEdgeArcLists(G, n2, 2); 122 checkGraphIncEdgeArcLists(G, n3, 3); 123 124 checkGraphBoundaryArcList(G, G.leftFace(G.direct(a0,true)), 4); 125 checkGraphBoundaryArcList(G, G.leftFace(G.direct(a0,false)), 4); 126 checkGraphBoundaryArcList(G, G.leftFace(G.direct(a1,false)), 4); 127 128 checkGraphConEdgeList(G, 6); 129 checkGraphConArcList(G, 12); 130 131 } 132 133 template <class Graph> 134 void checkGraphErase() { 135 TEMPLATE_GRAPH_TYPEDEFS(Graph); 136 137 Graph G; 138 Node n1 = G.addNode(), 139 n2 = G.addNode(), 140 n3 = G.addNode(), 141 n4 = G.addNode(); 142 Edge e1 = G.addEdge(n1, n2, INVALID, INVALID), 143 e2 = G.addEdge(n2, n1, e1, e1), 144 e3 = G.addEdge(n2, n3, e1, INVALID), 145 e4 = G.addEdge(n1, n4, e2, INVALID), 146 e5 = G.addEdge(n4, n3, e4, e3); 147 148 // Check edge deletion 149 G.erase(e2); 150 151 checkGraphNodeList(G, 4); 152 checkGraphEdgeList(G, 4); 153 checkGraphArcList(G, 8); 154 checkGraphFaceList(G, 2); 155 156 checkGraphIncEdgeArcLists(G, n1, 2); 157 checkGraphIncEdgeArcLists(G, n2, 2); 158 checkGraphIncEdgeArcLists(G, n3, 2); 159 checkGraphIncEdgeArcLists(G, n4, 2); 160 161 checkGraphBoundaryArcList(G, G.leftFace(G.direct(e1,true)), 4); 162 checkGraphBoundaryArcList(G, G.leftFace(G.direct(e1,false)), 4); 163 164 checkGraphConEdgeList(G, 4); 165 checkGraphConArcList(G, 8); 166 167 // Check node deletion 168 G.erase(n3); 169 170 checkGraphNodeList(G, 3); 171 checkGraphEdgeList(G, 2); 172 checkGraphArcList(G, 4); 173 checkGraphFaceList(G, 1); 174 175 checkGraphIncEdgeArcLists(G, n1, 2); 176 checkGraphIncEdgeArcLists(G, n2, 1); 177 checkGraphIncEdgeArcLists(G, n4, 1); 178 179 checkGraphBoundaryArcList(G, G.leftFace(G.direct(e1,true)), 4); 180 181 checkGraphConEdgeList(G, 2); 182 checkGraphConArcList(G, 4); 183 } 184 185 186 template <class Graph> 187 void checkGraphSnapshot() { 188 TEMPLATE_GRAPH_TYPEDEFS(Graph); 189 190 Graph G; 191 Node n1 = G.addNode(), 192 n2 = G.addNode(), 193 n3 = G.addNode(); 194 Edge e1 = G.addEdge(n1, n2, INVALID, INVALID), 195 e2 = G.addEdge(n2, n1, e1, e1), 196 e3 = G.addEdge(n2, n3, e1, INVALID); 197 198 checkGraphNodeList(G, 3); 199 checkGraphEdgeList(G, 3); 200 checkGraphArcList(G, 6); 201 checkGraphFaceList(G, 2); 202 203 typename Graph::Snapshot snapshot(G); 204 205 Node n = G.addNode(); 206 Edge ea4 = G.addEdge(n3, n, e3, INVALID), 207 ea5 = G.addEdge(n, n3, ea4, ea4), 208 ea6 = G.addEdge(n3, n2, ea5, e3); 209 210 checkGraphNodeList(G, 4); 211 checkGraphEdgeList(G, 6); 212 checkGraphArcList(G, 12); 213 checkGraphFaceList(G, 4); 214 215 snapshot.restore(); 216 217 checkGraphNodeList(G, 3); 218 checkGraphEdgeList(G, 3); 219 checkGraphArcList(G, 6); 220 checkGraphFaceList(G, 2); 221 222 checkGraphIncEdgeArcLists(G, n1, 2); 223 checkGraphIncEdgeArcLists(G, n2, 3); 224 checkGraphIncEdgeArcLists(G, n3, 1); 225 checkGraphBoundaryArcList(G, G.leftFace(G.direct(e1,true)), 2); 226 checkGraphBoundaryArcList(G, G.leftFace(G.direct(e1,false)), 4); 227 228 checkGraphConEdgeList(G, 3); 229 checkGraphConArcList(G, 6); 230 231 checkNodeIds(G); 232 checkEdgeIds(G); 233 checkArcIds(G); 234 checkFaceIds(G); 235 checkGraphNodeMap(G); 236 checkGraphEdgeMap(G); 237 checkGraphArcMap(G); 238 checkGraphFaceMap(G); 239 240 G.addNode(); 241 snapshot.save(G); 242 243 G.addEdge(G.addNode(), G.addNode(), INVALID, INVALID); 244 245 snapshot.restore(); 246 snapshot.save(G); 247 248 checkGraphNodeList(G, 4); 249 checkGraphEdgeList(G, 3); 250 checkGraphArcList(G, 6); 251 checkGraphFaceList(G, 3); 252 253 G.addEdge(G.addNode(), G.addNode(), INVALID, INVALID); 254 255 snapshot.restore(); 256 257 checkGraphNodeList(G, 4); 258 checkGraphEdgeList(G, 3); 259 checkGraphArcList(G, 6); 260 checkGraphFaceList(G, 3); 261 } 262 263 template <typename Graph> 264 void checkGraphValidity() { 265 TEMPLATE_GRAPH_TYPEDEFS(Graph); 266 Graph g; 267 268 Node 269 n1 = g.addNode(), 270 n2 = g.addNode(), 271 n3 = g.addNode(); 272 273 Edge 274 e1 = g.addEdge(n1, n2, INVALID, INVALID), 275 e2 = g.addEdge(n2, n3, e1, INVALID); 276 277 check(g.valid(n1), "Wrong validity check"); 278 check(g.valid(e1), "Wrong validity check"); 279 check(g.valid(g.direct(e1, true)), "Wrong validity check"); 280 281 check(!g.valid(g.nodeFromId(-1)), "Wrong validity check"); 282 check(!g.valid(g.edgeFromId(-1)), "Wrong validity check"); 283 check(!g.valid(g.arcFromId(-1)), "Wrong validity check"); 284 check(!g.valid(g.faceFromId(-1)), "Wrong validity check"); 285 } 286 287 template <typename Graph> 288 void checkGraphValidityErase() { 289 TEMPLATE_GRAPH_TYPEDEFS(Graph); 290 Graph g; 291 292 Node 293 n1 = g.addNode(), 294 n2 = g.addNode(), 295 n3 = g.addNode(); 296 297 Edge 298 e1 = g.addEdge(n1, n2, INVALID, INVALID), 299 e2 = g.addEdge(n2, n3, e1, INVALID); 300 301 check(g.valid(n1), "Wrong validity check"); 302 check(g.valid(e1), "Wrong validity check"); 303 check(g.valid(g.direct(e1, true)), "Wrong validity check"); 304 305 g.erase(n1); 306 307 check(!g.valid(n1), "Wrong validity check"); 308 check(g.valid(n2), "Wrong validity check"); 309 check(g.valid(n3), "Wrong validity check"); 310 check(!g.valid(e1), "Wrong validity check"); 311 check(g.valid(e2), "Wrong validity check"); 312 313 check(!g.valid(g.nodeFromId(-1)), "Wrong validity check"); 314 check(!g.valid(g.edgeFromId(-1)), "Wrong validity check"); 315 check(!g.valid(g.arcFromId(-1)), "Wrong validity check"); 316 check(!g.valid(g.faceFromId(-1)), "Wrong validity check"); 317 } 318 319 void checkGraphs() { 320 { // Checking PlanarGraph 321 checkGraphBuild<PlanarGraph>(); 322 checkGraphArcSplit<PlanarGraph>(); 323 checkGraphErase<PlanarGraph>(); 324 checkGraphSnapshot<PlanarGraph>(); 325 checkGraphValidityErase<PlanarGraph>(); 326 } 327 } 328 329 int main() { 330 checkGraphs(); 331 return 0; 332 } -
new file test/planar_graph_test.h
diff -r 941e63d323f1 -r 4e27249fd00f test/planar_graph_test.h
- + 1 /* -*- mode: C++; indent-tabs-mode: nil; -*- 2 * 3 * This file is a part of LEMON, a generic C++ optimization library. 4 * 5 * Copyright (C) 2003-2009 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). 8 * 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. 12 * 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 15 * purpose. 16 * 17 */ 18 19 #ifndef LEMON_TEST_GRAPH_TEST_H 20 #define LEMON_TEST_GRAPH_TEST_H 21 22 #include <set> 23 24 #include <lemon/core.h> 25 #include <lemon/maps.h> 26 27 #include "test_tools.h" 28 29 namespace lemon { 30 31 template<class Graph> 32 void checkGraphNodeList(const Graph &G, int cnt) 33 { 34 typename Graph::NodeIt n(G); 35 for(int i=0;i<cnt;i++) { 36 check(n!=INVALID,"Wrong Node list linking."); 37 ++n; 38 } 39 check(n==INVALID,"Wrong Node list linking."); 40 check(countNodes(G)==cnt,"Wrong Node number."); 41 } 42 43 template<class Graph> 44 void checkGraphFaceList(const Graph &G, int cnt) 45 { 46 typename Graph::FaceIt n(G); 47 for(int i=0;i<cnt;i++) { 48 check(n!=INVALID,"Wrong Face list linking."); 49 ++n; 50 } 51 check(n==INVALID,"Wrong Face list linking."); 52 check(countFaces(G)==cnt,"Wrong Face number."); 53 } 54 55 template<class Graph> 56 void checkGraphArcList(const Graph &G, int cnt) 57 { 58 typename Graph::ArcIt e(G); 59 for(int i=0;i<cnt;i++) { 60 check(e!=INVALID,"Wrong Arc list linking."); 61 check(G.oppositeNode(G.source(e), e) == G.target(e), 62 "Wrong opposite node"); 63 check(G.oppositeNode(G.target(e), e) == G.source(e), 64 "Wrong opposite node"); 65 ++e; 66 } 67 check(e==INVALID,"Wrong Arc list linking."); 68 check(countArcs(G)==cnt,"Wrong Arc number."); 69 } 70 71 template<class Graph> 72 void checkGraphOutArcList(const Graph &G, typename Graph::Node n, int cnt) 73 { 74 typename Graph::OutArcIt e(G,n); 75 for(int i=0;i<cnt;i++) { 76 check(e!=INVALID,"Wrong OutArc list linking."); 77 check(n==G.source(e),"Wrong OutArc list linking."); 78 check(n==G.baseNode(e),"Wrong OutArc list linking."); 79 check(G.target(e)==G.runningNode(e),"Wrong OutArc list linking."); 80 ++e; 81 } 82 check(e==INVALID,"Wrong OutArc list linking."); 83 check(countOutArcs(G,n)==cnt,"Wrong OutArc number."); 84 } 85 86 template<class Graph> 87 void checkGraphInArcList(const Graph &G, typename Graph::Node n, int cnt) 88 { 89 typename Graph::InArcIt e(G,n); 90 for(int i=0;i<cnt;i++) { 91 check(e!=INVALID,"Wrong InArc list linking."); 92 check(n==G.target(e),"Wrong InArc list linking."); 93 check(n==G.baseNode(e),"Wrong OutArc list linking."); 94 check(G.source(e)==G.runningNode(e),"Wrong OutArc list linking."); 95 ++e; 96 } 97 check(e==INVALID,"Wrong InArc list linking."); 98 check(countInArcs(G,n)==cnt,"Wrong InArc number."); 99 } 100 101 template<class Graph> 102 void checkGraphEdgeList(const Graph &G, int cnt) 103 { 104 typename Graph::EdgeIt e(G); 105 for(int i=0;i<cnt;i++) { 106 check(e!=INVALID,"Wrong Edge list linking."); 107 check(G.oppositeNode(G.u(e), e) == G.v(e), "Wrong opposite node"); 108 check(G.oppositeNode(G.v(e), e) == G.u(e), "Wrong opposite node"); 109 ++e; 110 } 111 check(e==INVALID,"Wrong Edge list linking."); 112 check(countEdges(G)==cnt,"Wrong Edge number."); 113 } 114 115 template<class Graph> 116 void checkGraphIncEdgeList(const Graph &G, typename Graph::Node n, int cnt) 117 { 118 typename Graph::IncEdgeIt e(G,n); 119 for(int i=0;i<cnt;i++) { 120 check(e!=INVALID,"Wrong IncEdge list linking."); 121 check(n==G.u(e) || n==G.v(e),"Wrong IncEdge list linking."); 122 check(n==G.baseNode(e),"Wrong OutArc list linking."); 123 check(G.u(e)==G.runningNode(e) || G.v(e)==G.runningNode(e), 124 "Wrong OutArc list linking."); 125 ++e; 126 } 127 check(e==INVALID,"Wrong IncEdge list linking."); 128 check(countIncEdges(G,n)==cnt,"Wrong IncEdge number."); 129 } 130 131 template <class Graph> 132 void checkGraphIncEdgeArcLists(const Graph &G, typename Graph::Node n, 133 int cnt) 134 { 135 checkGraphIncEdgeList(G, n, cnt); 136 checkGraphOutArcList(G, n, cnt); 137 checkGraphInArcList(G, n, cnt); 138 } 139 140 template<class Graph> 141 void checkGraphBoundaryArcList(const Graph &G, typename Graph::Face n, int 142 cnt) 143 { 144 // std::cout << G.id(n) << ' '; 145 // int alma = countBoundaryArcs(G,n); 146 // std::cout << alma << ':'; 147 typename Graph::CwBoundaryArcIt e(G,n); 148 for(int i=0;i<cnt;i++) { 149 // std::cout << ',' << G.id(e); 150 check(e!=INVALID,"Wrong CwBoundaryArc list linking."); 151 check(n==G.w1(e) || n==G.w2(e),"Wrong CwBoundaryArc list linking."); 152 ++e; 153 } 154 // std::cout << std::endl; 155 check(e==INVALID,"Wrong BoundaryArc list linking."); 156 check(countBoundaryArcs(G,n)==cnt,"Wrong IncEdge number."); 157 } 158 159 template <class Graph> 160 void checkGraphConArcList(const Graph &G, int cnt) { 161 int i = 0; 162 for (typename Graph::NodeIt u(G); u != INVALID; ++u) { 163 for (typename Graph::NodeIt v(G); v != INVALID; ++v) { 164 for (ConArcIt<Graph> a(G, u, v); a != INVALID; ++a) { 165 check(G.source(a) == u, "Wrong iterator."); 166 check(G.target(a) == v, "Wrong iterator."); 167 ++i; 168 } 169 } 170 } 171 check(cnt == i, "Wrong iterator."); 172 } 173 174 template <class Graph> 175 void checkGraphConEdgeList(const Graph &G, int cnt) { 176 int i = 0; 177 for (typename Graph::NodeIt u(G); u != INVALID; ++u) { 178 for (typename Graph::NodeIt v(G); v != INVALID; ++v) { 179 for (ConEdgeIt<Graph> e(G, u, v); e != INVALID; ++e) { 180 check((G.u(e) == u && G.v(e) == v) || 181 (G.u(e) == v && G.v(e) == u), "Wrong iterator."); 182 i += u == v ? 2 : 1; 183 } 184 } 185 } 186 check(2 * cnt == i, "Wrong iterator."); 187 } 188 189 template <typename Graph> 190 void checkArcDirections(const Graph& G) { 191 for (typename Graph::ArcIt a(G); a != INVALID; ++a) { 192 check(G.source(a) == G.target(G.oppositeArc(a)), "Wrong direction"); 193 check(G.target(a) == G.source(G.oppositeArc(a)), "Wrong direction"); 194 check(G.direct(a, G.direction(a)) == a, "Wrong direction"); 195 } 196 } 197 198 template <typename Graph> 199 void checkNodeIds(const Graph& G) { 200 std::set<int> values; 201 for (typename Graph::NodeIt n(G); n != INVALID; ++n) { 202 check(G.nodeFromId(G.id(n)) == n, "Wrong id"); 203 check(values.find(G.id(n)) == values.end(), "Wrong id"); 204 check(G.id(n) <= G.maxNodeId(), "Wrong maximum id"); 205 values.insert(G.id(n)); 206 } 207 } 208 209 template <typename Graph> 210 void checkArcIds(const Graph& G) { 211 std::set<int> values; 212 for (typename Graph::ArcIt a(G); a != INVALID; ++a) { 213 check(G.arcFromId(G.id(a)) == a, "Wrong id"); 214 check(values.find(G.id(a)) == values.end(), "Wrong id"); 215 check(G.id(a) <= G.maxArcId(), "Wrong maximum id"); 216 values.insert(G.id(a)); 217 } 218 } 219 220 template <typename Graph> 221 void checkEdgeIds(const Graph& G) { 222 std::set<int> values; 223 for (typename Graph::EdgeIt e(G); e != INVALID; ++e) { 224 check(G.edgeFromId(G.id(e)) == e, "Wrong id"); 225 check(values.find(G.id(e)) == values.end(), "Wrong id"); 226 check(G.id(e) <= G.maxEdgeId(), "Wrong maximum id"); 227 values.insert(G.id(e)); 228 } 229 } 230 231 template <typename Graph> 232 void checkFaceIds(const Graph& G) { 233 std::set<int> values; 234 for (typename Graph::FaceIt n(G); n != INVALID; ++n) { 235 check(G.faceFromId(G.id(n)) == n, "Wrong id"); 236 check(values.find(G.id(n)) == values.end(), "Wrong id"); 237 check(G.id(n) <= G.maxFaceId(), "Wrong maximum id"); 238 values.insert(G.id(n)); 239 } 240 } 241 242 template <typename Graph> 243 void checkGraphNodeMap(const Graph& G) { 244 typedef typename Graph::Node Node; 245 typedef typename Graph::NodeIt NodeIt; 246 247 typedef typename Graph::template NodeMap<int> IntNodeMap; 248 IntNodeMap map(G, 42); 249 for (NodeIt it(G); it != INVALID; ++it) { 250 check(map[it] == 42, "Wrong map constructor."); 251 } 252 int s = 0; 253 for (NodeIt it(G); it != INVALID; ++it) { 254 map[it] = 0; 255 check(map[it] == 0, "Wrong operator[]."); 256 map.set(it, s); 257 check(map[it] == s, "Wrong set."); 258 ++s; 259 } 260 s = s * (s - 1) / 2; 261 for (NodeIt it(G); it != INVALID; ++it) { 262 s -= map[it]; 263 } 264 check(s == 0, "Wrong sum."); 265 266 // map = constMap<Node>(12); 267 // for (NodeIt it(G); it != INVALID; ++it) { 268 // check(map[it] == 12, "Wrong operator[]."); 269 // } 270 } 271 272 template <typename Graph> 273 void checkGraphArcMap(const Graph& G) { 274 typedef typename Graph::Arc Arc; 275 typedef typename Graph::ArcIt ArcIt; 276 277 typedef typename Graph::template ArcMap<int> IntArcMap; 278 IntArcMap map(G, 42); 279 for (ArcIt it(G); it != INVALID; ++it) { 280 check(map[it] == 42, "Wrong map constructor."); 281 } 282 int s = 0; 283 for (ArcIt it(G); it != INVALID; ++it) { 284 map[it] = 0; 285 check(map[it] == 0, "Wrong operator[]."); 286 map.set(it, s); 287 check(map[it] == s, "Wrong set."); 288 ++s; 289 } 290 s = s * (s - 1) / 2; 291 for (ArcIt it(G); it != INVALID; ++it) { 292 s -= map[it]; 293 } 294 check(s == 0, "Wrong sum."); 295 296 // map = constMap<Arc>(12); 297 // for (ArcIt it(G); it != INVALID; ++it) { 298 // check(map[it] == 12, "Wrong operator[]."); 299 // } 300 } 301 302 template <typename Graph> 303 void checkGraphEdgeMap(const Graph& G) { 304 typedef typename Graph::Edge Edge; 305 typedef typename Graph::EdgeIt EdgeIt; 306 307 typedef typename Graph::template EdgeMap<int> IntEdgeMap; 308 IntEdgeMap map(G, 42); 309 for (EdgeIt it(G); it != INVALID; ++it) { 310 check(map[it] == 42, "Wrong map constructor."); 311 } 312 int s = 0; 313 for (EdgeIt it(G); it != INVALID; ++it) { 314 map[it] = 0; 315 check(map[it] == 0, "Wrong operator[]."); 316 map.set(it, s); 317 check(map[it] == s, "Wrong set."); 318 ++s; 319 } 320 s = s * (s - 1) / 2; 321 for (EdgeIt it(G); it != INVALID; ++it) { 322 s -= map[it]; 323 } 324 check(s == 0, "Wrong sum."); 325 326 // map = constMap<Edge>(12); 327 // for (EdgeIt it(G); it != INVALID; ++it) { 328 // check(map[it] == 12, "Wrong operator[]."); 329 // } 330 } 331 332 333 template <typename Graph> 334 void checkGraphFaceMap(const Graph& G) { 335 typedef typename Graph::Face Face; 336 typedef typename Graph::FaceIt FaceIt; 337 338 typedef typename Graph::template FaceMap<int> IntFaceMap; 339 IntFaceMap map(G, 42); 340 for (FaceIt it(G); it != INVALID; ++it) { 341 check(map[it] == 42, "Wrong map constructor."); 342 } 343 int s = 0; 344 for (FaceIt it(G); it != INVALID; ++it) { 345 map[it] = 0; 346 check(map[it] == 0, "Wrong operator[]."); 347 map.set(it, s); 348 check(map[it] == s, "Wrong set."); 349 ++s; 350 } 351 s = s * (s - 1) / 2; 352 for (FaceIt it(G); it != INVALID; ++it) { 353 s -= map[it]; 354 } 355 check(s == 0, "Wrong sum."); 356 357 // map = constMap<Node>(12); 358 // for (NodeIt it(G); it != INVALID; ++it) { 359 // check(map[it] == 12, "Wrong operator[]."); 360 // } 361 } 362 363 } //namespace lemon 364 365 #endif