[Lemon-commits] Peter Kovacs: Refactoring and code formatting in...
Lemon HG
hg at lemon.cs.elte.hu
Fri Mar 23 16:14:07 CET 2018
details: http://lemon.cs.elte.hu/hg/lemon/rev/e2732b9da429
changeset: 1382:e2732b9da429
user: Peter Kovacs <kpeter [at] inf.elte.hu>
date: Thu Mar 22 18:55:31 2018 +0100
description:
Refactoring and code formatting in max_flow_test.cc (#608)
diffstat:
test/max_flow_test.cc | 41 ++++++++++++++++++++---------------------
1 files changed, 20 insertions(+), 21 deletions(-)
diffs (94 lines):
diff --git a/test/max_flow_test.cc b/test/max_flow_test.cc
--- a/test/max_flow_test.cc
+++ b/test/max_flow_test.cc
@@ -182,13 +182,13 @@
template <typename T>
-T cutValue (const SmartDigraph& g,
- const SmartDigraph::NodeMap<bool>& cut,
- const SmartDigraph::ArcMap<T>& cap) {
+T cutValue(const SmartDigraph& g,
+ const SmartDigraph::NodeMap<bool>& cut,
+ const SmartDigraph::ArcMap<T>& cap) {
- T c=0;
- for(SmartDigraph::ArcIt e(g); e!=INVALID; ++e) {
- if (cut[g.source(e)] && !cut[g.target(e)]) c+=cap[e];
+ T c = 0;
+ for (SmartDigraph::ArcIt e(g); e != INVALID; ++e) {
+ if (cut[g.source(e)] && !cut[g.target(e)]) c += cap[e];
}
return c;
}
@@ -217,23 +217,24 @@
return true;
}
-void initFlowTest()
+void checkInitPreflow()
{
DIGRAPH_TYPEDEFS(SmartDigraph);
SmartDigraph g;
- SmartDigraph::ArcMap<int> cap(g),iflow(g);
- Node s=g.addNode(); Node t=g.addNode();
- Node n1=g.addNode(); Node n2=g.addNode();
+ SmartDigraph::ArcMap<int> cap(g), iflow(g);
+ Node s = g.addNode(); Node t = g.addNode();
+ Node n1 = g.addNode(); Node n2 = g.addNode();
Arc a;
- a=g.addArc(s,n1); cap[a]=20; iflow[a]=20;
- a=g.addArc(n1,n2); cap[a]=10; iflow[a]=0;
- a=g.addArc(n2,t); cap[a]=20; iflow[a]=0;
+ a = g.addArc(s, n1); cap[a] = 20; iflow[a] = 20;
+ a = g.addArc(n1, n2); cap[a] = 10; iflow[a] = 0;
+ a = g.addArc(n2, t); cap[a] = 20; iflow[a] = 0;
- Preflow<SmartDigraph> pre(g,cap,s,t);
+ Preflow<SmartDigraph> pre(g, cap, s, t);
pre.init(iflow);
pre.startFirstPhase();
- check(pre.flowValue() == 10, "The incorrect max flow value.");
+
+ check(pre.flowValue() == 10, "Incorrect max flow value.");
check(pre.minCut(s), "Wrong min cut (Node s).");
check(pre.minCut(n1), "Wrong min cut (Node n1).");
check(!pre.minCut(n2), "Wrong min cut (Node n2).");
@@ -302,8 +303,7 @@
check(max_flow.flowValue() == min_cut_value &&
min_cut_value == 2 * flow_value,
- "The max flow value or the min cut value was not doubled");
-
+ "The max flow value or the min cut value was not doubled.");
max_flow.flowMap(flow);
@@ -322,7 +322,7 @@
CutMap min_cut3(g);
max_flow.minCutMap(min_cut3);
- min_cut_value=cutValue(g, min_cut3, cap);
+ min_cut_value = cutValue(g, min_cut3, cap);
check(max_flow.flowValue() == min_cut_value,
"The max flow value or the min cut value is wrong.");
@@ -379,7 +379,8 @@
typedef Preflow<SmartDigraph, SmartDigraph::ArcMap<float> > PType2;
checkMaxFlowAlg<PType1, PreflowStartFunctions<PType1> >();
checkMaxFlowAlg<PType2, PreflowStartFunctions<PType2> >();
- initFlowTest();
+
+ checkInitPreflow();
// Check EdmondsKarp
typedef EdmondsKarp<SmartDigraph, SmartDigraph::ArcMap<int> > EKType1;
@@ -387,7 +388,5 @@
checkMaxFlowAlg<EKType1, GeneralStartFunctions<EKType1> >();
checkMaxFlowAlg<EKType2, GeneralStartFunctions<EKType2> >();
- initFlowTest();
-
return 0;
}
More information about the Lemon-commits
mailing list