demo/lp_maxflow_demo.cc
changeset 1575 438bc5defad1
parent 1561 be178ff88711
child 1577 15098fb5275c
equal deleted inserted replaced
3:7a23b858829d 4:58d0d0fe966a
    80     for(OutEdgeIt e(g,n);e!=INVALID;++e) ex-=x[e];
    80     for(OutEdgeIt e(g,n);e!=INVALID;++e) ex-=x[e];
    81     lp.addRow(ex==0);
    81     lp.addRow(ex==0);
    82   }
    82   }
    83   
    83   
    84   //Objective function: the flow value entering 't'
    84   //Objective function: the flow value entering 't'
    85   {
    85   LpDefault::Expr obj;
    86     LpDefault::Expr ex;
    86   for(InEdgeIt  e(g,t);e!=INVALID;++e) obj+=x[e];
    87     for(InEdgeIt  e(g,t);e!=INVALID;++e) ex+=x[e];
    87   for(OutEdgeIt e(g,t);e!=INVALID;++e) obj-=x[e];
    88     for(OutEdgeIt e(g,t);e!=INVALID;++e) ex-=x[e];
    88   lp.setObj(obj);
    89     lp.setObj(ex);
    89 
    90   }
       
    91 
    90 
    92   //Maximization
    91   //Maximization
    93   lp.max();
    92   lp.max();
    94 
    93 
    95 #ifdef HAVE_GLPK
    94 #ifdef HAVE_GLPK