lemon/bellman_ford.h
changeset 2386 81b47fc5c444
parent 2376 0ed45a6c74b1
child 2391 14a343be7a5a
     1.1 --- a/lemon/bellman_ford.h	Fri Mar 02 17:56:22 2007 +0000
     1.2 +++ b/lemon/bellman_ford.h	Fri Mar 02 18:04:28 2007 +0000
     1.3 @@ -436,15 +436,15 @@
     1.4      /// \return %True when the algorithm have not found more shorter
     1.5      /// paths.
     1.6      bool processNextRound() {
     1.7 -      for (int i = 0; i < (int)_process.size(); ++i) {
     1.8 +      for (int i = 0; i < int(_process.size()); ++i) {
     1.9  	_mask->set(_process[i], false);
    1.10        }
    1.11        std::vector<Node> nextProcess;
    1.12        std::vector<Value> values(_process.size());
    1.13 -      for (int i = 0; i < (int)_process.size(); ++i) {
    1.14 +      for (int i = 0; i < int(_process.size()); ++i) {
    1.15  	values[i] = (*_dist)[_process[i]];
    1.16        }
    1.17 -      for (int i = 0; i < (int)_process.size(); ++i) {
    1.18 +      for (int i = 0; i < int(_process.size()); ++i) {
    1.19  	for (OutEdgeIt it(*graph, _process[i]); it != INVALID; ++it) {
    1.20  	  Node target = graph->target(it);
    1.21  	  Value relaxed = OperationTraits::plus(values[i], (*length)[it]);
    1.22 @@ -472,11 +472,11 @@
    1.23      /// called just weak round.
    1.24      /// \return %True when the algorithm have not found more shorter paths.
    1.25      bool processNextWeakRound() {
    1.26 -      for (int i = 0; i < (int)_process.size(); ++i) {
    1.27 +      for (int i = 0; i < int(_process.size()); ++i) {
    1.28  	_mask->set(_process[i], false);
    1.29        }
    1.30        std::vector<Node> nextProcess;
    1.31 -      for (int i = 0; i < (int)_process.size(); ++i) {
    1.32 +      for (int i = 0; i < int(_process.size()); ++i) {
    1.33  	for (OutEdgeIt it(*graph, _process[i]); it != INVALID; ++it) {
    1.34  	  Node target = graph->target(it);
    1.35  	  Value relaxed = 
    1.36 @@ -645,13 +645,13 @@
    1.37        }
    1.38  
    1.39        bool operator==(const ActiveIt& it) const { 
    1.40 -        return (Node)(*this) == (Node)it; 
    1.41 +        return static_cast<Node>(*this) == static_cast<Node>(it); 
    1.42        }
    1.43        bool operator!=(const ActiveIt& it) const { 
    1.44 -        return (Node)(*this) != (Node)it; 
    1.45 +        return static_cast<Node>(*this) != static_cast<Node>(it); 
    1.46        }
    1.47        bool operator<(const ActiveIt& it) const { 
    1.48 -        return (Node)(*this) < (Node)it; 
    1.49 +        return static_cast<Node>(*this) < static_cast<Node>(it); 
    1.50        }
    1.51        
    1.52      private:
    1.53 @@ -865,8 +865,9 @@
    1.54      BellmanFordWizardBase(const _Graph& graph, 
    1.55  			  const _LengthMap& length, 
    1.56  			  Node source = INVALID) :
    1.57 -      _graph((void *)&graph), _length((void *)&length), _pred(0),
    1.58 -      _dist(0), _source(source) {}
    1.59 +      _graph(reinterpret_cast<void*>(const_cast<_Graph*>(&graph))), 
    1.60 +      _length(reinterpret_cast<void*>(const_cast<_LengthMap*>(&length))), 
    1.61 +      _pred(0), _dist(0), _source(source) {}
    1.62  
    1.63    };
    1.64    
    1.65 @@ -923,8 +924,8 @@
    1.66      /// Constructor that requires parameters.
    1.67      /// These parameters will be the default values for the traits class.
    1.68      BellmanFordWizard(const Graph& graph, const LengthMap& length, 
    1.69 -		      Node source = INVALID) 
    1.70 -      : _Traits(graph, length, source) {}
    1.71 +		      Node src = INVALID) 
    1.72 +      : _Traits(graph, length, src) {}
    1.73  
    1.74      /// \brief Copy constructor
    1.75      BellmanFordWizard(const _Traits &b) : _Traits(b) {}
    1.76 @@ -938,9 +939,10 @@
    1.77      void run() {
    1.78        if(Base::_source == INVALID) throw UninitializedParameter();
    1.79        BellmanFord<Graph,LengthMap,_Traits> 
    1.80 -	bf(*(Graph*)Base::_graph, *(LengthMap*)Base::_length);
    1.81 -      if (Base::_pred) bf.predMap(*(PredMap*)Base::_pred);
    1.82 -      if (Base::_dist) bf.distMap(*(DistMap*)Base::_dist);
    1.83 +	bf(*reinterpret_cast<const Graph*>(Base::_graph), 
    1.84 +           *reinterpret_cast<const LengthMap*>(Base::_length));
    1.85 +      if (Base::_pred) bf.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
    1.86 +      if (Base::_dist) bf.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
    1.87        bf.run(Base::_source);
    1.88      }
    1.89  
    1.90 @@ -948,8 +950,8 @@
    1.91      ///
    1.92      /// Runs BellmanFord algorithm from the given node.
    1.93      /// \param source is the given source.
    1.94 -    void run(Node source) {
    1.95 -      Base::_source = source;
    1.96 +    void run(Node src) {
    1.97 +      Base::_source = src;
    1.98        run();
    1.99      }
   1.100  
   1.101 @@ -969,7 +971,7 @@
   1.102      template<class T>
   1.103      BellmanFordWizard<DefPredMapBase<T> > predMap(const T &t) 
   1.104      {
   1.105 -      Base::_pred=(void *)&t;
   1.106 +      Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t));
   1.107        return BellmanFordWizard<DefPredMapBase<T> >(*this);
   1.108      }
   1.109      
   1.110 @@ -988,7 +990,7 @@
   1.111      ///
   1.112      template<class T>
   1.113      BellmanFordWizard<DefDistMapBase<T> > distMap(const T &t) {
   1.114 -      Base::_dist=(void *)&t;
   1.115 +      Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t));
   1.116        return BellmanFordWizard<DefDistMapBase<T> >(*this);
   1.117      }
   1.118  
   1.119 @@ -1013,8 +1015,8 @@
   1.120      ///
   1.121      /// Sets the source node, from which the BellmanFord algorithm runs.
   1.122      /// \param source is the source node.
   1.123 -    BellmanFordWizard<_Traits>& source(Node source) {
   1.124 -      Base::_source = source;
   1.125 +    BellmanFordWizard<_Traits>& source(Node src) {
   1.126 +      Base::_source = src;
   1.127        return *this;
   1.128      }
   1.129