# HG changeset patch
# User Peter Kovacs <kpeter@inf.elte.hu>
# Date 1240589599 -7200
# Node ID 547e6b876ee16dec1a965c114282dc5be05e75ba
# Parent b95898314e095d3b9f994b1a1068518f25016745
Support infinite capacities in Circulation + fix in the doc (#270)
diff --git a/lemon/circulation.h b/lemon/circulation.h
a
|
b
|
|
119 | 119 | at the nodes. |
120 | 120 | |
121 | 121 | The exact formulation of this problem is the following. |
122 | | Let \f$G=(V,A)\f$ be a digraph, |
123 | | \f$lower, upper: A\rightarrow\mathbf{R}^+_0\f$ denote the lower and |
124 | | upper bounds on the arcs, for which \f$0 \leq lower(uv) \leq upper(uv)\f$ |
| 122 | Let \f$G=(V,A)\f$ be a digraph, \f$lower: A\rightarrow\mathbf{R}\f$ |
| 123 | \f$upper: A\rightarrow\mathbf{R}\cup\{\infty\}\f$ denote the lower and |
| 124 | upper bounds on the arcs, for which \f$lower(uv) \leq upper(uv)\f$ |
125 | 125 | holds for all \f$uv\in A\f$, and \f$sup: V\rightarrow\mathbf{R}\f$ |
126 | 126 | denotes the signed supply values of the nodes. |
127 | 127 | If \f$sup(u)>0\f$, then \f$u\f$ is a supply node with \f$sup(u)\f$ |
128 | 128 | supply, if \f$sup(u)<0\f$, then \f$u\f$ is a demand node with |
129 | 129 | \f$-sup(u)\f$ demand. |
130 | | A feasible circulation is an \f$f: A\rightarrow\mathbf{R}^+_0\f$ |
| 130 | A feasible circulation is an \f$f: A\rightarrow\mathbf{R}\f$ |
131 | 131 | solution of the following problem. |
132 | 132 | |
133 | 133 | \f[ \sum_{uv\in A} f(uv) - \sum_{vu\in A} f(vu) |
… |
… |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | for (ArcIt e(_g);e!=INVALID;++e) { |
506 | | if (!_tol.positive((*_excess)[_g.target(e)] + (*_up)[e])) { |
| 506 | if (!_tol.less(-(*_excess)[_g.target(e)], (*_up)[e])) { |
507 | 507 | _flow->set(e, (*_up)[e]); |
508 | 508 | (*_excess)[_g.target(e)] += (*_up)[e]; |
509 | 509 | (*_excess)[_g.source(e)] -= (*_up)[e]; |
510 | | } else if (_tol.positive((*_excess)[_g.target(e)] + (*_lo)[e])) { |
| 510 | } else if (_tol.less(-(*_excess)[_g.target(e)], (*_lo)[e])) { |
511 | 511 | _flow->set(e, (*_lo)[e]); |
512 | 512 | (*_excess)[_g.target(e)] += (*_lo)[e]; |
513 | 513 | (*_excess)[_g.source(e)] -= (*_lo)[e]; |
… |
… |
|
748 | 748 | bool checkBarrier() const |
749 | 749 | { |
750 | 750 | Flow delta=0; |
| 751 | Flow inf_cap = std::numeric_limits<Flow>::has_infinity ? |
| 752 | std::numeric_limits<Flow>::infinity() : |
| 753 | std::numeric_limits<Flow>::max(); |
751 | 754 | for(NodeIt n(_g);n!=INVALID;++n) |
752 | 755 | if(barrier(n)) |
753 | 756 | delta-=(*_supply)[n]; |
… |
… |
|
755 | 758 | { |
756 | 759 | Node s=_g.source(e); |
757 | 760 | Node t=_g.target(e); |
758 | | if(barrier(s)&&!barrier(t)) delta+=(*_up)[e]; |
| 761 | if(barrier(s)&&!barrier(t)) { |
| 762 | if (_tol.less(inf_cap - (*_up)[e], delta)) return false; |
| 763 | delta+=(*_up)[e]; |
| 764 | } |
759 | 765 | else if(barrier(t)&&!barrier(s)) delta-=(*_lo)[e]; |
760 | 766 | } |
761 | 767 | return _tol.negative(delta); |