lemon/ssp_min_cost_flow.h
changeset 2517 d9cfac072869
parent 2408 467ca6d16556
child 2553 bfced05fa852
equal deleted inserted replaced
5:38475601f03f 6:5ea40310605a
   177     /// \param k The value of the flow we are looking for.
   177     /// \param k The value of the flow we are looking for.
   178     ///
   178     ///
   179     /// \todo May be it does make sense to be able to start with a
   179     /// \todo May be it does make sense to be able to start with a
   180     /// nonzero feasible primal-dual solution pair as well.
   180     /// nonzero feasible primal-dual solution pair as well.
   181     ///
   181     ///
   182     /// \todo If the actual flow value is bigger than k, then
   182     /// \todo If the current flow value is bigger than k, then
   183     /// everything is cleared and the algorithm starts from zero
   183     /// everything is cleared and the algorithm starts from zero
   184     /// flow. Is it a good approach?
   184     /// flow. Is it a good approach?
   185     int run(int k) {
   185     int run(int k) {
   186       if (flowValue()>k) reset();
   186       if (flowValue()>k) reset();
   187       while (flowValue()<k && augment()) { }
   187       while (flowValue()<k && augment()) { }
   193       total_length=0;
   193       total_length=0;
   194       for (typename Graph::EdgeIt e(g); e!=INVALID; ++e) flow.set(e, 0);
   194       for (typename Graph::EdgeIt e(g); e!=INVALID; ++e) flow.set(e, 0);
   195       for (typename Graph::NodeIt n(g); n!=INVALID; ++n) potential.set(n, 0);  
   195       for (typename Graph::NodeIt n(g); n!=INVALID; ++n) potential.set(n, 0);  
   196     }
   196     }
   197 
   197 
   198     /// \brief Returns the value of the actual flow. 
   198     /// \brief Returns the value of the current flow. 
   199     int flowValue() const {
   199     int flowValue() const {
   200       int i=0;
   200       int i=0;
   201       for (typename Graph::OutEdgeIt e(g, s); e!=INVALID; ++e) i+=flow[e];
   201       for (typename Graph::OutEdgeIt e(g, s); e!=INVALID; ++e) i+=flow[e];
   202       for (typename Graph::InEdgeIt e(g, s); e!=INVALID; ++e) i-=flow[e];
   202       for (typename Graph::InEdgeIt e(g, s); e!=INVALID; ++e) i-=flow[e];
   203       return i;
   203       return i;