Index: lemon/dfs.h
===================================================================
--- lemon/dfs.h	(revision 278)
+++ lemon/dfs.h	(revision 280)
@@ -30,5 +30,4 @@
 #include <lemon/assert.h>
 #include <lemon/maps.h>
-#include <lemon/path.h>
 
 namespace lemon {
@@ -56,5 +55,4 @@
     ///\param g is the digraph, to which we would like to define the
     ///\ref PredMap.
-    ///\todo The digraph alone may be insufficient to initialize
     static PredMap *createPredMap(const Digraph &g)
     {
@@ -66,5 +64,4 @@
     ///The type of the map that indicates which nodes are processed.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    ///By default it is a NullMap.
     typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
     ///Instantiates a \ref ProcessedMap.
@@ -118,5 +115,5 @@
   ///This class provides an efficient implementation of the %DFS algorithm.
   ///
-  ///There is also a \ref dfs() "function-type interface" for the DFS
+  ///There is also a \ref dfs() "function type interface" for the DFS
   ///algorithm, which is convenient in the simplier cases and it can be
   ///used easier.
@@ -197,6 +194,5 @@
     int _stack_head;
 
-    ///Creates the maps if necessary.
-    ///\todo Better memory allocation (instead of new).
+    //Creates the maps if necessary.
     void create_maps()
     {
@@ -777,5 +773,6 @@
     ///arcs of the %DFS 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.
 
@@ -783,8 +780,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();
     }
 
@@ -793,5 +793,4 @@
     ///The type of the map that indicates which nodes are processed.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    ///By default it is a NullMap.
     typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
     ///Instantiates a \ref ProcessedMap.
@@ -828,5 +827,6 @@
     ///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<int> DistMap;
+    ///
+    typedef NullMap<typename Digraph::Node,int> DistMap;
     ///Instantiates a \ref DistMap.
 
@@ -834,14 +834,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 DFS paths.
-
-    ///The type of the DFS 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();
+    }
   };
 
@@ -873,8 +871,6 @@
     //Pointer to the map of distances.
     void *_dist;
-    //Pointer to the DFS path to the target node.
-    void *_path;
-    //Pointer to the distance of the target node.
-    int *_di;
+    //Pointer to the source node.
+    Node _source;
 
     public:
@@ -882,28 +878,42 @@
 
     /// 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).
     DfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0),
-                      _dist(0), _path(0), _di(0) {}
+                      _dist(0), _source(INVALID) {}
 
     /// Constructor.
 
-    /// This constructor requires one parameter,
-    /// 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.
-    DfsWizardBase(const GR &g) :
+    /// \param s The source node.
+    DfsWizardBase(const GR &g, Node s=INVALID) :
       _g(reinterpret_cast<void*>(const_cast<GR*>(&g))),
-      _reached(0), _processed(0), _pred(0), _dist(0),  _path(0), _di(0) {}
+      _reached(0), _processed(0), _pred(0), _dist(0), _source(s) {}
 
   };
 
-  /// Auxiliary class for the function-type interface of DFS algorithm.
-
-  /// This auxiliary class is created to implement the
-  /// \ref dfs() "function-type interface" of \ref Dfs algorithm.
-  /// It does not have own \ref run() method, it uses the functions
-  /// and features of the plain \ref Dfs.
+  /// Auxiliary class for the function type interface of DFS algorithm.
+
+  /// This auxiliary class is created to implement the function type
+  /// interface of \ref Dfs algorithm. It uses the functions and features
+  /// of the plain \ref Dfs, but it is much simpler to use it.
+  /// It should only be used through the \ref dfs() function, which makes
+  /// it easier to use the algorithm.
   ///
-  /// This class should only be used through the \ref dfs() 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 Dfs
+  /// the new class with the modified type comes from
+  /// the original class by using the ::
+  /// operator. In the case of \ref DfsWizard 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 Dfs object, and calls the
+  /// \ref Dfs::run() method of it.
   template<class TR>
   class DfsWizard : public TR
@@ -920,5 +930,5 @@
 
     ///\brief The type of the map that stores the predecessor
-    ///arcs of the DFS paths.
+    ///arcs of the shortest paths.
     typedef typename TR::PredMap PredMap;
     ///\brief The type of the map that stores the distances of the nodes.
@@ -928,6 +938,4 @@
     ///\brief The type of the map that indicates which nodes are processed.
     typedef typename TR::ProcessedMap ProcessedMap;
-    ///The type of the DFS paths
-    typedef typename TR::Path Path;
 
   public:
@@ -940,7 +948,6 @@
     /// Constructor that requires parameters.
     /// These parameters will be the default values for the traits class.
-    /// \param g The digraph the algorithm runs on.
-    DfsWizard(const Digraph &g) :
-      TR(g) {}
+    DfsWizard(const Digraph &g, Node s=INVALID) :
+      TR(g,s) {}
 
     ///Copy constructor
@@ -949,59 +956,41 @@
     ~DfsWizard() {}
 
-    ///Runs DFS algorithm from the given source node.
-
-    ///This method runs DFS algorithm from node \c s
-    ///in order to compute the DFS path to each node.
+    ///Runs DFS algorithm from a source node.
+
+    ///Runs DFS algorithm from a source node.
+    ///The node can be given with the \ref source() function.
+    void run()
+    {
+      if(Base::_source==INVALID) throw UninitializedParameter();
+      Dfs<Digraph,TR> alg(*reinterpret_cast<const Digraph*>(Base::_g));
+      if(Base::_reached)
+        alg.reachedMap(*reinterpret_cast<ReachedMap*>(Base::_reached));
+      if(Base::_processed)
+        alg.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed));
+      if(Base::_pred)
+        alg.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
+      if(Base::_dist)
+        alg.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
+      alg.run(Base::_source);
+    }
+
+    ///Runs DFS algorithm from the given node.
+
+    ///Runs DFS algorithm from the given node.
+    ///\param s is the given source.
     void run(Node s)
     {
-      Dfs<Digraph,TR> alg(*reinterpret_cast<const Digraph*>(Base::_g));
-      if (Base::_pred)
-        alg.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
-      if (Base::_dist)
-        alg.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
-      if (Base::_reached)
-        alg.reachedMap(*reinterpret_cast<ReachedMap*>(Base::_reached));
-      if (Base::_processed)
-        alg.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed));
-      if (s!=INVALID)
-        alg.run(s);
-      else
-        alg.run();
-    }
-
-    ///Finds the DFS path between \c s and \c t.
-
-    ///This method runs DFS algorithm from node \c s
-    ///in order to compute the DFS 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();
-      Dfs<Digraph,TR> alg(*reinterpret_cast<const Digraph*>(Base::_g));
-      if (Base::_pred)
-        alg.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
-      if (Base::_dist)
-        alg.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
-      if (Base::_reached)
-        alg.reachedMap(*reinterpret_cast<ReachedMap*>(Base::_reached));
-      if (Base::_processed)
-        alg.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed));
-      alg.run(s,t);
-      if (Base::_path)
-        *reinterpret_cast<Path*>(Base::_path) = alg.path(t);
-      if (Base::_di)
-        *Base::_di = alg.dist(t);
-      return alg.reached(t);
-      }
-
-    ///Runs DFS algorithm to visit all nodes in the digraph.
-
-    ///This method runs DFS algorithm in order to compute
-    ///the DFS path to each node.
-    void run()
-    {
-      run(INVALID);
+      Base::_source=s;
+      run();
+    }
+
+    /// Sets the source node, from which the Dfs algorithm runs.
+
+    /// Sets the source node, from which the Dfs algorithm runs.
+    /// \param s is the source node.
+    DfsWizard<TR> &source(Node s)
+    {
+      Base::_source=s;
+      return *this;
     }
 
@@ -1012,8 +1001,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>
@@ -1030,8 +1019,8 @@
       SetReachedMapBase(const TR &b) : TR(b) {}
     };
-    ///\brief \ref named-func-param "Named parameter"
+    ///\brief \ref named-templ-param "Named parameter"
     ///for setting \ref ReachedMap object.
     ///
-    /// \ref named-func-param "Named parameter"
+    /// \ref named-templ-param "Named parameter"
     ///for setting \ref ReachedMap object.
     template<class T>
@@ -1040,4 +1029,22 @@
       Base::_reached=reinterpret_cast<void*>(const_cast<T*>(&t));
       return DfsWizard<SetReachedMapBase<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>
+    DfsWizard<SetProcessedMapBase<T> > processedMap(const T &t)
+    {
+      Base::_processed=reinterpret_cast<void*>(const_cast<T*>(&t));
+      return DfsWizard<SetProcessedMapBase<T> >(*this);
     }
 
@@ -1048,8 +1055,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>
@@ -1060,68 +1067,19 @@
     }
 
-    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>
-    DfsWizard<SetProcessedMapBase<T> > processedMap(const T &t)
-    {
-      Base::_processed=reinterpret_cast<void*>(const_cast<T*>(&t));
-      return DfsWizard<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 DFS path to the target node.
-    ///
-    ///\ref named-func-param "Named parameter"
-    ///for getting the DFS path to the target node.
-    template<class T>
-    DfsWizard<SetPathBase<T> > path(const T &t)
-    {
-      Base::_path=reinterpret_cast<void*>(const_cast<T*>(&t));
-      return DfsWizard<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.
-    DfsWizard dist(const int &d)
-    {
-      Base::_di=const_cast<int*>(&d);
-      return *this;
-    }
-
   };
 
-  ///Function-type interface for DFS algorithm.
+  ///Function type interface for Dfs algorithm.
 
   ///\ingroup search
-  ///Function-type interface for DFS algorithm.
+  ///Function type interface for Dfs 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 DfsWizard.
-  ///The following examples show how to use these parameters.
+  ///The following
+  ///example shows how to use these parameters.
   ///\code
-  ///  // Compute the DFS tree
-  ///  dfs(g).predMap(preds).distMap(dists).run(s);
-  ///
-  ///  // Compute the DFS path from s to t
-  ///  bool reached = dfs(g).path(p).dist(d).run(s,t);
+  ///  dfs(g,source).predMap(preds).run();
   ///\endcode
-
   ///\warning Don't forget to put the \ref DfsWizard::run() "run()"
   ///to the end of the parameter list.
@@ -1130,7 +1088,7 @@
   template<class GR>
   DfsWizard<DfsWizardBase<GR> >
-  dfs(const GR &digraph)
+  dfs(const GR &g,typename GR::Node s=INVALID)
   {
-    return DfsWizard<DfsWizardBase<GR> >(digraph);
+    return DfsWizard<DfsWizardBase<GR> >(g,s);
   }
 
@@ -1318,6 +1276,5 @@
     int _stack_head;
 
-    ///Creates the maps if necessary.
-    ///\todo Better memory allocation (instead of new).
+    //Creates the maps if necessary.
     void create_maps() {
       if(!_reached) {
