Changeset 1168:259e3a90ad97 in lemon-main
- Timestamp:
- 03/22/18 18:56:26 (7 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/max_flow_test.cc
r1167 r1168 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); … … 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) … … 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."); … … 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 themin 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); … … 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 … … 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); … … 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(); … … 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;
Note: See TracChangeset
for help on using the changeset viewer.