lemon/preflow.h
branch1.1
changeset 811 bd24650d5cd2
parent 739 30d5f950aa5f
equal deleted inserted replaced
15:76e7a61787e6 16:0a1cc1237cfe
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     2  *
     2  *
     3  * This file is a part of LEMON, a generic C++ optimization library.
     3  * This file is a part of LEMON, a generic C++ optimization library.
     4  *
     4  *
     5  * Copyright (C) 2003-2009
     5  * Copyright (C) 2003-2011
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     8  *
     8  *
     9  * Permission to use, modify and distribute this software is granted
     9  * Permission to use, modify and distribute this software is granted
    10  * provided that this copyright notice appears in all copies. For
    10  * provided that this copyright notice appears in all copies. For
   534           if ((*_level)[v] == _level->maxLevel()) continue;
   534           if ((*_level)[v] == _level->maxLevel()) continue;
   535           _flow->set(e, 0);
   535           _flow->set(e, 0);
   536           (*_excess)[v] += rem;
   536           (*_excess)[v] += rem;
   537         }
   537         }
   538       }
   538       }
   539       for (NodeIt n(_graph); n != INVALID; ++n) 
   539       for (NodeIt n(_graph); n != INVALID; ++n)
   540         if(n!=_source && n!=_target && _tolerance.positive((*_excess)[n]))
   540         if(n!=_source && n!=_target && _tolerance.positive((*_excess)[n]))
   541           _level->activate(n);
   541           _level->activate(n);
   542           
   542 
   543       return true;
   543       return true;
   544     }
   544     }
   545 
   545 
   546     /// \brief Starts the first phase of the preflow algorithm.
   546     /// \brief Starts the first phase of the preflow algorithm.
   547     ///
   547     ///
   565         while (num > 0) {
   565         while (num > 0) {
   566           n = _level->highestActive();
   566           n = _level->highestActive();
   567           if (n == INVALID) goto first_phase_done;
   567           if (n == INVALID) goto first_phase_done;
   568           level = _level->highestActiveLevel();
   568           level = _level->highestActiveLevel();
   569           --num;
   569           --num;
   570           
   570 
   571           Value excess = (*_excess)[n];
   571           Value excess = (*_excess)[n];
   572           int new_level = _level->maxLevel();
   572           int new_level = _level->maxLevel();
   573 
   573 
   574           for (OutArcIt e(_graph, n); e != INVALID; ++e) {
   574           for (OutArcIt e(_graph, n); e != INVALID; ++e) {
   575             Value rem = (*_capacity)[e] - (*_flow)[e];
   575             Value rem = (*_capacity)[e] - (*_flow)[e];