1.1 --- a/test/max_flow_test.cc Thu Mar 22 18:55:01 2018 +0100
1.2 +++ b/test/max_flow_test.cc Thu Mar 22 18:55:31 2018 +0100
1.3 @@ -182,13 +182,13 @@
1.4
1.5
1.6 template <typename T>
1.7 -T cutValue (const SmartDigraph& g,
1.8 - const SmartDigraph::NodeMap<bool>& cut,
1.9 - const SmartDigraph::ArcMap<T>& cap) {
1.10 +T cutValue(const SmartDigraph& g,
1.11 + const SmartDigraph::NodeMap<bool>& cut,
1.12 + const SmartDigraph::ArcMap<T>& cap) {
1.13
1.14 - T c=0;
1.15 - for(SmartDigraph::ArcIt e(g); e!=INVALID; ++e) {
1.16 - if (cut[g.source(e)] && !cut[g.target(e)]) c+=cap[e];
1.17 + T c = 0;
1.18 + for (SmartDigraph::ArcIt e(g); e != INVALID; ++e) {
1.19 + if (cut[g.source(e)] && !cut[g.target(e)]) c += cap[e];
1.20 }
1.21 return c;
1.22 }
1.23 @@ -217,23 +217,24 @@
1.24 return true;
1.25 }
1.26
1.27 -void initFlowTest()
1.28 +void checkInitPreflow()
1.29 {
1.30 DIGRAPH_TYPEDEFS(SmartDigraph);
1.31
1.32 SmartDigraph g;
1.33 - SmartDigraph::ArcMap<int> cap(g),iflow(g);
1.34 - Node s=g.addNode(); Node t=g.addNode();
1.35 - Node n1=g.addNode(); Node n2=g.addNode();
1.36 + SmartDigraph::ArcMap<int> cap(g), iflow(g);
1.37 + Node s = g.addNode(); Node t = g.addNode();
1.38 + Node n1 = g.addNode(); Node n2 = g.addNode();
1.39 Arc a;
1.40 - a=g.addArc(s,n1); cap[a]=20; iflow[a]=20;
1.41 - a=g.addArc(n1,n2); cap[a]=10; iflow[a]=0;
1.42 - a=g.addArc(n2,t); cap[a]=20; iflow[a]=0;
1.43 + a = g.addArc(s, n1); cap[a] = 20; iflow[a] = 20;
1.44 + a = g.addArc(n1, n2); cap[a] = 10; iflow[a] = 0;
1.45 + a = g.addArc(n2, t); cap[a] = 20; iflow[a] = 0;
1.46
1.47 - Preflow<SmartDigraph> pre(g,cap,s,t);
1.48 + Preflow<SmartDigraph> pre(g, cap, s, t);
1.49 pre.init(iflow);
1.50 pre.startFirstPhase();
1.51 - check(pre.flowValue() == 10, "The incorrect max flow value.");
1.52 +
1.53 + check(pre.flowValue() == 10, "Incorrect max flow value.");
1.54 check(pre.minCut(s), "Wrong min cut (Node s).");
1.55 check(pre.minCut(n1), "Wrong min cut (Node n1).");
1.56 check(!pre.minCut(n2), "Wrong min cut (Node n2).");
1.57 @@ -302,8 +303,7 @@
1.58
1.59 check(max_flow.flowValue() == min_cut_value &&
1.60 min_cut_value == 2 * flow_value,
1.61 - "The max flow value or the min cut value was not doubled");
1.62 -
1.63 + "The max flow value or the min cut value was not doubled.");
1.64
1.65 max_flow.flowMap(flow);
1.66
1.67 @@ -322,7 +322,7 @@
1.68
1.69 CutMap min_cut3(g);
1.70 max_flow.minCutMap(min_cut3);
1.71 - min_cut_value=cutValue(g, min_cut3, cap);
1.72 + min_cut_value = cutValue(g, min_cut3, cap);
1.73
1.74 check(max_flow.flowValue() == min_cut_value,
1.75 "The max flow value or the min cut value is wrong.");
1.76 @@ -379,7 +379,8 @@
1.77 typedef Preflow<SmartDigraph, SmartDigraph::ArcMap<float> > PType2;
1.78 checkMaxFlowAlg<PType1, PreflowStartFunctions<PType1> >();
1.79 checkMaxFlowAlg<PType2, PreflowStartFunctions<PType2> >();
1.80 - initFlowTest();
1.81 +
1.82 + checkInitPreflow();
1.83
1.84 // Check EdmondsKarp
1.85 typedef EdmondsKarp<SmartDigraph, SmartDigraph::ArcMap<int> > EKType1;
1.86 @@ -387,7 +388,5 @@
1.87 checkMaxFlowAlg<EKType1, GeneralStartFunctions<EKType1> >();
1.88 checkMaxFlowAlg<EKType2, GeneralStartFunctions<EKType2> >();
1.89
1.90 - initFlowTest();
1.91 -
1.92 return 0;
1.93 }