COIN-OR::LEMON - Graph Library

Ignore:
Timestamp:
12/01/11 09:05:47 (9 years ago)
Author:
Balazs Dezso <deba@…>
Branch:
default
Phase:
public
Message:

Type safe red and blue node set (#69)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/graph_copy_test.cc

    r1190 r1193  
    222222  SmartBpGraph::EdgeMap<int> fem(from);
    223223  SmartBpGraph::Node fn = INVALID;
     224  SmartBpGraph::RedNode frn = INVALID;
     225  SmartBpGraph::BlueNode fbn = INVALID;
    224226  SmartBpGraph::Arc fa = INVALID;
    225227  SmartBpGraph::Edge fe = INVALID;
    226228
    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();
    230232    frnv.push_back(node);
    231233    fnm[node] = i * i;
    232234    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();
    239244    fbnv.push_back(node);
    240245    fnm[node] = i * i;
    241246    fbnm[node] = i + i;
     247    if (i == 0) fbn = node;
    242248  }
    243249
     
    261267  typename GR::template EdgeMap<int> tem(to);
    262268  typename GR::Node tn;
     269  typename GR::RedNode trn;
     270  typename GR::BlueNode tbn;
    263271  typename GR::Arc ta;
    264272  typename GR::Edge te;
    265273
    266274  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);
    269277  SmartBpGraph::ArcMap<typename GR::Arc> ar(from);
    270278  SmartBpGraph::EdgeMap<typename GR::Edge> er(from);
    271279
    272280  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);
    275283  typename GR::template ArcMap<SmartBpGraph::Arc> acr(to);
    276284  typename GR::template EdgeMap<SmartBpGraph::Edge> ecr(to);
     
    283291    nodeCrossRef(ncr).redCrossRef(rncr).blueCrossRef(bncr).
    284292    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();
    286295
    287296  check(countNodes(from) == countNodes(to), "Wrong copy.");
     
    294303    check(ncr[nr[it]] == it, "Wrong copy.");
    295304    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.");
    307323  }
    308324
     
    343359  }
    344360  check(tn == nr[fn], "Wrong copy.");
     361  check(trn == rnr[frn], "Wrong copy.");
     362  check(tbn == bnr[fbn], "Wrong copy.");
    345363  check(ta == ar[fa], "Wrong copy.");
    346364  check(te == er[fe], "Wrong copy.");
Note: See TracChangeset for help on using the changeset viewer.