# HG changeset patch
# User Péter Kovács <kpeter@inf.elte.hu>
# Date 1518871375 -3600
# Sat Feb 17 13:42:55 2018 +0100
# Node ID 538d666d8cb5afc58b6f2ccd51892d87abd01e18
# Parent dceba191c00dbe9bb4867fab619aac7a9c232ae9
Remove unused typedefs in max_flow_test.cc (#608)
diff --git a/test/max_flow_test.cc b/test/max_flow_test.cc
a
|
b
|
|
165 | 165 | typedef int Value; |
166 | 166 | typedef concepts::Digraph Digraph; |
167 | 167 | typedef concepts::ReadMap<Digraph::Arc, Value> CapMap; |
168 | | typedef Elevator<Digraph, Digraph::Node> Elev; |
169 | | typedef LinkedElevator<Digraph, Digraph::Node> LinkedElev; |
170 | 168 | |
171 | 169 | Digraph g; |
172 | 170 | Digraph::Node n; |
# HG changeset patch
# User Péter Kovács <kpeter@inf.elte.hu>
# Date 1518871414 -3600
# Sat Feb 17 13:43:34 2018 +0100
# Node ID 80bcc488ae41bccd9974d4e42a5b83c178b50a05
# Parent 538d666d8cb5afc58b6f2ccd51892d87abd01e18
Refactoring and code formatting in max_flow_test.cc (#608)
diff --git a/test/max_flow_test.cc b/test/max_flow_test.cc
a
|
b
|
|
182 | 182 | |
183 | 183 | |
184 | 184 | template <typename T> |
185 | | T cutValue (const SmartDigraph& g, |
186 | | const SmartDigraph::NodeMap<bool>& cut, |
187 | | const SmartDigraph::ArcMap<T>& cap) { |
| 185 | T cutValue(const SmartDigraph& g, |
| 186 | const SmartDigraph::NodeMap<bool>& cut, |
| 187 | const SmartDigraph::ArcMap<T>& cap) { |
188 | 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]; |
| 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]; |
192 | 192 | } |
193 | 193 | return c; |
194 | 194 | } |
… |
… |
|
217 | 217 | return true; |
218 | 218 | } |
219 | 219 | |
220 | | void initFlowTest() |
| 220 | void checkInitPreflow() |
221 | 221 | { |
222 | 222 | DIGRAPH_TYPEDEFS(SmartDigraph); |
223 | 223 | |
224 | 224 | 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(); |
228 | 228 | 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; |
| 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 | 232 | |
233 | | Preflow<SmartDigraph> pre(g,cap,s,t); |
| 233 | Preflow<SmartDigraph> pre(g, cap, s, t); |
234 | 234 | pre.init(iflow); |
235 | 235 | pre.startFirstPhase(); |
236 | | check(pre.flowValue() == 10, "The incorrect max flow value."); |
| 236 | |
| 237 | check(pre.flowValue() == 10, "Incorrect max flow value."); |
237 | 238 | check(pre.minCut(s), "Wrong min cut (Node s)."); |
238 | 239 | check(pre.minCut(n1), "Wrong min cut (Node n1)."); |
239 | 240 | check(!pre.minCut(n2), "Wrong min cut (Node n2)."); |
… |
… |
|
302 | 303 | |
303 | 304 | check(max_flow.flowValue() == min_cut_value && |
304 | 305 | 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."); |
307 | 307 | |
308 | 308 | max_flow.flowMap(flow); |
309 | 309 | |
… |
… |
|
322 | 322 | |
323 | 323 | CutMap min_cut3(g); |
324 | 324 | max_flow.minCutMap(min_cut3); |
325 | | min_cut_value=cutValue(g, min_cut3, cap); |
| 325 | min_cut_value = cutValue(g, min_cut3, cap); |
326 | 326 | |
327 | 327 | check(max_flow.flowValue() == min_cut_value, |
328 | 328 | "The max flow value or the min cut value is wrong."); |
… |
… |
|
379 | 379 | typedef Preflow<SmartDigraph, SmartDigraph::ArcMap<float> > PType2; |
380 | 380 | checkMaxFlowAlg<PType1, PreflowStartFunctions<PType1> >(); |
381 | 381 | checkMaxFlowAlg<PType2, PreflowStartFunctions<PType2> >(); |
382 | | initFlowTest(); |
| 382 | |
| 383 | checkInitPreflow(); |
383 | 384 | |
384 | 385 | // Check EdmondsKarp |
385 | 386 | typedef EdmondsKarp<SmartDigraph, SmartDigraph::ArcMap<int> > EKType1; |
… |
… |
|
387 | 388 | checkMaxFlowAlg<EKType1, GeneralStartFunctions<EKType1> >(); |
388 | 389 | checkMaxFlowAlg<EKType2, GeneralStartFunctions<EKType2> >(); |
389 | 390 | |
390 | | initFlowTest(); |
391 | | |
392 | 391 | return 0; |
393 | 392 | } |
# HG changeset patch
# User Péter Kovács <kpeter@inf.elte.hu>
# Date 1518871464 -3600
# Sat Feb 17 13:44:24 2018 +0100
# Node ID 6a0968a5c6134c8560ba8e6152b70a795606a743
# Parent 80bcc488ae41bccd9974d4e42a5b83c178b50a05
Use tolerance in max_flow_test.cc (#608)
diff --git a/test/max_flow_test.cc b/test/max_flow_test.cc
a
|
b
|
|
26 | 26 | #include <lemon/concepts/maps.h> |
27 | 27 | #include <lemon/lgf_reader.h> |
28 | 28 | #include <lemon/elevator.h> |
| 29 | #include <lemon/tolerance.h> |
29 | 30 | |
30 | 31 | using namespace lemon; |
31 | 32 | |
… |
… |
|
65 | 66 | "source 1\n" |
66 | 67 | "target 8\n"; |
67 | 68 | |
68 | | |
69 | 69 | // Checks the general interface of a max flow algorithm |
70 | 70 | template <typename GR, typename CAP> |
71 | 71 | struct MaxFlowClassConcept |
… |
… |
|
197 | 197 | bool checkFlow(const SmartDigraph& g, |
198 | 198 | const SmartDigraph::ArcMap<T>& flow, |
199 | 199 | const SmartDigraph::ArcMap<T>& cap, |
200 | | SmartDigraph::Node s, SmartDigraph::Node t) { |
| 200 | SmartDigraph::Node s, SmartDigraph::Node t, |
| 201 | const Tolerance<T>& tol) { |
201 | 202 | |
202 | 203 | for (SmartDigraph::ArcIt e(g); e != INVALID; ++e) { |
203 | | if (flow[e] < 0 || flow[e] > cap[e]) return false; |
| 204 | if (tol.negative(flow[e]) || tol.less(cap[e], flow[e])) return false; |
204 | 205 | } |
205 | 206 | |
206 | 207 | for (SmartDigraph::NodeIt n(g); n != INVALID; ++n) { |
… |
… |
|
212 | 213 | for (SmartDigraph::InArcIt e(g, n); e != INVALID; ++e) { |
213 | 214 | sum -= flow[e]; |
214 | 215 | } |
215 | | if (sum != 0) return false; |
| 216 | if (tol.nonZero(sum)) return false; |
216 | 217 | } |
217 | 218 | return true; |
218 | 219 | } |
… |
… |
|
251 | 252 | typedef CapMap FlowMap; |
252 | 253 | typedef BoolNodeMap CutMap; |
253 | 254 | |
| 255 | Tolerance<Value> tol; |
| 256 | |
254 | 257 | Digraph g; |
255 | 258 | Node s, t; |
256 | 259 | CapMap cap(g); |
… |
… |
|
264 | 267 | MF max_flow(g, cap, s, t); |
265 | 268 | max_flow.run(); |
266 | 269 | |
267 | | check(checkFlow(g, max_flow.flowMap(), cap, s, t), |
| 270 | check(checkFlow(g, max_flow.flowMap(), cap, s, t, tol), |
268 | 271 | "The flow is not feasible."); |
269 | 272 | |
270 | 273 | CutMap min_cut(g); |
271 | 274 | max_flow.minCutMap(min_cut); |
272 | 275 | Value min_cut_value = cutValue(g, min_cut, cap); |
273 | 276 | |
274 | | check(max_flow.flowValue() == min_cut_value, |
| 277 | check(!tol.different(max_flow.flowValue(), min_cut_value), |
275 | 278 | "The max flow value is not equal to the min cut value."); |
276 | 279 | |
277 | 280 | FlowMap flow(g); |
… |
… |
|
288 | 291 | max_flow.minCutMap(min_cut1); |
289 | 292 | min_cut_value = cutValue(g, min_cut1, cap); |
290 | 293 | |
291 | | check(max_flow.flowValue() == min_cut_value && |
292 | | min_cut_value == 2 * flow_value, |
| 294 | check(!tol.different(max_flow.flowValue(), min_cut_value) && |
| 295 | !tol.different(min_cut_value, 2 * flow_value), |
293 | 296 | "The max flow value or the min cut value is wrong."); |
294 | 297 | |
295 | 298 | SF::startSecondPhase(max_flow); // start second phase of the algorithm |
296 | 299 | |
297 | | check(checkFlow(g, max_flow.flowMap(), cap, s, t), |
| 300 | check(checkFlow(g, max_flow.flowMap(), cap, s, t, tol), |
298 | 301 | "The flow is not feasible."); |
299 | 302 | |
300 | 303 | CutMap min_cut2(g); |
301 | 304 | max_flow.minCutMap(min_cut2); |
302 | 305 | min_cut_value = cutValue(g, min_cut2, cap); |
303 | 306 | |
304 | | check(max_flow.flowValue() == min_cut_value && |
305 | | min_cut_value == 2 * flow_value, |
| 307 | check(!tol.different(max_flow.flowValue(), min_cut_value) && |
| 308 | !tol.different(min_cut_value, 2 * flow_value), |
306 | 309 | "The max flow value or the min cut value was not doubled."); |
307 | 310 | |
308 | 311 | max_flow.flowMap(flow); |
… |
… |
|
324 | 327 | max_flow.minCutMap(min_cut3); |
325 | 328 | min_cut_value = cutValue(g, min_cut3, cap); |
326 | 329 | |
327 | | check(max_flow.flowValue() == min_cut_value, |
| 330 | check(!tol.different(max_flow.flowValue(), min_cut_value), |
328 | 331 | "The max flow value or the min cut value is wrong."); |
329 | 332 | } |
330 | 333 | |
# HG changeset patch
# User Péter Kovács <kpeter@inf.elte.hu>
# Date 1518871525 -3600
# Sat Feb 17 13:45:25 2018 +0100
# Node ID 6d513768023dd6ad8a4bd5adcc346a88267c473d
# Parent 6a0968a5c6134c8560ba8e6152b70a795606a743
Improve max flow test method: set expected flow value (#608)
diff --git a/test/max_flow_test.cc b/test/max_flow_test.cc
a
|
b
|
|
243 | 243 | } |
244 | 244 | |
245 | 245 | template <typename MF, typename SF> |
246 | | void checkMaxFlowAlg() { |
| 246 | void checkMaxFlowAlg(const char *input_lgf, typename MF::Value expected) { |
247 | 247 | typedef SmartDigraph Digraph; |
248 | 248 | DIGRAPH_TYPEDEFS(Digraph); |
249 | 249 | |
… |
… |
|
257 | 257 | Digraph g; |
258 | 258 | Node s, t; |
259 | 259 | CapMap cap(g); |
260 | | std::istringstream input(test_lgf); |
| 260 | std::istringstream input(input_lgf); |
261 | 261 | DigraphReader<Digraph>(g,input) |
262 | 262 | .arcMap("capacity", cap) |
263 | 263 | .node("source",s) |
… |
… |
|
267 | 267 | MF max_flow(g, cap, s, t); |
268 | 268 | max_flow.run(); |
269 | 269 | |
| 270 | check(!tol.different(expected, max_flow.flowValue()), |
| 271 | "Incorrect max flow value."); |
270 | 272 | check(checkFlow(g, max_flow.flowMap(), cap, s, t, tol), |
271 | 273 | "The flow is not feasible."); |
272 | 274 | |
… |
… |
|
274 | 276 | max_flow.minCutMap(min_cut); |
275 | 277 | Value min_cut_value = cutValue(g, min_cut, cap); |
276 | 278 | |
277 | | check(!tol.different(max_flow.flowValue(), min_cut_value), |
278 | | "The max flow value is not equal to the min cut value."); |
| 279 | check(!tol.different(expected, min_cut_value), |
| 280 | "Incorrect min cut value."); |
279 | 281 | |
280 | 282 | FlowMap flow(g); |
281 | 283 | for (ArcIt e(g); e != INVALID; ++e) flow[e] = max_flow.flowMap()[e]; |
282 | | |
283 | | Value flow_value = max_flow.flowValue(); |
284 | | |
285 | 284 | for (ArcIt e(g); e != INVALID; ++e) cap[e] = 2 * cap[e]; |
286 | 285 | max_flow.init(flow); |
287 | 286 | |
… |
… |
|
291 | 290 | max_flow.minCutMap(min_cut1); |
292 | 291 | min_cut_value = cutValue(g, min_cut1, cap); |
293 | 292 | |
294 | | check(!tol.different(max_flow.flowValue(), min_cut_value) && |
295 | | !tol.different(min_cut_value, 2 * flow_value), |
296 | | "The max flow value or the min cut value is wrong."); |
| 293 | check(!tol.different(2 * expected, max_flow.flowValue()), |
| 294 | "Incorrect max flow value."); |
| 295 | check(!tol.different(2 * expected, min_cut_value), |
| 296 | "Incorrect min cut value."); |
297 | 297 | |
298 | 298 | SF::startSecondPhase(max_flow); // start second phase of the algorithm |
299 | 299 | |
… |
… |
|
304 | 304 | max_flow.minCutMap(min_cut2); |
305 | 305 | min_cut_value = cutValue(g, min_cut2, cap); |
306 | 306 | |
307 | | check(!tol.different(max_flow.flowValue(), min_cut_value) && |
308 | | !tol.different(min_cut_value, 2 * flow_value), |
309 | | "The max flow value or the min cut value was not doubled."); |
| 307 | check(!tol.different(2 * expected, max_flow.flowValue()), |
| 308 | "Incorrect max flow value."); |
| 309 | check(!tol.different(2 * expected, min_cut_value), |
| 310 | "Incorrect min cut value."); |
310 | 311 | |
311 | 312 | max_flow.flowMap(flow); |
312 | 313 | |
… |
… |
|
380 | 381 | // Check Preflow |
381 | 382 | typedef Preflow<SmartDigraph, SmartDigraph::ArcMap<int> > PType1; |
382 | 383 | typedef Preflow<SmartDigraph, SmartDigraph::ArcMap<float> > PType2; |
383 | | checkMaxFlowAlg<PType1, PreflowStartFunctions<PType1> >(); |
384 | | checkMaxFlowAlg<PType2, PreflowStartFunctions<PType2> >(); |
| 384 | typedef Preflow<SmartDigraph, SmartDigraph::ArcMap<double> > PType3; |
| 385 | checkMaxFlowAlg<PType1, PreflowStartFunctions<PType1> >(test_lgf, 13); |
| 386 | checkMaxFlowAlg<PType2, PreflowStartFunctions<PType2> >(test_lgf, 13); |
| 387 | checkMaxFlowAlg<PType3, PreflowStartFunctions<PType3> >(test_lgf, 13); |
385 | 388 | |
386 | 389 | checkInitPreflow(); |
387 | 390 | |
388 | 391 | // Check EdmondsKarp |
389 | 392 | typedef EdmondsKarp<SmartDigraph, SmartDigraph::ArcMap<int> > EKType1; |
390 | 393 | typedef EdmondsKarp<SmartDigraph, SmartDigraph::ArcMap<float> > EKType2; |
391 | | checkMaxFlowAlg<EKType1, GeneralStartFunctions<EKType1> >(); |
392 | | checkMaxFlowAlg<EKType2, GeneralStartFunctions<EKType2> >(); |
| 394 | typedef EdmondsKarp<SmartDigraph, SmartDigraph::ArcMap<double> > EKType3; |
| 395 | checkMaxFlowAlg<EKType1, GeneralStartFunctions<EKType1> >(test_lgf, 13); |
| 396 | checkMaxFlowAlg<EKType2, GeneralStartFunctions<EKType2> >(test_lgf, 13); |
| 397 | checkMaxFlowAlg<EKType3, GeneralStartFunctions<EKType3> >(test_lgf, 13); |
393 | 398 | |
394 | 399 | return 0; |
395 | 400 | } |
# HG changeset patch
# User Péter Kovács <kpeter@inf.elte.hu>
# Date 1518871562 -3600
# Sat Feb 17 13:46:02 2018 +0100
# Node ID 55febc0faa6d9e48b491ec4b380a42a3b6205972
# Parent 6d513768023dd6ad8a4bd5adcc346a88267c473d
Fix tolerance usage in Preflow algorithm (#608)
diff --git a/lemon/preflow.h b/lemon/preflow.h
a
|
b
|
|
476 | 476 | /// Initializes the internal data structures and sets the initial |
477 | 477 | /// flow to the given \c flowMap. The \c flowMap should contain a |
478 | 478 | /// flow or at least a preflow, i.e. at each node excluding the |
479 | | /// source node the incoming flow should greater or equal to the |
| 479 | /// source node the incoming flow should be greater or equal to the |
480 | 480 | /// outgoing flow. |
481 | 481 | /// \return \c false if the given \c flowMap is not a preflow. |
482 | 482 | template <typename FlowMap> |
… |
… |
|
495 | 495 | for (OutArcIt e(_graph, n); e != INVALID; ++e) { |
496 | 496 | excess -= (*_flow)[e]; |
497 | 497 | } |
498 | | if (excess < 0 && n != _source) return false; |
| 498 | if (_tolerance.negative(excess) && n != _source) return false; |
499 | 499 | (*_excess)[n] = excess; |
500 | 500 | } |
501 | 501 | |
… |
… |
|
639 | 639 | |
640 | 640 | (*_excess)[n] = excess; |
641 | 641 | |
642 | | if (excess != 0) { |
| 642 | if (_tolerance.nonZero(excess)) { |
643 | 643 | if (new_level + 1 < _level->maxLevel()) { |
644 | 644 | _level->liftHighestActive(new_level + 1); |
645 | 645 | } else { |
… |
… |
|
720 | 720 | |
721 | 721 | (*_excess)[n] = excess; |
722 | 722 | |
723 | | if (excess != 0) { |
| 723 | if (_tolerance.nonZero(excess)) { |
724 | 724 | if (new_level + 1 < _level->maxLevel()) { |
725 | 725 | _level->liftActiveOn(level, new_level + 1); |
726 | 726 | } else { |
… |
… |
|
791 | 791 | for (NodeIt n(_graph); n != INVALID; ++n) { |
792 | 792 | if (!reached[n]) { |
793 | 793 | _level->dirtyTopButOne(n); |
794 | | } else if ((*_excess)[n] > 0 && _target != n) { |
| 794 | } else if (_tolerance.positive((*_excess)[n]) && _target != n) { |
795 | 795 | _level->activate(n); |
796 | 796 | } |
797 | 797 | } |
… |
… |
|
852 | 852 | |
853 | 853 | (*_excess)[n] = excess; |
854 | 854 | |
855 | | if (excess != 0) { |
| 855 | if (_tolerance.nonZero(excess)) { |
856 | 856 | if (new_level + 1 < _level->maxLevel()) { |
857 | 857 | _level->liftHighestActive(new_level + 1); |
858 | 858 | } else { |
diff --git a/test/max_flow_test.cc b/test/max_flow_test.cc
a
|
b
|
|
66 | 66 | "source 1\n" |
67 | 67 | "target 8\n"; |
68 | 68 | |
| 69 | char test_lgf_float[] = |
| 70 | "@nodes\n" |
| 71 | "label\n" |
| 72 | "0\n" |
| 73 | "1\n" |
| 74 | "2\n" |
| 75 | "3\n" |
| 76 | "4\n" |
| 77 | "5\n" |
| 78 | "6\n" |
| 79 | "7\n" |
| 80 | "8\n" |
| 81 | "9\n" |
| 82 | "@arcs\n" |
| 83 | " capacity\n" |
| 84 | "0 1 0.1\n" |
| 85 | "0 2 0.1\n" |
| 86 | "0 3 0.1\n" |
| 87 | "1 4 0.1\n" |
| 88 | "2 4 0.1\n" |
| 89 | "3 4 0.1\n" |
| 90 | "4 5 0.3\n" |
| 91 | "5 6 0.1\n" |
| 92 | "5 7 0.1\n" |
| 93 | "5 8 0.1\n" |
| 94 | "6 9 0.1\n" |
| 95 | "7 9 0.1\n" |
| 96 | "8 9 0.1\n" |
| 97 | "@attributes\n" |
| 98 | "source 0\n" |
| 99 | "target 9\n"; |
| 100 | |
69 | 101 | // Checks the general interface of a max flow algorithm |
70 | 102 | template <typename GR, typename CAP> |
71 | 103 | struct MaxFlowClassConcept |
… |
… |
|
258 | 290 | Node s, t; |
259 | 291 | CapMap cap(g); |
260 | 292 | std::istringstream input(input_lgf); |
261 | | DigraphReader<Digraph>(g,input) |
| 293 | DigraphReader<Digraph>(g, input) |
262 | 294 | .arcMap("capacity", cap) |
263 | | .node("source",s) |
264 | | .node("target",t) |
| 295 | .node("source", s) |
| 296 | .node("target", t) |
265 | 297 | .run(); |
266 | 298 | |
267 | 299 | MF max_flow(g, cap, s, t); |
… |
… |
|
280 | 312 | "Incorrect min cut value."); |
281 | 313 | |
282 | 314 | FlowMap flow(g); |
283 | | for (ArcIt e(g); e != INVALID; ++e) flow[e] = max_flow.flowMap()[e]; |
284 | | for (ArcIt e(g); e != INVALID; ++e) cap[e] = 2 * cap[e]; |
| 315 | for (ArcIt e(g); e != INVALID; ++e) flow[e] = 13 * max_flow.flowMap()[e]; |
| 316 | for (ArcIt e(g); e != INVALID; ++e) cap[e] = 17 * cap[e]; |
285 | 317 | max_flow.init(flow); |
286 | 318 | |
287 | 319 | SF::startFirstPhase(max_flow); // start first phase of the algorithm |
… |
… |
|
290 | 322 | max_flow.minCutMap(min_cut1); |
291 | 323 | min_cut_value = cutValue(g, min_cut1, cap); |
292 | 324 | |
293 | | check(!tol.different(2 * expected, max_flow.flowValue()), |
| 325 | check(!tol.different(17 * expected, max_flow.flowValue()), |
294 | 326 | "Incorrect max flow value."); |
295 | | check(!tol.different(2 * expected, min_cut_value), |
| 327 | check(!tol.different(17 * expected, min_cut_value), |
296 | 328 | "Incorrect min cut value."); |
297 | 329 | |
298 | 330 | SF::startSecondPhase(max_flow); // start second phase of the algorithm |
… |
… |
|
304 | 336 | max_flow.minCutMap(min_cut2); |
305 | 337 | min_cut_value = cutValue(g, min_cut2, cap); |
306 | 338 | |
307 | | check(!tol.different(2 * expected, max_flow.flowValue()), |
| 339 | check(!tol.different(17 * expected, max_flow.flowValue()), |
308 | 340 | "Incorrect max flow value."); |
309 | | check(!tol.different(2 * expected, min_cut_value), |
| 341 | check(!tol.different(17 * expected, min_cut_value), |
310 | 342 | "Incorrect min cut value."); |
311 | 343 | |
312 | 344 | max_flow.flowMap(flow); |
… |
… |
|
382 | 414 | typedef Preflow<SmartDigraph, SmartDigraph::ArcMap<int> > PType1; |
383 | 415 | typedef Preflow<SmartDigraph, SmartDigraph::ArcMap<float> > PType2; |
384 | 416 | typedef Preflow<SmartDigraph, SmartDigraph::ArcMap<double> > PType3; |
| 417 | |
385 | 418 | checkMaxFlowAlg<PType1, PreflowStartFunctions<PType1> >(test_lgf, 13); |
386 | 419 | checkMaxFlowAlg<PType2, PreflowStartFunctions<PType2> >(test_lgf, 13); |
387 | 420 | checkMaxFlowAlg<PType3, PreflowStartFunctions<PType3> >(test_lgf, 13); |
388 | 421 | |
| 422 | checkMaxFlowAlg<PType2, PreflowStartFunctions<PType2> >(test_lgf_float, 0.3); |
| 423 | checkMaxFlowAlg<PType3, PreflowStartFunctions<PType3> >(test_lgf_float, 0.3); |
| 424 | |
389 | 425 | checkInitPreflow(); |
390 | 426 | |
391 | 427 | // Check EdmondsKarp |
392 | 428 | typedef EdmondsKarp<SmartDigraph, SmartDigraph::ArcMap<int> > EKType1; |
393 | 429 | typedef EdmondsKarp<SmartDigraph, SmartDigraph::ArcMap<float> > EKType2; |
394 | 430 | typedef EdmondsKarp<SmartDigraph, SmartDigraph::ArcMap<double> > EKType3; |
| 431 | |
395 | 432 | checkMaxFlowAlg<EKType1, GeneralStartFunctions<EKType1> >(test_lgf, 13); |
396 | 433 | checkMaxFlowAlg<EKType2, GeneralStartFunctions<EKType2> >(test_lgf, 13); |
397 | 434 | checkMaxFlowAlg<EKType3, GeneralStartFunctions<EKType3> >(test_lgf, 13); |
398 | 435 | |
| 436 | checkMaxFlowAlg<EKType2, GeneralStartFunctions<EKType2> >(test_lgf_float, 0.3); |
| 437 | checkMaxFlowAlg<EKType3, GeneralStartFunctions<EKType3> >(test_lgf_float, 0.3); |
| 438 | |
399 | 439 | return 0; |
400 | 440 | } |