Changeset 1167:e018899c2926 in lemon-main
- Timestamp:
- 03/22/18 18:55:59 (7 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/max_flow_test.cc
r1166 r1167 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; … … 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> … … 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 … … 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; … … 251 252 typedef CapMap FlowMap; 252 253 typedef BoolNodeMap CutMap; 254 255 Tolerance<Value> tol; 253 256 254 257 Digraph g; … … 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 … … 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 … … 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 … … 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 … … 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 }
Note: See TracChangeset
for help on using the changeset viewer.