test/graph_copy_test.cc
changeset 1088 4000b7ef4e01
parent 1025 c8fa41fcc4a7
child 1092 dceba191c00d
equal deleted inserted replaced
9:8b1b2c15ed14 10:2b67c5889554
   214   const int nn = 10;
   214   const int nn = 10;
   215 
   215 
   216   // Build a graph
   216   // Build a graph
   217   SmartBpGraph from;
   217   SmartBpGraph from;
   218   SmartBpGraph::NodeMap<int> fnm(from);
   218   SmartBpGraph::NodeMap<int> fnm(from);
   219   SmartBpGraph::RedMap<int> frnm(from);
   219   SmartBpGraph::RedNodeMap<int> frnm(from);
   220   SmartBpGraph::BlueMap<int> fbnm(from);
   220   SmartBpGraph::BlueNodeMap<int> fbnm(from);
   221   SmartBpGraph::ArcMap<int> fam(from);
   221   SmartBpGraph::ArcMap<int> fam(from);
   222   SmartBpGraph::EdgeMap<int> fem(from);
   222   SmartBpGraph::EdgeMap<int> fem(from);
   223   SmartBpGraph::Node fn = INVALID;
   223   SmartBpGraph::Node fn = INVALID;
   224   SmartBpGraph::RedNode frn = INVALID;
   224   SmartBpGraph::RedNode frn = INVALID;
   225   SmartBpGraph::BlueNode fbn = INVALID;
   225   SmartBpGraph::BlueNode fbn = INVALID;
   259   }
   259   }
   260 
   260 
   261   // Test graph copy
   261   // Test graph copy
   262   GR to;
   262   GR to;
   263   typename GR::template NodeMap<int> tnm(to);
   263   typename GR::template NodeMap<int> tnm(to);
   264   typename GR::template RedMap<int> trnm(to);
   264   typename GR::template RedNodeMap<int> trnm(to);
   265   typename GR::template BlueMap<int> tbnm(to);
   265   typename GR::template BlueNodeMap<int> tbnm(to);
   266   typename GR::template ArcMap<int> tam(to);
   266   typename GR::template ArcMap<int> tam(to);
   267   typename GR::template EdgeMap<int> tem(to);
   267   typename GR::template EdgeMap<int> tem(to);
   268   typename GR::Node tn;
   268   typename GR::Node tn;
   269   typename GR::RedNode trn;
   269   typename GR::RedNode trn;
   270   typename GR::BlueNode tbn;
   270   typename GR::BlueNode tbn;
   271   typename GR::Arc ta;
   271   typename GR::Arc ta;
   272   typename GR::Edge te;
   272   typename GR::Edge te;
   273 
   273 
   274   SmartBpGraph::NodeMap<typename GR::Node> nr(from);
   274   SmartBpGraph::NodeMap<typename GR::Node> nr(from);
   275   SmartBpGraph::RedMap<typename GR::RedNode> rnr(from);
   275   SmartBpGraph::RedNodeMap<typename GR::RedNode> rnr(from);
   276   SmartBpGraph::BlueMap<typename GR::BlueNode> bnr(from);
   276   SmartBpGraph::BlueNodeMap<typename GR::BlueNode> bnr(from);
   277   SmartBpGraph::ArcMap<typename GR::Arc> ar(from);
   277   SmartBpGraph::ArcMap<typename GR::Arc> ar(from);
   278   SmartBpGraph::EdgeMap<typename GR::Edge> er(from);
   278   SmartBpGraph::EdgeMap<typename GR::Edge> er(from);
   279 
   279 
   280   typename GR::template NodeMap<SmartBpGraph::Node> ncr(to);
   280   typename GR::template NodeMap<SmartBpGraph::Node> ncr(to);
   281   typename GR::template RedMap<SmartBpGraph::RedNode> rncr(to);
   281   typename GR::template RedNodeMap<SmartBpGraph::RedNode> rncr(to);
   282   typename GR::template BlueMap<SmartBpGraph::BlueNode> bncr(to);
   282   typename GR::template BlueNodeMap<SmartBpGraph::BlueNode> bncr(to);
   283   typename GR::template ArcMap<SmartBpGraph::Arc> acr(to);
   283   typename GR::template ArcMap<SmartBpGraph::Arc> acr(to);
   284   typename GR::template EdgeMap<SmartBpGraph::Edge> ecr(to);
   284   typename GR::template EdgeMap<SmartBpGraph::Edge> ecr(to);
   285 
   285 
   286   bpGraphCopy(from, to).
   286   bpGraphCopy(from, to).
   287     nodeMap(fnm, tnm).redMap(frnm, trnm).blueMap(fbnm, tbnm).
   287     nodeMap(fnm, tnm).
       
   288     redNodeMap(frnm, trnm).blueNodeMap(fbnm, tbnm).
   288     arcMap(fam, tam).edgeMap(fem, tem).
   289     arcMap(fam, tam).edgeMap(fem, tem).
   289     nodeRef(nr).redRef(rnr).blueRef(bnr).
   290     nodeRef(nr).redRef(rnr).blueRef(bnr).
   290     arcRef(ar).edgeRef(er).
   291     arcRef(ar).edgeRef(er).
   291     nodeCrossRef(ncr).redCrossRef(rncr).blueCrossRef(bncr).
   292     nodeCrossRef(ncr).redCrossRef(rncr).blueCrossRef(bncr).
   292     arcCrossRef(acr).edgeCrossRef(ecr).
   293     arcCrossRef(acr).edgeCrossRef(ecr).
   302   for (SmartBpGraph::NodeIt it(from); it != INVALID; ++it) {
   303   for (SmartBpGraph::NodeIt it(from); it != INVALID; ++it) {
   303     check(ncr[nr[it]] == it, "Wrong copy.");
   304     check(ncr[nr[it]] == it, "Wrong copy.");
   304     check(fnm[it] == tnm[nr[it]], "Wrong copy.");
   305     check(fnm[it] == tnm[nr[it]], "Wrong copy.");
   305   }
   306   }
   306 
   307 
   307   for (SmartBpGraph::RedIt it(from); it != INVALID; ++it) {
   308   for (SmartBpGraph::RedNodeIt it(from); it != INVALID; ++it) {
   308     check(ncr[nr[it]] == it, "Wrong copy.");
   309     check(ncr[nr[it]] == it, "Wrong copy.");
   309     check(fnm[it] == tnm[nr[it]], "Wrong copy.");
   310     check(fnm[it] == tnm[nr[it]], "Wrong copy.");
   310     check(rnr[it] == nr[it], "Wrong copy.");
   311     check(rnr[it] == nr[it], "Wrong copy.");
   311     check(rncr[rnr[it]] == it, "Wrong copy.");
   312     check(rncr[rnr[it]] == it, "Wrong copy.");
   312     check(frnm[it] == trnm[rnr[it]], "Wrong copy.");
   313     check(frnm[it] == trnm[rnr[it]], "Wrong copy.");
   313     check(to.red(rnr[it]), "Wrong copy.");
   314     check(to.red(rnr[it]), "Wrong copy.");
   314   }
   315   }
   315 
   316 
   316   for (SmartBpGraph::BlueIt it(from); it != INVALID; ++it) {
   317   for (SmartBpGraph::BlueNodeIt it(from); it != INVALID; ++it) {
   317     check(ncr[nr[it]] == it, "Wrong copy.");
   318     check(ncr[nr[it]] == it, "Wrong copy.");
   318     check(fnm[it] == tnm[nr[it]], "Wrong copy.");
   319     check(fnm[it] == tnm[nr[it]], "Wrong copy.");
   319     check(bnr[it] == nr[it], "Wrong copy.");
   320     check(bnr[it] == nr[it], "Wrong copy.");
   320     check(bncr[bnr[it]] == it, "Wrong copy.");
   321     check(bncr[bnr[it]] == it, "Wrong copy.");
   321     check(fbnm[it] == tbnm[bnr[it]], "Wrong copy.");
   322     check(fbnm[it] == tbnm[bnr[it]], "Wrong copy.");
   341   }
   342   }
   342 
   343 
   343   for (typename GR::NodeIt it(to); it != INVALID; ++it) {
   344   for (typename GR::NodeIt it(to); it != INVALID; ++it) {
   344     check(nr[ncr[it]] == it, "Wrong copy.");
   345     check(nr[ncr[it]] == it, "Wrong copy.");
   345   }
   346   }
   346   for (typename GR::RedIt it(to); it != INVALID; ++it) {
   347   for (typename GR::RedNodeIt it(to); it != INVALID; ++it) {
   347     check(rncr[it] == ncr[it], "Wrong copy.");
   348     check(rncr[it] == ncr[it], "Wrong copy.");
   348     check(rnr[rncr[it]] == it, "Wrong copy.");
   349     check(rnr[rncr[it]] == it, "Wrong copy.");
   349   }
   350   }
   350   for (typename GR::BlueIt it(to); it != INVALID; ++it) {
   351   for (typename GR::BlueNodeIt it(to); it != INVALID; ++it) {
   351     check(bncr[it] == ncr[it], "Wrong copy.");
   352     check(bncr[it] == ncr[it], "Wrong copy.");
   352     check(bnr[bncr[it]] == it, "Wrong copy.");
   353     check(bnr[bncr[it]] == it, "Wrong copy.");
   353   }
   354   }
   354   for (typename GR::ArcIt it(to); it != INVALID; ++it) {
   355   for (typename GR::ArcIt it(to); it != INVALID; ++it) {
   355     check(ar[acr[it]] == it, "Wrong copy.");
   356     check(ar[acr[it]] == it, "Wrong copy.");