Only added comments.
1.1 --- a/demo/lp_maxflow_demo.cc Mon Jun 27 15:22:34 2005 +0000
1.2 +++ b/demo/lp_maxflow_demo.cc Mon Jun 27 15:25:33 2005 +0000
1.3 @@ -34,26 +34,34 @@
1.4 typedef typename G::OutEdgeIt OutEdgeIt;
1.5 typedef typename G::InEdgeIt InEdgeIt;
1.6
1.7 + //Define a map on the edges for the variables of the LP problem
1.8 typename G::template EdgeMap<LpDefault::Col> x(g);
1.9 lp.addColSet(x);
1.10
1.11 + //Nonnegativity and capacity constraints
1.12 for(EdgeIt e(g);e!=INVALID;++e) {
1.13 lp.colUpperBound(x[e],cap[e]);
1.14 lp.colLowerBound(x[e],0);
1.15 }
1.16
1.17 +
1.18 + //Flow conservation constraints for the nodes (except for 's' and 't')
1.19 for(NodeIt n(g);n!=INVALID;++n) if(n!=s&&n!=t) {
1.20 LpDefault::Expr ex;
1.21 for(InEdgeIt e(g,n);e!=INVALID;++e) ex+=x[e];
1.22 for(OutEdgeIt e(g,n);e!=INVALID;++e) ex-=x[e];
1.23 lp.addRow(ex==0);
1.24 }
1.25 +
1.26 + //Objective function: the flow value entering 't'
1.27 {
1.28 LpDefault::Expr ex;
1.29 for(InEdgeIt e(g,t);e!=INVALID;++e) ex+=x[e];
1.30 for(OutEdgeIt e(g,t);e!=INVALID;++e) ex-=x[e];
1.31 lp.setObj(ex);
1.32 }
1.33 +
1.34 + //Maximization
1.35 lp.max();
1.36
1.37 #ifdef HAVE_GLPK
1.38 @@ -61,6 +69,7 @@
1.39 lp.messageLevel(3);
1.40 #endif
1.41
1.42 + //Solve with the underlying solver
1.43 lp.solve();
1.44
1.45 return lp.primalValue();