Index: lemon/dijkstra.h
===================================================================
--- lemon/dijkstra.h	(revision 278)
+++ lemon/dijkstra.h	(revision 280)
@@ -31,5 +31,4 @@
 #include <lemon/error.h>
 #include <lemon/maps.h>
-#include <lemon/path.h>
 
 namespace lemon {
@@ -145,5 +144,4 @@
     ///\param g is the digraph, to which we would like to define the
     ///\ref PredMap.
-    ///\todo The digraph alone may be insufficient for the initialization
     static PredMap *createPredMap(const Digraph &g)
     {
@@ -156,6 +154,4 @@
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     ///By default it is a NullMap.
-    ///\todo If it is set to a real map,
-    ///Dijkstra::processed() should read this.
     typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
     ///Instantiates a \ref ProcessedMap.
@@ -201,5 +197,5 @@
   ///It is also possible to change the underlying priority heap.
   ///
-  ///There is also a \ref dijkstra() "function-type interface" for the
+  ///There is also a \ref dijkstra() "function type interface" for the
   ///%Dijkstra algorithm, which is convenient in the simplier cases and
   ///it can be used easier.
@@ -298,6 +294,5 @@
     bool local_heap;
 
-    ///Creates the maps if necessary.
-    ///\todo Better memory allocation (instead of new).
+    //Creates the maps if necessary.
     void create_maps()
     {
@@ -959,5 +954,4 @@
     /// \param g is the digraph, to which we would like to define the
     /// HeapCrossRef.
-    /// \todo The digraph alone may be insufficient for the initialization
     static HeapCrossRef *createHeapCrossRef(const Digraph &g)
     {
@@ -989,5 +983,5 @@
     ///arcs of the shortest paths.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
+    typedef NullMap <typename Digraph::Node,typename Digraph::Arc> PredMap;
     ///Instantiates a \ref PredMap.
 
@@ -995,8 +989,11 @@
     ///\param g is the digraph, to which we would like to define the
     ///\ref PredMap.
-    ///\todo The digraph alone may be insufficient to initialize
+#ifdef DOXYGEN
     static PredMap *createPredMap(const Digraph &g)
-    {
-      return new PredMap(g);
+#else
+    static PredMap *createPredMap(const Digraph &)
+#endif
+    {
+      return new PredMap();
     }
 
@@ -1006,7 +1003,4 @@
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     ///By default it is a NullMap.
-    ///\todo If it is set to a real map,
-    ///Dijkstra::processed() should read this.
-    ///\todo named parameter to set this type, function to read and write.
     typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
     ///Instantiates a \ref ProcessedMap.
@@ -1028,5 +1022,5 @@
     ///The type of the map that stores the distances of the nodes.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    typedef typename Digraph::template NodeMap<typename LM::Value> DistMap;
+    typedef NullMap<typename Digraph::Node,Value> DistMap;
     ///Instantiates a \ref DistMap.
 
@@ -1034,14 +1028,12 @@
     ///\param g is the digraph, to which we would like to define
     ///the \ref DistMap
+#ifdef DOXYGEN
     static DistMap *createDistMap(const Digraph &g)
-    {
-      return new DistMap(g);
-    }
-
-    ///The type of the shortest paths.
-
-    ///The type of the shortest paths.
-    ///It must meet the \ref concepts::Path "Path" concept.
-    typedef lemon::Path<Digraph> Path;
+#else
+    static DistMap *createDistMap(const Digraph &)
+#endif
+    {
+      return new DistMap();
+    }
   };
 
@@ -1054,5 +1046,4 @@
   /// The \ref DijkstraWizardBase is a class to be the default traits of the
   /// \ref DijkstraWizard class.
-  /// \todo More named parameters are required...
   template<class GR,class LM>
   class DijkstraWizardBase : public DijkstraWizardDefaultTraits<GR,LM>
@@ -1065,5 +1056,5 @@
     //Pointer to the digraph the algorithm runs on.
     void *_g;
-    //Pointer to the length map.
+    //Pointer to the length map
     void *_length;
     //Pointer to the map of processed nodes.
@@ -1073,8 +1064,6 @@
     //Pointer to the map of distances.
     void *_dist;
-    //Pointer to the shortest path to the target node.
-    void *_path;
-    //Pointer to the distance of the target node.
-    void *_di;
+    //Pointer to the source node.
+    Node _source;
 
   public:
@@ -1082,30 +1071,44 @@
 
     /// This constructor does not require parameters, therefore it initiates
-    /// all of the attributes to \c 0.
+    /// all of the attributes to default values (0, INVALID).
     DijkstraWizardBase() : _g(0), _length(0), _processed(0), _pred(0),
-                           _dist(0), _path(0), _di(0) {}
+                           _dist(0), _source(INVALID) {}
 
     /// Constructor.
 
-    /// This constructor requires two parameters,
-    /// others are initiated to \c 0.
+    /// This constructor requires some parameters,
+    /// listed in the parameters list.
+    /// Others are initiated to 0.
     /// \param g The digraph the algorithm runs on.
     /// \param l The length map.
-    DijkstraWizardBase(const GR &g,const LM &l) :
+    /// \param s The source node.
+    DijkstraWizardBase(const GR &g,const LM &l, Node s=INVALID) :
       _g(reinterpret_cast<void*>(const_cast<GR*>(&g))),
       _length(reinterpret_cast<void*>(const_cast<LM*>(&l))),
-      _processed(0), _pred(0), _dist(0), _path(0), _di(0) {}
+      _processed(0), _pred(0), _dist(0), _source(s) {}
 
   };
 
-  /// Auxiliary class for the function-type interface of Dijkstra algorithm.
-
-  /// This auxiliary class is created to implement the
-  /// \ref dijkstra() "function-type interface" of \ref Dijkstra algorithm.
-  /// It does not have own \ref run() method, it uses the functions
-  /// and features of the plain \ref Dijkstra.
+  /// Auxiliary class for the function type interface of Dijkstra algorithm.
+
+  /// This auxiliary class is created to implement the function type
+  /// interface of \ref Dijkstra algorithm. It uses the functions and features
+  /// of the plain \ref Dijkstra, but it is much simpler to use it.
+  /// It should only be used through the \ref dijkstra() function, which makes
+  /// it easier to use the algorithm.
   ///
-  /// This class should only be used through the \ref dijkstra() function,
-  /// which makes it easier to use the algorithm.
+  /// Simplicity means that the way to change the types defined
+  /// in the traits class is based on functions that returns the new class
+  /// and not on templatable built-in classes.
+  /// When using the plain \ref Dijkstra
+  /// the new class with the modified type comes from
+  /// the original class by using the ::
+  /// operator. In the case of \ref DijkstraWizard only
+  /// a function have to be called, and it will
+  /// return the needed class.
+  ///
+  /// It does not have own \ref run() method. When its \ref run() method
+  /// is called, it initiates a plain \ref Dijkstra object, and calls the
+  /// \ref Dijkstra::run() method of it.
   template<class TR>
   class DijkstraWizard : public TR
@@ -1132,6 +1135,4 @@
     ///The type of the map that indicates which nodes are processed.
     typedef typename TR::ProcessedMap ProcessedMap;
-    ///The type of the shortest paths
-    typedef typename TR::Path Path;
     ///The heap type used by the dijkstra algorithm.
     typedef typename TR::Heap Heap;
@@ -1146,8 +1147,6 @@
     /// Constructor that requires parameters.
     /// These parameters will be the default values for the traits class.
-    /// \param g The digraph the algorithm runs on.
-    /// \param l The length map.
-    DijkstraWizard(const Digraph &g, const LengthMap &l) :
-      TR(g,l) {}
+    DijkstraWizard(const Digraph &g,const LengthMap &l, Node s=INVALID) :
+      TR(g,l,s) {}
 
     ///Copy constructor
@@ -1156,48 +1155,41 @@
     ~DijkstraWizard() {}
 
-    ///Runs Dijkstra algorithm from the given source node.
-
-    ///This method runs %Dijkstra algorithm from the given source node
-    ///in order to compute the shortest path to each node.
+    ///Runs Dijkstra algorithm from a source node.
+
+    ///Runs Dijkstra algorithm from a source node.
+    ///The node can be given with the \ref source() function.
+    void run()
+    {
+      if(Base::_source==INVALID) throw UninitializedParameter();
+      Dijkstra<Digraph,LengthMap,TR>
+        dij(*reinterpret_cast<const Digraph*>(Base::_g),
+            *reinterpret_cast<const LengthMap*>(Base::_length));
+      if(Base::_processed)
+        dij.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed));
+      if(Base::_pred)
+        dij.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
+      if(Base::_dist)
+        dij.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
+      dij.run(Base::_source);
+    }
+
+    ///Runs Dijkstra algorithm from the given node.
+
+    ///Runs Dijkstra algorithm from the given node.
+    ///\param s is the given source.
     void run(Node s)
     {
-      if (s==INVALID) throw UninitializedParameter();
-      Dijkstra<Digraph,LengthMap,TR>
-        dijk(*reinterpret_cast<const Digraph*>(Base::_g),
-             *reinterpret_cast<const LengthMap*>(Base::_length));
-      if (Base::_pred)
-        dijk.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
-      if (Base::_dist)
-        dijk.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
-      if (Base::_processed)
-        dijk.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed));
-      dijk.run(s);
-    }
-
-    ///Finds the shortest path between \c s and \c t.
-
-    ///This method runs the %Dijkstra algorithm from node \c s
-    ///in order to compute the shortest path to node \c t
-    ///(it stops searching when \c t is processed).
-    ///
-    ///\return \c true if \c t is reachable form \c s.
-    bool run(Node s, Node t)
-    {
-      if (s==INVALID || t==INVALID) throw UninitializedParameter();
-      Dijkstra<Digraph,LengthMap,TR>
-        dijk(*reinterpret_cast<const Digraph*>(Base::_g),
-             *reinterpret_cast<const LengthMap*>(Base::_length));
-      if (Base::_pred)
-        dijk.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
-      if (Base::_dist)
-        dijk.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
-      if (Base::_processed)
-        dijk.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed));
-      dijk.run(s,t);
-      if (Base::_path)
-        *reinterpret_cast<Path*>(Base::_path) = dijk.path(t);
-      if (Base::_di)
-        *reinterpret_cast<Value*>(Base::_di) = dijk.dist(t);
-      return dijk.reached(t);
+      Base::_source=s;
+      run();
+    }
+
+    /// Sets the source node, from which the Dijkstra algorithm runs.
+
+    /// Sets the source node, from which the Dijkstra algorithm runs.
+    /// \param s is the source node.
+    DijkstraWizard<TR> &source(Node s)
+    {
+      Base::_source=s;
+      return *this;
     }
 
@@ -1208,8 +1200,8 @@
       SetPredMapBase(const TR &b) : TR(b) {}
     };
-    ///\brief \ref named-func-param "Named parameter"
+    ///\brief \ref named-templ-param "Named parameter"
     ///for setting \ref PredMap object.
     ///
-    ///\ref named-func-param "Named parameter"
+    ///\ref named-templ-param "Named parameter"
     ///for setting \ref PredMap object.
     template<class T>
@@ -1218,4 +1210,22 @@
       Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t));
       return DijkstraWizard<SetPredMapBase<T> >(*this);
+    }
+
+    template<class T>
+    struct SetProcessedMapBase : public Base {
+      typedef T ProcessedMap;
+      static ProcessedMap *createProcessedMap(const Digraph &) { return 0; };
+      SetProcessedMapBase(const TR &b) : TR(b) {}
+    };
+    ///\brief \ref named-templ-param "Named parameter"
+    ///for setting \ref ProcessedMap object.
+    ///
+    /// \ref named-templ-param "Named parameter"
+    ///for setting \ref ProcessedMap object.
+    template<class T>
+    DijkstraWizard<SetProcessedMapBase<T> > processedMap(const T &t)
+    {
+      Base::_processed=reinterpret_cast<void*>(const_cast<T*>(&t));
+      return DijkstraWizard<SetProcessedMapBase<T> >(*this);
     }
 
@@ -1226,8 +1236,8 @@
       SetDistMapBase(const TR &b) : TR(b) {}
     };
-    ///\brief \ref named-func-param "Named parameter"
+    ///\brief \ref named-templ-param "Named parameter"
     ///for setting \ref DistMap object.
     ///
-    ///\ref named-func-param "Named parameter"
+    ///\ref named-templ-param "Named parameter"
     ///for setting \ref DistMap object.
     template<class T>
@@ -1238,66 +1248,18 @@
     }
 
-    template<class T>
-    struct SetProcessedMapBase : public Base {
-      typedef T ProcessedMap;
-      static ProcessedMap *createProcessedMap(const Digraph &) { return 0; };
-      SetProcessedMapBase(const TR &b) : TR(b) {}
-    };
-    ///\brief \ref named-func-param "Named parameter"
-    ///for setting \ref ProcessedMap object.
-    ///
-    /// \ref named-func-param "Named parameter"
-    ///for setting \ref ProcessedMap object.
-    template<class T>
-    DijkstraWizard<SetProcessedMapBase<T> > processedMap(const T &t)
-    {
-      Base::_processed=reinterpret_cast<void*>(const_cast<T*>(&t));
-      return DijkstraWizard<SetProcessedMapBase<T> >(*this);
-    }
-
-    template<class T>
-    struct SetPathBase : public Base {
-      typedef T Path;
-      SetPathBase(const TR &b) : TR(b) {}
-    };
-    ///\brief \ref named-func-param "Named parameter"
-    ///for getting the shortest path to the target node.
-    ///
-    ///\ref named-func-param "Named parameter"
-    ///for getting the shortest path to the target node.
-    template<class T>
-    DijkstraWizard<SetPathBase<T> > path(const T &t)
-    {
-      Base::_path=reinterpret_cast<void*>(const_cast<T*>(&t));
-      return DijkstraWizard<SetPathBase<T> >(*this);
-    }
-
-    ///\brief \ref named-func-param "Named parameter"
-    ///for getting the distance of the target node.
-    ///
-    ///\ref named-func-param "Named parameter"
-    ///for getting the distance of the target node.
-    DijkstraWizard dist(const Value &d)
-    {
-      Base::_di=reinterpret_cast<void*>(const_cast<Value*>(&d));
-      return *this;
-    }
-
   };
 
-  ///Function-type interface for Dijkstra algorithm.
+  ///Function type interface for Dijkstra algorithm.
 
   /// \ingroup shortest_path
-  ///Function-type interface for Dijkstra algorithm.
+  ///Function type interface for Dijkstra algorithm.
   ///
-  ///This function also has several \ref named-func-param "named parameters",
+  ///This function also has several
+  ///\ref named-templ-func-param "named parameters",
   ///they are declared as the members of class \ref DijkstraWizard.
-  ///The following examples show how to use these parameters.
+  ///The following
+  ///example shows how to use these parameters.
   ///\code
-  ///  // Compute shortest path from node s to each node
-  ///  dijkstra(g,length).predMap(preds).distMap(dists).run(s);
-  ///
-  ///  // Compute shortest path from s to t
-  ///  bool reached = dijkstra(g,length).path(p).dist(d).run(s,t);
+  ///  dijkstra(g,length,source).predMap(preds).run();
   ///\endcode
   ///\warning Don't forget to put the \ref DijkstraWizard::run() "run()"
@@ -1307,7 +1269,7 @@
   template<class GR, class LM>
   DijkstraWizard<DijkstraWizardBase<GR,LM> >
-  dijkstra(const GR &digraph, const LM &length)
+  dijkstra(const GR &g,const LM &l,typename GR::Node s=INVALID)
   {
-    return DijkstraWizard<DijkstraWizardBase<GR,LM> >(digraph,length);
+    return DijkstraWizard<DijkstraWizardBase<GR,LM> >(g,l,s);
   }
 
