Changeset 1025:c8fa41fcc4a7 in lemon-main for test
- Timestamp:
- 12/01/11 09:05:47 (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- test
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
test/bpgraph_test.cc
r1021 r1025 42 42 G.reserveEdge(3); 43 43 44 Node44 RedNode 45 45 rn1 = G.addRedNode(); 46 46 checkGraphNodeList(G, 1); … … 50 50 checkGraphArcList(G, 0); 51 51 52 Node52 BlueNode 53 53 bn1 = G.addBlueNode(), 54 54 bn2 = G.addBlueNode(); … … 77 77 78 78 Edge 79 e2 = G.addEdge( rn1, bn1),79 e2 = G.addEdge(bn1, rn1), 80 80 e3 = G.addEdge(rn1, bn2); 81 81 … … 113 113 114 114 BpGraph G; 115 Node 116 n1 = G.addRedNode(), n2 = G.addBlueNode(), 117 n3 = G.addBlueNode(), n4 = G.addRedNode(); 115 RedNode 116 n1 = G.addRedNode(), n4 = G.addRedNode(); 117 BlueNode 118 n2 = G.addBlueNode(), n3 = G.addBlueNode(); 118 119 Edge 119 120 e1 = G.addEdge(n1, n2), e2 = G.addEdge(n1, n3), … … 160 161 161 162 BpGraph G; 162 Node 163 n1 = G.addRedNode(), n2 = G.addBlueNode(), 164 n3 = G.addBlueNode(), n4 = G.addRedNode(); 163 RedNode 164 n1 = G.addRedNode(), n4 = G.addRedNode(); 165 BlueNode 166 n2 = G.addBlueNode(), n3 = G.addBlueNode(); 165 167 Edge 166 168 e1 = G.addEdge(n1, n2), e2 = G.addEdge(n1, n3), … … 210 212 211 213 BpGraph G; 212 Node 213 n1 = G.addRedNode(), 214 RedNode 215 n1 = G.addRedNode(); 216 BlueNode 214 217 n2 = G.addBlueNode(), 215 218 n3 = G.addBlueNode(); … … 226 229 typename BpGraph::Snapshot snapshot(G); 227 230 228 Node n4 = G.addRedNode();231 RedNode n4 = G.addRedNode(); 229 232 G.addEdge(n4, n2); 230 233 G.addEdge(n4, n3); … … 293 296 BpGraph g; 294 297 295 Node 296 n1 = g.addRedNode(), 298 RedNode 299 n1 = g.addRedNode(); 300 BlueNode 297 301 n2 = g.addBlueNode(), 298 302 n3 = g.addBlueNode(); … … 397 401 for (int i = 0; i < G.redNum(); ++i) { 398 402 check(G.red(G.redNode(i)), "Wrong node"); 399 check(G. redIndex(G.redNode(i)) == i, "Wrong index");403 check(G.index(G.redNode(i)) == i, "Wrong index"); 400 404 } 401 405 402 406 for (int i = 0; i < G.blueNum(); ++i) { 403 407 check(G.blue(G.blueNode(i)), "Wrong node"); 404 check(G. blueIndex(G.blueNode(i)) == i, "Wrong index");408 check(G.index(G.blueNode(i)) == i, "Wrong index"); 405 409 } 406 410 -
test/graph_copy_test.cc
r1022 r1025 222 222 SmartBpGraph::EdgeMap<int> fem(from); 223 223 SmartBpGraph::Node fn = INVALID; 224 SmartBpGraph::RedNode frn = INVALID; 225 SmartBpGraph::BlueNode fbn = INVALID; 224 226 SmartBpGraph::Arc fa = INVALID; 225 227 SmartBpGraph::Edge fe = INVALID; 226 228 227 std::vector<SmartBpGraph:: Node> frnv;228 for (int i = 0; i < nn; ++i) { 229 SmartBpGraph:: Node node = from.addRedNode();229 std::vector<SmartBpGraph::RedNode> frnv; 230 for (int i = 0; i < nn; ++i) { 231 SmartBpGraph::RedNode node = from.addRedNode(); 230 232 frnv.push_back(node); 231 233 fnm[node] = i * i; 232 234 frnm[node] = i + i; 233 if (i == 0) fn = node; 234 } 235 236 std::vector<SmartBpGraph::Node> fbnv; 237 for (int i = 0; i < nn; ++i) { 238 SmartBpGraph::Node node = from.addBlueNode(); 235 if (i == 0) { 236 fn = node; 237 frn = node; 238 } 239 } 240 241 std::vector<SmartBpGraph::BlueNode> fbnv; 242 for (int i = 0; i < nn; ++i) { 243 SmartBpGraph::BlueNode node = from.addBlueNode(); 239 244 fbnv.push_back(node); 240 245 fnm[node] = i * i; 241 246 fbnm[node] = i + i; 247 if (i == 0) fbn = node; 242 248 } 243 249 … … 261 267 typename GR::template EdgeMap<int> tem(to); 262 268 typename GR::Node tn; 269 typename GR::RedNode trn; 270 typename GR::BlueNode tbn; 263 271 typename GR::Arc ta; 264 272 typename GR::Edge te; 265 273 266 274 SmartBpGraph::NodeMap<typename GR::Node> nr(from); 267 SmartBpGraph::RedMap<typename GR:: Node> rnr(from);268 SmartBpGraph::BlueMap<typename GR:: Node> bnr(from);275 SmartBpGraph::RedMap<typename GR::RedNode> rnr(from); 276 SmartBpGraph::BlueMap<typename GR::BlueNode> bnr(from); 269 277 SmartBpGraph::ArcMap<typename GR::Arc> ar(from); 270 278 SmartBpGraph::EdgeMap<typename GR::Edge> er(from); 271 279 272 280 typename GR::template NodeMap<SmartBpGraph::Node> ncr(to); 273 typename GR::template RedMap<SmartBpGraph:: Node> rncr(to);274 typename GR::template BlueMap<SmartBpGraph:: Node> bncr(to);281 typename GR::template RedMap<SmartBpGraph::RedNode> rncr(to); 282 typename GR::template BlueMap<SmartBpGraph::BlueNode> bncr(to); 275 283 typename GR::template ArcMap<SmartBpGraph::Arc> acr(to); 276 284 typename GR::template EdgeMap<SmartBpGraph::Edge> ecr(to); … … 283 291 nodeCrossRef(ncr).redCrossRef(rncr).blueCrossRef(bncr). 284 292 arcCrossRef(acr).edgeCrossRef(ecr). 285 node(fn, tn).arc(fa, ta).edge(fe, te).run(); 293 node(fn, tn).redNode(frn, trn).blueNode(fbn, tbn). 294 arc(fa, ta).edge(fe, te).run(); 286 295 287 296 check(countNodes(from) == countNodes(to), "Wrong copy."); … … 294 303 check(ncr[nr[it]] == it, "Wrong copy."); 295 304 check(fnm[it] == tnm[nr[it]], "Wrong copy."); 296 if (from.red(it)) { 297 check(rnr[it] == nr[it], "Wrong copy."); 298 check(rncr[rnr[it]] == it, "Wrong copy."); 299 check(frnm[it] == trnm[rnr[it]], "Wrong copy."); 300 check(to.red(rnr[it]), "Wrong copy."); 301 } else { 302 check(bnr[it] == nr[it], "Wrong copy."); 303 check(bncr[bnr[it]] == it, "Wrong copy."); 304 check(fbnm[it] == tbnm[bnr[it]], "Wrong copy."); 305 check(to.blue(bnr[it]), "Wrong copy."); 306 } 305 } 306 307 for (SmartBpGraph::RedIt it(from); it != INVALID; ++it) { 308 check(ncr[nr[it]] == it, "Wrong copy."); 309 check(fnm[it] == tnm[nr[it]], "Wrong copy."); 310 check(rnr[it] == nr[it], "Wrong copy."); 311 check(rncr[rnr[it]] == it, "Wrong copy."); 312 check(frnm[it] == trnm[rnr[it]], "Wrong copy."); 313 check(to.red(rnr[it]), "Wrong copy."); 314 } 315 316 for (SmartBpGraph::BlueIt it(from); it != INVALID; ++it) { 317 check(ncr[nr[it]] == it, "Wrong copy."); 318 check(fnm[it] == tnm[nr[it]], "Wrong copy."); 319 check(bnr[it] == nr[it], "Wrong copy."); 320 check(bncr[bnr[it]] == it, "Wrong copy."); 321 check(fbnm[it] == tbnm[bnr[it]], "Wrong copy."); 322 check(to.blue(bnr[it]), "Wrong copy."); 307 323 } 308 324 … … 343 359 } 344 360 check(tn == nr[fn], "Wrong copy."); 361 check(trn == rnr[frn], "Wrong copy."); 362 check(tbn == bnr[fbn], "Wrong copy."); 345 363 check(ta == ar[fa], "Wrong copy."); 346 364 check(te == er[fe], "Wrong copy."); -
test/graph_test.h
r1019 r1025 47 47 for(int i=0;i<cnt;i++) { 48 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 std::pair<typename Graph::RedNode, typename Graph::BlueNode> rbn = 56 G.asRedBlueNode(nn); 57 check(rbn.first == n,"Wrong node conversion."); 58 check(rbn.second == INVALID,"Wrong node conversion."); 49 59 ++n; 50 60 } … … 59 69 for(int i=0;i<cnt;i++) { 60 70 check(n!=INVALID,"Wrong blue Node list linking."); 71 check(G.blue(n),"Wrong node set check."); 72 check(!G.red(n),"Wrong node set check."); 73 typename Graph::Node nn = n; 74 check(G.asBlueNodeUnsafe(nn) == n,"Wrong node conversion."); 75 check(G.asBlueNode(nn) == n,"Wrong node conversion."); 76 check(G.asRedNode(nn) == INVALID,"Wrong node conversion."); 77 std::pair<typename Graph::RedNode, typename Graph::BlueNode> rbn = 78 G.asRedBlueNode(nn); 79 check(rbn.first == INVALID,"Wrong node conversion."); 80 check(rbn.second == n,"Wrong node conversion."); 61 81 ++n; 62 82 } … … 208 228 for (typename Graph::RedIt n(G); n != INVALID; ++n) { 209 229 check(G.red(n), "Wrong partition"); 210 check(G.redId(n) == G.id(RedNode(n)), "Wrong id"); 211 check(values.find(G.redId(n)) == values.end(), "Wrong id"); 212 check(G.redId(n) <= G.maxRedId(), "Wrong maximum id"); 230 check(values.find(G.id(n)) == values.end(), "Wrong id"); 231 check(G.id(n) <= G.maxRedId(), "Wrong maximum id"); 213 232 values.insert(G.id(n)); 214 233 } … … 222 241 for (typename Graph::BlueIt n(G); n != INVALID; ++n) { 223 242 check(G.blue(n), "Wrong partition"); 224 check(G.blueId(n) == G.id(BlueNode(n)), "Wrong id"); 225 check(values.find(G.blueId(n)) == values.end(), "Wrong id"); 226 check(G.blueId(n) <= G.maxBlueId(), "Wrong maximum id"); 243 check(values.find(G.id(n)) == values.end(), "Wrong id"); 244 check(G.id(n) <= G.maxBlueId(), "Wrong maximum id"); 227 245 values.insert(G.id(n)); 228 246 }
Note: See TracChangeset
for help on using the changeset viewer.