Changes in test/graph_test.h [440:88ed40ad0d4f:1027:8b2b9e61d8ce] in lemon-main
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/graph_test.h
r440 r1027 42 42 43 43 template<class Graph> 44 void checkGraphRedNodeList(const Graph &G, int cnt) 45 { 46 typename Graph::RedNodeIt n(G); 47 for(int i=0;i<cnt;i++) { 48 check(n!=INVALID,"Wrong red Node list linking."); 49 check(G.red(n),"Wrong node set check."); 50 check(!G.blue(n),"Wrong node set check."); 51 typename Graph::Node nn = n; 52 check(G.asRedNodeUnsafe(nn) == n,"Wrong node conversion."); 53 check(G.asRedNode(nn) == n,"Wrong node conversion."); 54 check(G.asBlueNode(nn) == INVALID,"Wrong node conversion."); 55 ++n; 56 } 57 check(n==INVALID,"Wrong red Node list linking."); 58 check(countRedNodes(G)==cnt,"Wrong red Node number."); 59 } 60 61 template<class Graph> 62 void checkGraphBlueNodeList(const Graph &G, int cnt) 63 { 64 typename Graph::BlueNodeIt n(G); 65 for(int i=0;i<cnt;i++) { 66 check(n!=INVALID,"Wrong blue Node list linking."); 67 check(G.blue(n),"Wrong node set check."); 68 check(!G.red(n),"Wrong node set check."); 69 typename Graph::Node nn = n; 70 check(G.asBlueNodeUnsafe(nn) == n,"Wrong node conversion."); 71 check(G.asBlueNode(nn) == n,"Wrong node conversion."); 72 check(G.asRedNode(nn) == INVALID,"Wrong node conversion."); 73 ++n; 74 } 75 check(n==INVALID,"Wrong blue Node list linking."); 76 check(countBlueNodes(G)==cnt,"Wrong blue Node number."); 77 } 78 79 template<class Graph> 44 80 void checkGraphArcList(const Graph &G, int cnt) 45 81 { … … 167 203 template <typename Graph> 168 204 void checkNodeIds(const Graph& G) { 205 typedef typename Graph::Node Node; 169 206 std::set<int> values; 170 207 for (typename Graph::NodeIt n(G); n != INVALID; ++n) { … … 174 211 values.insert(G.id(n)); 175 212 } 213 check(G.maxId(Node()) <= G.maxNodeId(), "Wrong maximum id"); 214 } 215 216 template <typename Graph> 217 void checkRedNodeIds(const Graph& G) { 218 typedef typename Graph::RedNode RedNode; 219 std::set<int> values; 220 for (typename Graph::RedNodeIt n(G); n != INVALID; ++n) { 221 check(G.red(n), "Wrong partition"); 222 check(values.find(G.id(n)) == values.end(), "Wrong id"); 223 check(G.id(n) <= G.maxRedId(), "Wrong maximum id"); 224 values.insert(G.id(n)); 225 } 226 check(G.maxId(RedNode()) == G.maxRedId(), "Wrong maximum id"); 227 } 228 229 template <typename Graph> 230 void checkBlueNodeIds(const Graph& G) { 231 typedef typename Graph::BlueNode BlueNode; 232 std::set<int> values; 233 for (typename Graph::BlueNodeIt n(G); n != INVALID; ++n) { 234 check(G.blue(n), "Wrong partition"); 235 check(values.find(G.id(n)) == values.end(), "Wrong id"); 236 check(G.id(n) <= G.maxBlueId(), "Wrong maximum id"); 237 values.insert(G.id(n)); 238 } 239 check(G.maxId(BlueNode()) == G.maxBlueId(), "Wrong maximum id"); 176 240 } 177 241 178 242 template <typename Graph> 179 243 void checkArcIds(const Graph& G) { 244 typedef typename Graph::Arc Arc; 180 245 std::set<int> values; 181 246 for (typename Graph::ArcIt a(G); a != INVALID; ++a) { … … 185 250 values.insert(G.id(a)); 186 251 } 252 check(G.maxId(Arc()) <= G.maxArcId(), "Wrong maximum id"); 187 253 } 188 254 189 255 template <typename Graph> 190 256 void checkEdgeIds(const Graph& G) { 257 typedef typename Graph::Edge Edge; 191 258 std::set<int> values; 192 259 for (typename Graph::EdgeIt e(G); e != INVALID; ++e) { … … 196 263 values.insert(G.id(e)); 197 264 } 265 check(G.maxId(Edge()) <= G.maxEdgeId(), "Wrong maximum id"); 198 266 } 199 267 … … 229 297 230 298 template <typename Graph> 299 void checkGraphRedNodeMap(const Graph& G) { 300 typedef typename Graph::Node Node; 301 typedef typename Graph::RedNodeIt RedNodeIt; 302 303 typedef typename Graph::template RedNodeMap<int> IntRedNodeMap; 304 IntRedNodeMap map(G, 42); 305 for (RedNodeIt it(G); it != INVALID; ++it) { 306 check(map[it] == 42, "Wrong map constructor."); 307 } 308 int s = 0; 309 for (RedNodeIt it(G); it != INVALID; ++it) { 310 map[it] = 0; 311 check(map[it] == 0, "Wrong operator[]."); 312 map.set(it, s); 313 check(map[it] == s, "Wrong set."); 314 ++s; 315 } 316 s = s * (s - 1) / 2; 317 for (RedNodeIt it(G); it != INVALID; ++it) { 318 s -= map[it]; 319 } 320 check(s == 0, "Wrong sum."); 321 322 // map = constMap<Node>(12); 323 // for (NodeIt it(G); it != INVALID; ++it) { 324 // check(map[it] == 12, "Wrong operator[]."); 325 // } 326 } 327 328 template <typename Graph> 329 void checkGraphBlueNodeMap(const Graph& G) { 330 typedef typename Graph::Node Node; 331 typedef typename Graph::BlueNodeIt BlueNodeIt; 332 333 typedef typename Graph::template BlueNodeMap<int> IntBlueNodeMap; 334 IntBlueNodeMap map(G, 42); 335 for (BlueNodeIt it(G); it != INVALID; ++it) { 336 check(map[it] == 42, "Wrong map constructor."); 337 } 338 int s = 0; 339 for (BlueNodeIt it(G); it != INVALID; ++it) { 340 map[it] = 0; 341 check(map[it] == 0, "Wrong operator[]."); 342 map.set(it, s); 343 check(map[it] == s, "Wrong set."); 344 ++s; 345 } 346 s = s * (s - 1) / 2; 347 for (BlueNodeIt it(G); it != INVALID; ++it) { 348 s -= map[it]; 349 } 350 check(s == 0, "Wrong sum."); 351 352 // map = constMap<Node>(12); 353 // for (NodeIt it(G); it != INVALID; ++it) { 354 // check(map[it] == 12, "Wrong operator[]."); 355 // } 356 } 357 358 template <typename Graph> 231 359 void checkGraphArcMap(const Graph& G) { 232 360 typedef typename Graph::Arc Arc;
Note: See TracChangeset
for help on using the changeset viewer.