Changes in lemon/circulation.h [657:dacc2cee2b4c:658:85cb3aa71cce] in lemon
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/circulation.h
r657 r658 231 231 ///@{ 232 232 233 template <typename _FlowMap>233 template <typename T> 234 234 struct SetFlowMapTraits : public Traits { 235 typedef _FlowMapFlowMap;235 typedef T FlowMap; 236 236 static FlowMap *createFlowMap(const Digraph&) { 237 237 LEMON_ASSERT(false, "FlowMap is not initialized"); … … 245 245 /// \ref named-templ-param "Named parameter" for setting FlowMap 246 246 /// type. 247 template <typename _FlowMap>247 template <typename T> 248 248 struct SetFlowMap 249 249 : public Circulation<Digraph, LowerMap, UpperMap, SupplyMap, 250 SetFlowMapTraits< _FlowMap> > {250 SetFlowMapTraits<T> > { 251 251 typedef Circulation<Digraph, LowerMap, UpperMap, SupplyMap, 252 SetFlowMapTraits< _FlowMap> > Create;252 SetFlowMapTraits<T> > Create; 253 253 }; 254 254 255 template <typename _Elevator>255 template <typename T> 256 256 struct SetElevatorTraits : public Traits { 257 typedef _ElevatorElevator;257 typedef T Elevator; 258 258 static Elevator *createElevator(const Digraph&, int) { 259 259 LEMON_ASSERT(false, "Elevator is not initialized"); … … 271 271 /// \ref run() or \ref init(). 272 272 /// \sa SetStandardElevator 273 template <typename _Elevator>273 template <typename T> 274 274 struct SetElevator 275 275 : public Circulation<Digraph, LowerMap, UpperMap, SupplyMap, 276 SetElevatorTraits< _Elevator> > {276 SetElevatorTraits<T> > { 277 277 typedef Circulation<Digraph, LowerMap, UpperMap, SupplyMap, 278 SetElevatorTraits< _Elevator> > Create;278 SetElevatorTraits<T> > Create; 279 279 }; 280 280 281 template <typename _Elevator>281 template <typename T> 282 282 struct SetStandardElevatorTraits : public Traits { 283 typedef _ElevatorElevator;283 typedef T Elevator; 284 284 static Elevator *createElevator(const Digraph& digraph, int max_level) { 285 285 return new Elevator(digraph, max_level); … … 299 299 /// before calling \ref run() or \ref init(). 300 300 /// \sa SetElevator 301 template <typename _Elevator>301 template <typename T> 302 302 struct SetStandardElevator 303 303 : public Circulation<Digraph, LowerMap, UpperMap, SupplyMap, 304 SetStandardElevatorTraits< _Elevator> > {304 SetStandardElevatorTraits<T> > { 305 305 typedef Circulation<Digraph, LowerMap, UpperMap, SupplyMap, 306 SetStandardElevatorTraits< _Elevator> > Create;306 SetStandardElevatorTraits<T> > Create; 307 307 }; 308 308 … … 471 471 472 472 for(NodeIt n(_g);n!=INVALID;++n) { 473 _excess->set(n, (*_supply)[n]);473 (*_excess)[n] = (*_supply)[n]; 474 474 } 475 475 476 476 for (ArcIt e(_g);e!=INVALID;++e) { 477 477 _flow->set(e, (*_lo)[e]); 478 _excess->set(_g.target(e), (*_excess)[_g.target(e)] + (*_flow)[e]);479 _excess->set(_g.source(e), (*_excess)[_g.source(e)] - (*_flow)[e]);478 (*_excess)[_g.target(e)] += (*_flow)[e]; 479 (*_excess)[_g.source(e)] -= (*_flow)[e]; 480 480 } 481 481 … … 500 500 501 501 for(NodeIt n(_g);n!=INVALID;++n) { 502 _excess->set(n, (*_supply)[n]);502 (*_excess)[n] = (*_supply)[n]; 503 503 } 504 504 … … 506 506 if (!_tol.positive((*_excess)[_g.target(e)] + (*_up)[e])) { 507 507 _flow->set(e, (*_up)[e]); 508 _excess->set(_g.target(e), (*_excess)[_g.target(e)] + (*_up)[e]);509 _excess->set(_g.source(e), (*_excess)[_g.source(e)] - (*_up)[e]);508 (*_excess)[_g.target(e)] += (*_up)[e]; 509 (*_excess)[_g.source(e)] -= (*_up)[e]; 510 510 } else if (_tol.positive((*_excess)[_g.target(e)] + (*_lo)[e])) { 511 511 _flow->set(e, (*_lo)[e]); 512 _excess->set(_g.target(e), (*_excess)[_g.target(e)] + (*_lo)[e]);513 _excess->set(_g.source(e), (*_excess)[_g.source(e)] - (*_lo)[e]);512 (*_excess)[_g.target(e)] += (*_lo)[e]; 513 (*_excess)[_g.source(e)] -= (*_lo)[e]; 514 514 } else { 515 515 Flow fc = -(*_excess)[_g.target(e)]; 516 516 _flow->set(e, fc); 517 _excess->set(_g.target(e), 0);518 _excess->set(_g.source(e), (*_excess)[_g.source(e)] - fc);517 (*_excess)[_g.target(e)] = 0; 518 (*_excess)[_g.source(e)] -= fc; 519 519 } 520 520 } … … 555 555 if(!_tol.less(fc, exc)) { 556 556 _flow->set(e, (*_flow)[e] + exc); 557 _excess->set(v, (*_excess)[v] + exc);557 (*_excess)[v] += exc; 558 558 if(!_level->active(v) && _tol.positive((*_excess)[v])) 559 559 _level->activate(v); 560 _excess->set(act,0);560 (*_excess)[act] = 0; 561 561 _level->deactivate(act); 562 562 goto next_l; … … 564 564 else { 565 565 _flow->set(e, (*_up)[e]); 566 _excess->set(v, (*_excess)[v] + fc);566 (*_excess)[v] += fc; 567 567 if(!_level->active(v) && _tol.positive((*_excess)[v])) 568 568 _level->activate(v); … … 579 579 if(!_tol.less(fc, exc)) { 580 580 _flow->set(e, (*_flow)[e] - exc); 581 _excess->set(v, (*_excess)[v] + exc);581 (*_excess)[v] += exc; 582 582 if(!_level->active(v) && _tol.positive((*_excess)[v])) 583 583 _level->activate(v); 584 _excess->set(act,0);584 (*_excess)[act] = 0; 585 585 _level->deactivate(act); 586 586 goto next_l; … … 588 588 else { 589 589 _flow->set(e, (*_lo)[e]); 590 _excess->set(v, (*_excess)[v] + fc);590 (*_excess)[v] += fc; 591 591 if(!_level->active(v) && _tol.positive((*_excess)[v])) 592 592 _level->activate(v); … … 597 597 } 598 598 599 _excess->set(act, exc);599 (*_excess)[act] = exc; 600 600 if(!_tol.positive(exc)) _level->deactivate(act); 601 601 else if(mlevel==_node_num) { … … 700 700 /// 701 701 /// \note This function calls \ref barrier() for each node, 702 /// so it runs in \f$O(n)\f$time.702 /// so it runs in O(n) time. 703 703 /// 704 704 /// \pre Either \ref run() or \ref init() must be called before
Note: See TracChangeset
for help on using the changeset viewer.