lemon/max_cardinality_search.h
changeset 1270 dceba191c00d
parent 1129 9a3187204242
child 1271 fb1c7da561ce
     1.1 --- a/lemon/max_cardinality_search.h	Fri Aug 09 14:07:27 2013 +0200
     1.2 +++ b/lemon/max_cardinality_search.h	Fri Aug 09 11:28:17 2013 +0200
     1.3 @@ -1,8 +1,8 @@
     1.4 -/* -*- C++ -*-
     1.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
     1.6   *
     1.7 - * This file is a part of LEMON, a generic C++ optimization library
     1.8 + * This file is a part of LEMON, a generic C++ optimization library.
     1.9   *
    1.10 - * Copyright (C) 2003-2010
    1.11 + * Copyright (C) 2003-2013
    1.12   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    1.13   * (Egervary Research Group on Combinatorial Optimization, EGRES).
    1.14   *
    1.15 @@ -21,7 +21,7 @@
    1.16  
    1.17  
    1.18  /// \ingroup search
    1.19 -/// \file 
    1.20 +/// \file
    1.21  /// \brief Maximum cardinality search in undirected digraphs.
    1.22  
    1.23  #include <lemon/bin_heap.h>
    1.24 @@ -41,7 +41,7 @@
    1.25    /// \param CapacityMap Type of capacity map.
    1.26    template <typename GR, typename CAP>
    1.27    struct MaxCardinalitySearchDefaultTraits {
    1.28 -    /// The digraph type the algorithm runs on. 
    1.29 +    /// The digraph type the algorithm runs on.
    1.30      typedef GR Digraph;
    1.31  
    1.32      template <typename CM>
    1.33 @@ -50,7 +50,7 @@
    1.34        typedef CM CapacityMap;
    1.35  
    1.36        static CapacityMap *createCapacityMap(const Digraph& g) {
    1.37 -	return new CapacityMap(g);
    1.38 +        return new CapacityMap(g);
    1.39        }
    1.40      };
    1.41  
    1.42 @@ -60,7 +60,7 @@
    1.43        typedef ConstMap<CM, Const<int, 1> > CapacityMap;
    1.44  
    1.45        static CapacityMap *createCapacityMap(const Digraph&) {
    1.46 -	return new CapacityMap;
    1.47 +        return new CapacityMap;
    1.48        }
    1.49      };
    1.50  
    1.51 @@ -90,17 +90,17 @@
    1.52  
    1.53      /// \brief Instantiates a HeapCrossRef.
    1.54      ///
    1.55 -    /// This function instantiates a \ref HeapCrossRef. 
    1.56 -    /// \param digraph is the digraph, to which we would like to define the 
    1.57 +    /// This function instantiates a \ref HeapCrossRef.
    1.58 +    /// \param digraph is the digraph, to which we would like to define the
    1.59      /// HeapCrossRef.
    1.60      static HeapCrossRef *createHeapCrossRef(const Digraph &digraph) {
    1.61        return new HeapCrossRef(digraph);
    1.62      }
    1.63 -    
    1.64 +
    1.65      template <typename CapacityMap>
    1.66      struct HeapSelector {
    1.67        template <typename Value, typename Ref>
    1.68 -      struct Selector { 
    1.69 +      struct Selector {
    1.70          typedef BinHeap<Value, Ref, std::greater<Value> > Heap;
    1.71        };
    1.72      };
    1.73 @@ -128,7 +128,7 @@
    1.74  
    1.75      /// \brief Instantiates a Heap.
    1.76      ///
    1.77 -    /// This function instantiates a \ref Heap. 
    1.78 +    /// This function instantiates a \ref Heap.
    1.79      /// \param crossref The cross reference of the heap.
    1.80      static Heap *createHeap(HeapCrossRef& crossref) {
    1.81        return new Heap(crossref);
    1.82 @@ -143,7 +143,7 @@
    1.83  
    1.84      /// \brief Instantiates a ProcessedMap.
    1.85      ///
    1.86 -    /// This function instantiates a \ref ProcessedMap. 
    1.87 +    /// This function instantiates a \ref ProcessedMap.
    1.88      /// \param digraph is the digraph, to which
    1.89      /// we would like to define the \ref ProcessedMap
    1.90  #ifdef DOXYGEN
    1.91 @@ -156,15 +156,15 @@
    1.92      }
    1.93  
    1.94      /// \brief The type of the map that stores the cardinalities of the nodes.
    1.95 -    /// 
    1.96 +    ///
    1.97      /// The type of the map that stores the cardinalities of the nodes.
    1.98      /// It must meet the \ref concepts::WriteMap "WriteMap" concept.
    1.99      typedef typename Digraph::template NodeMap<Value> CardinalityMap;
   1.100  
   1.101      /// \brief Instantiates a CardinalityMap.
   1.102      ///
   1.103 -    /// This function instantiates a \ref CardinalityMap. 
   1.104 -    /// \param digraph is the digraph, to which we would like to define the \ref 
   1.105 +    /// This function instantiates a \ref CardinalityMap.
   1.106 +    /// \param digraph is the digraph, to which we would like to define the \ref
   1.107      /// CardinalityMap
   1.108      static CardinalityMap *createCardinalityMap(const Digraph &digraph) {
   1.109        return new CardinalityMap(digraph);
   1.110 @@ -172,13 +172,13 @@
   1.111  
   1.112  
   1.113    };
   1.114 -  
   1.115 +
   1.116    /// \ingroup search
   1.117    ///
   1.118    /// \brief Maximum Cardinality Search algorithm class.
   1.119    ///
   1.120 -  /// This class provides an efficient implementation of Maximum Cardinality 
   1.121 -  /// Search algorithm. The maximum cardinality search first chooses any 
   1.122 +  /// This class provides an efficient implementation of Maximum Cardinality
   1.123 +  /// Search algorithm. The maximum cardinality search first chooses any
   1.124    /// node of the digraph. Then every time it chooses one unprocessed node
   1.125    /// with maximum cardinality, i.e the sum of capacities on out arcs to the nodes
   1.126    /// which were previusly processed.
   1.127 @@ -186,38 +186,38 @@
   1.128    /// again any unprocessed node of the digraph.
   1.129  
   1.130    /// The arc capacities are passed to the algorithm using a
   1.131 -  /// \ref concepts::ReadMap "ReadMap", so it is easy to change it to any 
   1.132 +  /// \ref concepts::ReadMap "ReadMap", so it is easy to change it to any
   1.133    /// kind of capacity.
   1.134    ///
   1.135 -  /// The type of the capacity is determined by the \ref 
   1.136 +  /// The type of the capacity is determined by the \ref
   1.137    /// concepts::ReadMap::Value "Value" of the capacity map.
   1.138    ///
   1.139    /// It is also possible to change the underlying priority heap.
   1.140    ///
   1.141    ///
   1.142    /// \param GR The digraph type the algorithm runs on. The value of
   1.143 -  /// Digraph is not used directly by the search algorithm, it 
   1.144 +  /// Digraph is not used directly by the search algorithm, it
   1.145    /// is only passed to \ref MaxCardinalitySearchDefaultTraits.
   1.146 -  /// \param CAP This read-only ArcMap determines the capacities of 
   1.147 +  /// \param CAP This read-only ArcMap determines the capacities of
   1.148    /// the arcs. It is read once for each arc, so the map may involve in
   1.149    /// relatively time consuming process to compute the arc capacity if
   1.150    /// it is necessary. The default map type is \ref
   1.151    /// ConstMap "ConstMap<concepts::Digraph::Arc, Const<int,1> >". The value
   1.152 -  /// of CapacityMap is not used directly by search algorithm, it is only 
   1.153 -  /// passed to \ref MaxCardinalitySearchDefaultTraits.  
   1.154 -  /// \param TR Traits class to set various data types used by the 
   1.155 -  /// algorithm.  The default traits class is 
   1.156 -  /// \ref MaxCardinalitySearchDefaultTraits 
   1.157 -  /// "MaxCardinalitySearchDefaultTraits<GR, CAP>".  
   1.158 -  /// See \ref MaxCardinalitySearchDefaultTraits 
   1.159 +  /// of CapacityMap is not used directly by search algorithm, it is only
   1.160 +  /// passed to \ref MaxCardinalitySearchDefaultTraits.
   1.161 +  /// \param TR Traits class to set various data types used by the
   1.162 +  /// algorithm.  The default traits class is
   1.163 +  /// \ref MaxCardinalitySearchDefaultTraits
   1.164 +  /// "MaxCardinalitySearchDefaultTraits<GR, CAP>".
   1.165 +  /// See \ref MaxCardinalitySearchDefaultTraits
   1.166    /// for the documentation of a MaxCardinalitySearch traits class.
   1.167  
   1.168  #ifdef DOXYGEN
   1.169    template <typename GR, typename CAP, typename TR>
   1.170  #else
   1.171 -  template <typename GR, typename CAP = 
   1.172 -	    ConstMap<typename GR::Arc, Const<int,1> >,
   1.173 -	    typename TR = 
   1.174 +  template <typename GR, typename CAP =
   1.175 +            ConstMap<typename GR::Arc, Const<int,1> >,
   1.176 +            typename TR =
   1.177              MaxCardinalitySearchDefaultTraits<GR, CAP> >
   1.178  #endif
   1.179    class MaxCardinalitySearch {
   1.180 @@ -226,7 +226,7 @@
   1.181      typedef TR Traits;
   1.182      ///The type of the underlying digraph.
   1.183      typedef typename Traits::Digraph Digraph;
   1.184 -    
   1.185 +
   1.186      ///The type of the capacity of the arcs.
   1.187      typedef typename Traits::CapacityMap::Value Value;
   1.188      ///The type of the map that stores the arc capacities.
   1.189 @@ -266,7 +266,7 @@
   1.190    public :
   1.191  
   1.192      typedef MaxCardinalitySearch Create;
   1.193 - 
   1.194 +
   1.195      ///\name Named template parameters
   1.196  
   1.197      ///@{
   1.198 @@ -275,89 +275,89 @@
   1.199      struct DefCapacityMapTraits : public Traits {
   1.200        typedef T CapacityMap;
   1.201        static CapacityMap *createCapacityMap(const Digraph &) {
   1.202 -       	LEMON_ASSERT(false,"Uninitialized parameter.");
   1.203 -	return 0;
   1.204 +               LEMON_ASSERT(false,"Uninitialized parameter.");
   1.205 +        return 0;
   1.206        }
   1.207      };
   1.208 -    /// \brief \ref named-templ-param "Named parameter" for setting 
   1.209 +    /// \brief \ref named-templ-param "Named parameter" for setting
   1.210      /// CapacityMap type
   1.211      ///
   1.212      /// \ref named-templ-param "Named parameter" for setting CapacityMap type
   1.213      /// for the algorithm.
   1.214      template <class T>
   1.215 -    struct SetCapacityMap 
   1.216 -      : public MaxCardinalitySearch<Digraph, CapacityMap, 
   1.217 -                                    DefCapacityMapTraits<T> > { 
   1.218 -      typedef MaxCardinalitySearch<Digraph, CapacityMap, 
   1.219 +    struct SetCapacityMap
   1.220 +      : public MaxCardinalitySearch<Digraph, CapacityMap,
   1.221 +                                    DefCapacityMapTraits<T> > {
   1.222 +      typedef MaxCardinalitySearch<Digraph, CapacityMap,
   1.223                                     DefCapacityMapTraits<T> > Create;
   1.224      };
   1.225  
   1.226      template <class T>
   1.227      struct DefCardinalityMapTraits : public Traits {
   1.228        typedef T CardinalityMap;
   1.229 -      static CardinalityMap *createCardinalityMap(const Digraph &) 
   1.230 +      static CardinalityMap *createCardinalityMap(const Digraph &)
   1.231        {
   1.232 -	LEMON_ASSERT(false,"Uninitialized parameter.");
   1.233 -	return 0;
   1.234 +        LEMON_ASSERT(false,"Uninitialized parameter.");
   1.235 +        return 0;
   1.236        }
   1.237      };
   1.238 -    /// \brief \ref named-templ-param "Named parameter" for setting 
   1.239 +    /// \brief \ref named-templ-param "Named parameter" for setting
   1.240      /// CardinalityMap type
   1.241      ///
   1.242 -    /// \ref named-templ-param "Named parameter" for setting CardinalityMap 
   1.243 +    /// \ref named-templ-param "Named parameter" for setting CardinalityMap
   1.244      /// type for the algorithm.
   1.245      template <class T>
   1.246 -    struct SetCardinalityMap 
   1.247 -      : public MaxCardinalitySearch<Digraph, CapacityMap, 
   1.248 -                                    DefCardinalityMapTraits<T> > { 
   1.249 -      typedef MaxCardinalitySearch<Digraph, CapacityMap, 
   1.250 +    struct SetCardinalityMap
   1.251 +      : public MaxCardinalitySearch<Digraph, CapacityMap,
   1.252 +                                    DefCardinalityMapTraits<T> > {
   1.253 +      typedef MaxCardinalitySearch<Digraph, CapacityMap,
   1.254                                     DefCardinalityMapTraits<T> > Create;
   1.255      };
   1.256 -    
   1.257 +
   1.258      template <class T>
   1.259      struct DefProcessedMapTraits : public Traits {
   1.260        typedef T ProcessedMap;
   1.261        static ProcessedMap *createProcessedMap(const Digraph &) {
   1.262 -       	LEMON_ASSERT(false,"Uninitialized parameter.");
   1.263 -	return 0;
   1.264 +               LEMON_ASSERT(false,"Uninitialized parameter.");
   1.265 +        return 0;
   1.266        }
   1.267      };
   1.268 -    /// \brief \ref named-templ-param "Named parameter" for setting 
   1.269 +    /// \brief \ref named-templ-param "Named parameter" for setting
   1.270      /// ProcessedMap type
   1.271      ///
   1.272      /// \ref named-templ-param "Named parameter" for setting ProcessedMap type
   1.273      /// for the algorithm.
   1.274      template <class T>
   1.275 -    struct SetProcessedMap 
   1.276 -      : public MaxCardinalitySearch<Digraph, CapacityMap, 
   1.277 -                                    DefProcessedMapTraits<T> > { 
   1.278 -      typedef MaxCardinalitySearch<Digraph, CapacityMap, 
   1.279 +    struct SetProcessedMap
   1.280 +      : public MaxCardinalitySearch<Digraph, CapacityMap,
   1.281 +                                    DefProcessedMapTraits<T> > {
   1.282 +      typedef MaxCardinalitySearch<Digraph, CapacityMap,
   1.283                                     DefProcessedMapTraits<T> > Create;
   1.284      };
   1.285 -    
   1.286 +
   1.287      template <class H, class CR>
   1.288      struct DefHeapTraits : public Traits {
   1.289        typedef CR HeapCrossRef;
   1.290        typedef H Heap;
   1.291        static HeapCrossRef *createHeapCrossRef(const Digraph &) {
   1.292 -     	LEMON_ASSERT(false,"Uninitialized parameter.");
   1.293 -	return 0;
   1.294 +             LEMON_ASSERT(false,"Uninitialized parameter.");
   1.295 +        return 0;
   1.296        }
   1.297        static Heap *createHeap(HeapCrossRef &) {
   1.298 -       	LEMON_ASSERT(false,"Uninitialized parameter.");
   1.299 -	return 0;
   1.300 +               LEMON_ASSERT(false,"Uninitialized parameter.");
   1.301 +        return 0;
   1.302        }
   1.303      };
   1.304 -    /// \brief \ref named-templ-param "Named parameter" for setting heap 
   1.305 +    /// \brief \ref named-templ-param "Named parameter" for setting heap
   1.306      /// and cross reference type
   1.307      ///
   1.308 -    /// \ref named-templ-param "Named parameter" for setting heap and cross 
   1.309 +    /// \ref named-templ-param "Named parameter" for setting heap and cross
   1.310      /// reference type for the algorithm.
   1.311      template <class H, class CR = typename Digraph::template NodeMap<int> >
   1.312      struct SetHeap
   1.313 -      : public MaxCardinalitySearch<Digraph, CapacityMap, 
   1.314 -                                    DefHeapTraits<H, CR> > { 
   1.315 -      typedef MaxCardinalitySearch< Digraph, CapacityMap, 
   1.316 +      : public MaxCardinalitySearch<Digraph, CapacityMap,
   1.317 +                                    DefHeapTraits<H, CR> > {
   1.318 +      typedef MaxCardinalitySearch< Digraph, CapacityMap,
   1.319                                      DefHeapTraits<H, CR> > Create;
   1.320      };
   1.321  
   1.322 @@ -366,29 +366,29 @@
   1.323        typedef CR HeapCrossRef;
   1.324        typedef H Heap;
   1.325        static HeapCrossRef *createHeapCrossRef(const Digraph &digraph) {
   1.326 -	return new HeapCrossRef(digraph);
   1.327 +        return new HeapCrossRef(digraph);
   1.328        }
   1.329        static Heap *createHeap(HeapCrossRef &crossref) {
   1.330 -	return new Heap(crossref);
   1.331 +        return new Heap(crossref);
   1.332        }
   1.333      };
   1.334  
   1.335 -    /// \brief \ref named-templ-param "Named parameter" for setting heap and 
   1.336 +    /// \brief \ref named-templ-param "Named parameter" for setting heap and
   1.337      /// cross reference type with automatic allocation
   1.338      ///
   1.339 -    /// \ref named-templ-param "Named parameter" for setting heap and cross 
   1.340 -    /// reference type. It can allocate the heap and the cross reference 
   1.341 -    /// object if the cross reference's constructor waits for the digraph as 
   1.342 +    /// \ref named-templ-param "Named parameter" for setting heap and cross
   1.343 +    /// reference type. It can allocate the heap and the cross reference
   1.344 +    /// object if the cross reference's constructor waits for the digraph as
   1.345      /// parameter and the heap's constructor waits for the cross reference.
   1.346      template <class H, class CR = typename Digraph::template NodeMap<int> >
   1.347      struct SetStandardHeap
   1.348 -      : public MaxCardinalitySearch<Digraph, CapacityMap, 
   1.349 -                                    DefStandardHeapTraits<H, CR> > { 
   1.350 -      typedef MaxCardinalitySearch<Digraph, CapacityMap, 
   1.351 -                                   DefStandardHeapTraits<H, CR> > 
   1.352 +      : public MaxCardinalitySearch<Digraph, CapacityMap,
   1.353 +                                    DefStandardHeapTraits<H, CR> > {
   1.354 +      typedef MaxCardinalitySearch<Digraph, CapacityMap,
   1.355 +                                   DefStandardHeapTraits<H, CR> >
   1.356        Create;
   1.357      };
   1.358 -    
   1.359 +
   1.360      ///@}
   1.361  
   1.362  
   1.363 @@ -396,14 +396,14 @@
   1.364  
   1.365      MaxCardinalitySearch() {}
   1.366  
   1.367 -  public:      
   1.368 -    
   1.369 +  public:
   1.370 +
   1.371      /// \brief Constructor.
   1.372      ///
   1.373      ///\param digraph the digraph the algorithm will run on.
   1.374      ///\param capacity the capacity map used by the algorithm.
   1.375      MaxCardinalitySearch(const Digraph& digraph,
   1.376 -			 const CapacityMap& capacity) :
   1.377 +                         const CapacityMap& capacity) :
   1.378        _graph(&digraph),
   1.379        _capacity(&capacity), local_capacity(false),
   1.380        _cardinality(0), local_cardinality(false),
   1.381 @@ -441,8 +441,8 @@
   1.382      /// \return <tt> (*this) </tt>
   1.383      MaxCardinalitySearch &capacityMap(const CapacityMap &m) {
   1.384        if (local_capacity) {
   1.385 -	delete _capacity;
   1.386 -	local_capacity=false;
   1.387 +        delete _capacity;
   1.388 +        local_capacity=false;
   1.389        }
   1.390        _capacity=&m;
   1.391        return *this;
   1.392 @@ -456,7 +456,7 @@
   1.393        return *_capacity;
   1.394      }
   1.395  
   1.396 -    /// \brief Sets the map storing the cardinalities calculated by the 
   1.397 +    /// \brief Sets the map storing the cardinalities calculated by the
   1.398      /// algorithm.
   1.399      ///
   1.400      /// Sets the map storing the cardinalities calculated by the algorithm.
   1.401 @@ -466,8 +466,8 @@
   1.402      /// \return <tt> (*this) </tt>
   1.403      MaxCardinalitySearch &cardinalityMap(CardinalityMap &m) {
   1.404        if(local_cardinality) {
   1.405 -	delete _cardinality;
   1.406 -	local_cardinality=false;
   1.407 +        delete _cardinality;
   1.408 +        local_cardinality=false;
   1.409        }
   1.410        _cardinality = &m;
   1.411        return *this;
   1.412 @@ -480,11 +480,11 @@
   1.413      /// it will allocate one. The destuctor deallocates this
   1.414      /// automatically allocated map, of course.
   1.415      /// \return <tt> (*this) </tt>
   1.416 -    MaxCardinalitySearch &processedMap(ProcessedMap &m) 
   1.417 +    MaxCardinalitySearch &processedMap(ProcessedMap &m)
   1.418      {
   1.419        if(local_processed) {
   1.420 -	delete _processed;
   1.421 -	local_processed=false;
   1.422 +        delete _processed;
   1.423 +        local_processed=false;
   1.424        }
   1.425        _processed = &m;
   1.426        return *this;
   1.427 @@ -507,13 +507,13 @@
   1.428      /// \return <tt> (*this) </tt>
   1.429      MaxCardinalitySearch &heap(Heap& hp, HeapCrossRef &cr) {
   1.430        if(local_heap_cross_ref) {
   1.431 -	delete _heap_cross_ref;
   1.432 -	local_heap_cross_ref = false;
   1.433 +        delete _heap_cross_ref;
   1.434 +        local_heap_cross_ref = false;
   1.435        }
   1.436        _heap_cross_ref = &cr;
   1.437        if(local_heap) {
   1.438 -	delete _heap;
   1.439 -	local_heap = false;
   1.440 +        delete _heap;
   1.441 +        local_heap = false;
   1.442        }
   1.443        _heap = &hp;
   1.444        return *this;
   1.445 @@ -544,27 +544,27 @@
   1.446  
   1.447      void create_maps() {
   1.448        if(!_capacity) {
   1.449 -	local_capacity = true;
   1.450 -	_capacity = Traits::createCapacityMap(*_graph);
   1.451 +        local_capacity = true;
   1.452 +        _capacity = Traits::createCapacityMap(*_graph);
   1.453        }
   1.454        if(!_cardinality) {
   1.455 -	local_cardinality = true;
   1.456 -	_cardinality = Traits::createCardinalityMap(*_graph);
   1.457 +        local_cardinality = true;
   1.458 +        _cardinality = Traits::createCardinalityMap(*_graph);
   1.459        }
   1.460        if(!_processed) {
   1.461 -	local_processed = true;
   1.462 -	_processed = Traits::createProcessedMap(*_graph);
   1.463 +        local_processed = true;
   1.464 +        _processed = Traits::createProcessedMap(*_graph);
   1.465        }
   1.466        if (!_heap_cross_ref) {
   1.467 -	local_heap_cross_ref = true;
   1.468 -	_heap_cross_ref = Traits::createHeapCrossRef(*_graph);
   1.469 +        local_heap_cross_ref = true;
   1.470 +        _heap_cross_ref = Traits::createHeapCrossRef(*_graph);
   1.471        }
   1.472        if (!_heap) {
   1.473 -	local_heap = true;
   1.474 -	_heap = Traits::createHeap(*_heap_cross_ref);
   1.475 +        local_heap = true;
   1.476 +        _heap = Traits::createHeap(*_heap_cross_ref);
   1.477        }
   1.478      }
   1.479 -    
   1.480 +
   1.481      void finalizeNodeData(Node node, Value capacity) {
   1.482        _processed->set(node, true);
   1.483        _cardinality->set(node, capacity);
   1.484 @@ -589,22 +589,22 @@
   1.485        create_maps();
   1.486        _heap->clear();
   1.487        for (NodeIt it(*_graph) ; it != INVALID ; ++it) {
   1.488 -	_processed->set(it, false);
   1.489 -	_heap_cross_ref->set(it, Heap::PRE_HEAP);
   1.490 +        _processed->set(it, false);
   1.491 +        _heap_cross_ref->set(it, Heap::PRE_HEAP);
   1.492        }
   1.493      }
   1.494 -    
   1.495 +
   1.496      /// \brief Adds a new source node.
   1.497 -    /// 
   1.498 +    ///
   1.499      /// Adds a new source node to the priority heap.
   1.500      ///
   1.501      /// It checks if the node has not yet been added to the heap.
   1.502      void addSource(Node source, Value capacity = 0) {
   1.503        if(_heap->state(source) == Heap::PRE_HEAP) {
   1.504 -	_heap->push(source, capacity);
   1.505 -      } 
   1.506 +        _heap->push(source, capacity);
   1.507 +      }
   1.508      }
   1.509 -    
   1.510 +
   1.511      /// \brief Processes the next node in the priority heap
   1.512      ///
   1.513      /// Processes the next node in the priority heap.
   1.514 @@ -613,22 +613,22 @@
   1.515      ///
   1.516      /// \warning The priority heap must not be empty!
   1.517      Node processNextNode() {
   1.518 -      Node node = _heap->top(); 
   1.519 +      Node node = _heap->top();
   1.520        finalizeNodeData(node, _heap->prio());
   1.521        _heap->pop();
   1.522 -      
   1.523 +
   1.524        for (InArcIt it(*_graph, node); it != INVALID; ++it) {
   1.525 -	Node source = _graph->source(it);
   1.526 -	switch (_heap->state(source)) {
   1.527 -	case Heap::PRE_HEAP:
   1.528 -	  _heap->push(source, (*_capacity)[it]);
   1.529 -	  break;
   1.530 -	case Heap::IN_HEAP:
   1.531 -	  _heap->decrease(source, (*_heap)[source] + (*_capacity)[it]);
   1.532 -	  break;
   1.533 -	case Heap::POST_HEAP:
   1.534 -	  break;
   1.535 -	}
   1.536 +        Node source = _graph->source(it);
   1.537 +        switch (_heap->state(source)) {
   1.538 +        case Heap::PRE_HEAP:
   1.539 +          _heap->push(source, (*_capacity)[it]);
   1.540 +          break;
   1.541 +        case Heap::IN_HEAP:
   1.542 +          _heap->decrease(source, (*_heap)[source] + (*_capacity)[it]);
   1.543 +          break;
   1.544 +        case Heap::POST_HEAP:
   1.545 +          break;
   1.546 +        }
   1.547        }
   1.548        return node;
   1.549      }
   1.550 @@ -637,24 +637,24 @@
   1.551      ///
   1.552      /// Next node to be processed.
   1.553      ///
   1.554 -    /// \return The next node to be processed or INVALID if the 
   1.555 +    /// \return The next node to be processed or INVALID if the
   1.556      /// priority heap is empty.
   1.557 -    Node nextNode() { 
   1.558 +    Node nextNode() {
   1.559        return !_heap->empty() ? _heap->top() : INVALID;
   1.560      }
   1.561 - 
   1.562 +
   1.563      /// \brief Returns \c false if there are nodes
   1.564      /// to be processed in the priority heap
   1.565      ///
   1.566      /// Returns \c false if there are nodes
   1.567      /// to be processed in the priority heap
   1.568      bool emptyQueue() { return _heap->empty(); }
   1.569 -    /// \brief Returns the number of the nodes to be processed 
   1.570 +    /// \brief Returns the number of the nodes to be processed
   1.571      /// in the priority heap
   1.572      ///
   1.573      /// Returns the number of the nodes to be processed in the priority heap
   1.574      int emptySize() { return _heap->size(); }
   1.575 -    
   1.576 +
   1.577      /// \brief Executes the algorithm.
   1.578      ///
   1.579      /// Executes the algorithm.
   1.580 @@ -662,12 +662,12 @@
   1.581      ///\pre init() must be called and at least one node should be added
   1.582      /// with addSource() before using this function.
   1.583      ///
   1.584 -    /// This method runs the Maximum Cardinality Search algorithm from the 
   1.585 +    /// This method runs the Maximum Cardinality Search algorithm from the
   1.586      /// source node(s).
   1.587      void start() {
   1.588        while ( !_heap->empty() ) processNextNode();
   1.589      }
   1.590 -    
   1.591 +
   1.592      /// \brief Executes the algorithm until \c dest is reached.
   1.593      ///
   1.594      /// Executes the algorithm until \c dest is reached.
   1.595 @@ -675,13 +675,13 @@
   1.596      /// \pre init() must be called and at least one node should be added
   1.597      /// with addSource() before using this function.
   1.598      ///
   1.599 -    /// This method runs the %MaxCardinalitySearch algorithm from the source 
   1.600 +    /// This method runs the %MaxCardinalitySearch algorithm from the source
   1.601      /// nodes.
   1.602      void start(Node dest) {
   1.603        while ( !_heap->empty() && _heap->top()!=dest ) processNextNode();
   1.604        if ( !_heap->empty() ) finalizeNodeData(_heap->top(), _heap->prio());
   1.605      }
   1.606 -    
   1.607 +
   1.608      /// \brief Executes the algorithm until a condition is met.
   1.609      ///
   1.610      /// Executes the algorithm until a condition is met.
   1.611 @@ -696,10 +696,10 @@
   1.612        while ( !_heap->empty() && !nm[_heap->top()] ) processNextNode();
   1.613        if ( !_heap->empty() ) finalizeNodeData(_heap->top(),_heap->prio());
   1.614      }
   1.615 -    
   1.616 +
   1.617      /// \brief Runs the maximum cardinality search algorithm from node \c s.
   1.618      ///
   1.619 -    /// This method runs the %MaxCardinalitySearch algorithm from a root 
   1.620 +    /// This method runs the %MaxCardinalitySearch algorithm from a root
   1.621      /// node \c s.
   1.622      ///
   1.623      ///\note d.run(s) is just a shortcut of the following code.
   1.624 @@ -714,10 +714,10 @@
   1.625        start();
   1.626      }
   1.627  
   1.628 -    /// \brief Runs the maximum cardinality search algorithm for the 
   1.629 +    /// \brief Runs the maximum cardinality search algorithm for the
   1.630      /// whole digraph.
   1.631      ///
   1.632 -    /// This method runs the %MaxCardinalitySearch algorithm from all 
   1.633 +    /// This method runs the %MaxCardinalitySearch algorithm from all
   1.634      /// unprocessed node of the digraph.
   1.635      ///
   1.636      ///\note d.run(s) is just a shortcut of the following code.
   1.637 @@ -739,16 +739,16 @@
   1.638          }
   1.639        }
   1.640      }
   1.641 -    
   1.642 +
   1.643      ///@}
   1.644  
   1.645      /// \name Query Functions
   1.646 -    /// The results of the maximum cardinality search algorithm can be 
   1.647 +    /// The results of the maximum cardinality search algorithm can be
   1.648      /// obtained using these functions.
   1.649      /// \n
   1.650 -    /// Before the use of these functions, either run() or start() must be 
   1.651 +    /// Before the use of these functions, either run() or start() must be
   1.652      /// called.
   1.653 -    
   1.654 +
   1.655      ///@{
   1.656  
   1.657      /// \brief The cardinality of a node.
   1.658 @@ -767,10 +767,10 @@
   1.659  
   1.660      /// \brief Returns a reference to the NodeMap of cardinalities.
   1.661      ///
   1.662 -    /// Returns a reference to the NodeMap of cardinalities. \pre \ref run() 
   1.663 +    /// Returns a reference to the NodeMap of cardinalities. \pre \ref run()
   1.664      /// must be called before using this function.
   1.665      const CardinalityMap &cardinalityMap() const { return *_cardinality;}
   1.666 - 
   1.667 +
   1.668      /// \brief Checks if a node is reachable from the root.
   1.669      ///
   1.670      /// Returns \c true if \c v is reachable from the root.
   1.671 @@ -784,7 +784,7 @@
   1.672      /// path to \c v has already found.
   1.673      /// \pre \ref run() must be called before using this function.
   1.674      bool processed(Node v) { return (*_heap_cross_ref)[v] == Heap::POST_HEAP; }
   1.675 -    
   1.676 +
   1.677      ///@}
   1.678    };
   1.679