COIN-OR::LEMON - Graph Library

Changeset 1382:e2732b9da429 in lemon


Ignore:
Timestamp:
03/22/18 18:55:31 (7 months ago)
Author:
Peter Kovacs <kpeter@…>
Branch:
default
Phase:
public
Message:

Refactoring and code formatting in max_flow_test.cc (#608)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/max_flow_test.cc

    r1381 r1382  
    183183
    184184template <typename T>
    185 T cutValue (const SmartDigraph& g,
    186               const SmartDigraph::NodeMap<bool>& cut,
    187               const SmartDigraph::ArcMap<T>& cap) {
    188 
    189   T c=0;
    190   for(SmartDigraph::ArcIt e(g); e!=INVALID; ++e) {
    191     if (cut[g.source(e)] && !cut[g.target(e)]) c+=cap[e];
     185T cutValue(const SmartDigraph& g,
     186           const SmartDigraph::NodeMap<bool>& cut,
     187           const SmartDigraph::ArcMap<T>& cap) {
     188
     189  T c = 0;
     190  for (SmartDigraph::ArcIt e(g); e != INVALID; ++e) {
     191    if (cut[g.source(e)] && !cut[g.target(e)]) c += cap[e];
    192192  }
    193193  return c;
     
    218218}
    219219
    220 void initFlowTest()
     220void checkInitPreflow()
    221221{
    222222  DIGRAPH_TYPEDEFS(SmartDigraph);
    223223
    224224  SmartDigraph g;
    225   SmartDigraph::ArcMap<int> cap(g),iflow(g);
    226   Node s=g.addNode(); Node t=g.addNode();
    227   Node n1=g.addNode(); Node n2=g.addNode();
     225  SmartDigraph::ArcMap<int> cap(g), iflow(g);
     226  Node s = g.addNode(); Node t = g.addNode();
     227  Node n1 = g.addNode(); Node n2 = g.addNode();
    228228  Arc a;
    229   a=g.addArc(s,n1); cap[a]=20; iflow[a]=20;
    230   a=g.addArc(n1,n2); cap[a]=10; iflow[a]=0;
    231   a=g.addArc(n2,t); cap[a]=20; iflow[a]=0;
    232 
    233   Preflow<SmartDigraph> pre(g,cap,s,t);
     229  a = g.addArc(s, n1); cap[a] = 20; iflow[a] = 20;
     230  a = g.addArc(n1, n2); cap[a] = 10; iflow[a] = 0;
     231  a = g.addArc(n2, t); cap[a] = 20; iflow[a] = 0;
     232
     233  Preflow<SmartDigraph> pre(g, cap, s, t);
    234234  pre.init(iflow);
    235235  pre.startFirstPhase();
    236   check(pre.flowValue() == 10, "The incorrect max flow value.");
     236
     237  check(pre.flowValue() == 10, "Incorrect max flow value.");
    237238  check(pre.minCut(s), "Wrong min cut (Node s).");
    238239  check(pre.minCut(n1), "Wrong min cut (Node n1).");
     
    303304  check(max_flow.flowValue() == min_cut_value &&
    304305        min_cut_value == 2 * flow_value,
    305         "The max flow value or the min cut value was not doubled");
    306 
     306        "The max flow value or the min cut value was not doubled.");
    307307
    308308  max_flow.flowMap(flow);
     
    323323  CutMap min_cut3(g);
    324324  max_flow.minCutMap(min_cut3);
    325   min_cut_value=cutValue(g, min_cut3, cap);
     325  min_cut_value = cutValue(g, min_cut3, cap);
    326326
    327327  check(max_flow.flowValue() == min_cut_value,
     
    380380  checkMaxFlowAlg<PType1, PreflowStartFunctions<PType1> >();
    381381  checkMaxFlowAlg<PType2, PreflowStartFunctions<PType2> >();
    382   initFlowTest();
     382
     383  checkInitPreflow();
    383384
    384385  // Check EdmondsKarp
     
    388389  checkMaxFlowAlg<EKType2, GeneralStartFunctions<EKType2> >();
    389390
    390   initFlowTest();
    391 
    392391  return 0;
    393392}
Note: See TracChangeset for help on using the changeset viewer.