Bugfix in DijkstraWizard
authoralpar
Sun, 06 Mar 2005 21:20:49 +0000
changeset 1201cb26a6250401
parent 1200 ae69f556b429
child 1202 da44ee225dad
Bugfix in DijkstraWizard
src/lemon/dijkstra.h
     1.1 --- a/src/lemon/dijkstra.h	Sun Mar 06 21:13:24 2005 +0000
     1.2 +++ b/src/lemon/dijkstra.h	Sun Mar 06 21:20:49 2005 +0000
     1.3 @@ -729,6 +729,9 @@
     1.4  
     1.5      typedef DijkstraDefaultTraits<GR,LM> Base;
     1.6    protected:
     1.7 +    /// Type of the nodes in the graph.
     1.8 +    typedef typename Base::Graph::Node Node;
     1.9 +
    1.10      /// Pointer to the underlying graph.
    1.11      void *_g;
    1.12      /// Pointer to the length map
    1.13 @@ -740,10 +743,7 @@
    1.14      ///Pointer to the map of distances.
    1.15      void *_dist;
    1.16      ///Pointer to the source node.
    1.17 -    void *_source;
    1.18 -
    1.19 -    /// Type of the nodes in the graph.
    1.20 -    typedef typename Base::Graph::Node Node;
    1.21 +    Node _source;
    1.22  
    1.23      public:
    1.24      /// Constructor.
    1.25 @@ -751,7 +751,7 @@
    1.26      /// This constructor does not require parameters, therefore it initiates
    1.27      /// all of the attributes to default values (0, INVALID).
    1.28      DijkstraWizardBase() : _g(0), _length(0), _pred(0), _predNode(0),
    1.29 -		       _dist(0), _source(0) {}
    1.30 +		       _dist(0), _source(INVALID) {}
    1.31  
    1.32      /// Constructor.
    1.33      
    1.34 @@ -763,7 +763,7 @@
    1.35      /// \param s is the initial value of  \ref _source
    1.36      DijkstraWizardBase(const GR &g,const LM &l, Node s=INVALID) :
    1.37        _g((void *)&g), _length((void *)&l), _pred(0), _predNode(0),
    1.38 -		  _dist(0), _source((s==INVALID)?0:(void *)&s) {}
    1.39 +		  _dist(0), _source(s) {}
    1.40  
    1.41    };
    1.42    
    1.43 @@ -840,13 +840,13 @@
    1.44      ///The node can be given by the \ref source function.
    1.45      void run()
    1.46      {
    1.47 -      if(Base::_source==0) throw UninitializedParameter();
    1.48 +      if(Base::_source==INVALID) throw UninitializedParameter();
    1.49        Dijkstra<Graph,LengthMap,TR> 
    1.50  	Dij(*(Graph*)Base::_g,*(LengthMap*)Base::_length);
    1.51        if(Base::_pred) Dij.predMap(*(PredMap*)Base::_pred);
    1.52        if(Base::_predNode) Dij.predNodeMap(*(PredNodeMap*)Base::_predNode);
    1.53        if(Base::_dist) Dij.distMap(*(DistMap*)Base::_dist);
    1.54 -      Dij.run(*(Node*)Base::_source);
    1.55 +      Dij.run(Base::_source);
    1.56      }
    1.57  
    1.58      ///Runs Dijkstra algorithm from the given node.
    1.59 @@ -855,7 +855,7 @@
    1.60      ///\param s is the given source.
    1.61      void run(Node s)
    1.62      {
    1.63 -      Base::_source=(void *)&s;
    1.64 +      Base::_source=s;
    1.65        run();
    1.66      }
    1.67  
    1.68 @@ -926,7 +926,7 @@
    1.69      /// \param s is the source node.
    1.70      DijkstraWizard<TR> &source(Node s) 
    1.71      {
    1.72 -      Base::_source=(void *)&s;
    1.73 +      Base::_source=s;
    1.74        return *this;
    1.75      }
    1.76