lemon/dfs.h
changeset 278 931190050520
parent 258 0310c8984732
child 281 e9b4fbe163f5
child 286 da414906fe21
equal deleted inserted replaced
10:f51d64d593c2 11:4a912b42f5b3
    27 #include <lemon/bits/path_dump.h>
    27 #include <lemon/bits/path_dump.h>
    28 #include <lemon/core.h>
    28 #include <lemon/core.h>
    29 #include <lemon/error.h>
    29 #include <lemon/error.h>
    30 #include <lemon/assert.h>
    30 #include <lemon/assert.h>
    31 #include <lemon/maps.h>
    31 #include <lemon/maps.h>
       
    32 #include <lemon/path.h>
    32 
    33 
    33 namespace lemon {
    34 namespace lemon {
    34 
    35 
    35   ///Default traits class of Dfs class.
    36   ///Default traits class of Dfs class.
    36 
    37 
   114   ///%DFS algorithm class.
   115   ///%DFS algorithm class.
   115 
   116 
   116   ///\ingroup search
   117   ///\ingroup search
   117   ///This class provides an efficient implementation of the %DFS algorithm.
   118   ///This class provides an efficient implementation of the %DFS algorithm.
   118   ///
   119   ///
   119   ///There is also a \ref dfs() "function type interface" for the DFS
   120   ///There is also a \ref dfs() "function-type interface" for the DFS
   120   ///algorithm, which is convenient in the simplier cases and it can be
   121   ///algorithm, which is convenient in the simplier cases and it can be
   121   ///used easier.
   122   ///used easier.
   122   ///
   123   ///
   123   ///\tparam GR The type of the digraph the algorithm runs on.
   124   ///\tparam GR The type of the digraph the algorithm runs on.
   124   ///The default value is \ref ListDigraph. The value of GR is not used
   125   ///The default value is \ref ListDigraph. The value of GR is not used
   773     ///arcs of the %DFS paths.
   774     ///arcs of the %DFS paths.
   774     ///
   775     ///
   775     ///The type of the map that stores the predecessor
   776     ///The type of the map that stores the predecessor
   776     ///arcs of the %DFS paths.
   777     ///arcs of the %DFS paths.
   777     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   778     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   778     ///
   779     typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
   779     typedef NullMap<typename Digraph::Node,typename Digraph::Arc> PredMap;
       
   780     ///Instantiates a \ref PredMap.
   780     ///Instantiates a \ref PredMap.
   781 
   781 
   782     ///This function instantiates a \ref PredMap.
   782     ///This function instantiates a \ref PredMap.
   783     ///\param g is the digraph, to which we would like to define the
   783     ///\param g is the digraph, to which we would like to define the
   784     ///\ref PredMap.
   784     ///\ref PredMap.
   785     ///\todo The digraph alone may be insufficient to initialize
   785     ///\todo The digraph alone may be insufficient to initialize
   786 #ifdef DOXYGEN
       
   787     static PredMap *createPredMap(const Digraph &g)
   786     static PredMap *createPredMap(const Digraph &g)
   788 #else
   787     {
   789     static PredMap *createPredMap(const Digraph &)
   788       return new PredMap(g);
   790 #endif
       
   791     {
       
   792       return new PredMap();
       
   793     }
   789     }
   794 
   790 
   795     ///The type of the map that indicates which nodes are processed.
   791     ///The type of the map that indicates which nodes are processed.
   796 
   792 
   797     ///The type of the map that indicates which nodes are processed.
   793     ///The type of the map that indicates which nodes are processed.
   798     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   794     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
       
   795     ///By default it is a NullMap.
   799     typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
   796     typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
   800     ///Instantiates a \ref ProcessedMap.
   797     ///Instantiates a \ref ProcessedMap.
   801 
   798 
   802     ///This function instantiates a \ref ProcessedMap.
   799     ///This function instantiates a \ref ProcessedMap.
   803     ///\param g is the digraph, to which
   800     ///\param g is the digraph, to which
   828 
   825 
   829     ///The type of the map that stores the distances of the nodes.
   826     ///The type of the map that stores the distances of the nodes.
   830 
   827 
   831     ///The type of the map that stores the distances of the nodes.
   828     ///The type of the map that stores the distances of the nodes.
   832     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   829     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   833     ///
   830     typedef typename Digraph::template NodeMap<int> DistMap;
   834     typedef NullMap<typename Digraph::Node,int> DistMap;
       
   835     ///Instantiates a \ref DistMap.
   831     ///Instantiates a \ref DistMap.
   836 
   832 
   837     ///This function instantiates a \ref DistMap.
   833     ///This function instantiates a \ref DistMap.
   838     ///\param g is the digraph, to which we would like to define
   834     ///\param g is the digraph, to which we would like to define
   839     ///the \ref DistMap
   835     ///the \ref DistMap
   840 #ifdef DOXYGEN
       
   841     static DistMap *createDistMap(const Digraph &g)
   836     static DistMap *createDistMap(const Digraph &g)
   842 #else
   837     {
   843     static DistMap *createDistMap(const Digraph &)
   838       return new DistMap(g);
   844 #endif
   839     }
   845     {
   840 
   846       return new DistMap();
   841     ///The type of the DFS paths.
   847     }
   842 
       
   843     ///The type of the DFS paths.
       
   844     ///It must meet the \ref concepts::Path "Path" concept.
       
   845     typedef lemon::Path<Digraph> Path;
   848   };
   846   };
   849 
   847 
   850   /// Default traits class used by \ref DfsWizard
   848   /// Default traits class used by \ref DfsWizard
   851 
   849 
   852   /// To make it easier to use Dfs algorithm
   850   /// To make it easier to use Dfs algorithm
   872     void *_processed;
   870     void *_processed;
   873     //Pointer to the map of predecessors arcs.
   871     //Pointer to the map of predecessors arcs.
   874     void *_pred;
   872     void *_pred;
   875     //Pointer to the map of distances.
   873     //Pointer to the map of distances.
   876     void *_dist;
   874     void *_dist;
   877     //Pointer to the source node.
   875     //Pointer to the DFS path to the target node.
   878     Node _source;
   876     void *_path;
       
   877     //Pointer to the distance of the target node.
       
   878     int *_di;
   879 
   879 
   880     public:
   880     public:
   881     /// Constructor.
   881     /// Constructor.
   882 
   882 
   883     /// This constructor does not require parameters, therefore it initiates
   883     /// This constructor does not require parameters, therefore it initiates
   884     /// all of the attributes to default values (0, INVALID).
   884     /// all of the attributes to \c 0.
   885     DfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0),
   885     DfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0),
   886                       _dist(0), _source(INVALID) {}
   886                       _dist(0), _path(0), _di(0) {}
   887 
   887 
   888     /// Constructor.
   888     /// Constructor.
   889 
   889 
   890     /// This constructor requires some parameters,
   890     /// This constructor requires one parameter,
   891     /// listed in the parameters list.
   891     /// others are initiated to \c 0.
   892     /// Others are initiated to 0.
       
   893     /// \param g The digraph the algorithm runs on.
   892     /// \param g The digraph the algorithm runs on.
   894     /// \param s The source node.
   893     DfsWizardBase(const GR &g) :
   895     DfsWizardBase(const GR &g, Node s=INVALID) :
       
   896       _g(reinterpret_cast<void*>(const_cast<GR*>(&g))),
   894       _g(reinterpret_cast<void*>(const_cast<GR*>(&g))),
   897       _reached(0), _processed(0), _pred(0), _dist(0), _source(s) {}
   895       _reached(0), _processed(0), _pred(0), _dist(0),  _path(0), _di(0) {}
   898 
   896 
   899   };
   897   };
   900 
   898 
   901   /// Auxiliary class for the function type interface of DFS algorithm.
   899   /// Auxiliary class for the function-type interface of DFS algorithm.
   902 
   900 
   903   /// This auxiliary class is created to implement the function type
   901   /// This auxiliary class is created to implement the
   904   /// interface of \ref Dfs algorithm. It uses the functions and features
   902   /// \ref dfs() "function-type interface" of \ref Dfs algorithm.
   905   /// of the plain \ref Dfs, but it is much simpler to use it.
   903   /// It does not have own \ref run() method, it uses the functions
   906   /// It should only be used through the \ref dfs() function, which makes
   904   /// and features of the plain \ref Dfs.
   907   /// it easier to use the algorithm.
       
   908   ///
   905   ///
   909   /// Simplicity means that the way to change the types defined
   906   /// This class should only be used through the \ref dfs() function,
   910   /// in the traits class is based on functions that returns the new class
   907   /// which makes it easier to use the algorithm.
   911   /// and not on templatable built-in classes.
       
   912   /// When using the plain \ref Dfs
       
   913   /// the new class with the modified type comes from
       
   914   /// the original class by using the ::
       
   915   /// operator. In the case of \ref DfsWizard only
       
   916   /// a function have to be called, and it will
       
   917   /// return the needed class.
       
   918   ///
       
   919   /// It does not have own \ref run() method. When its \ref run() method
       
   920   /// is called, it initiates a plain \ref Dfs object, and calls the
       
   921   /// \ref Dfs::run() method of it.
       
   922   template<class TR>
   908   template<class TR>
   923   class DfsWizard : public TR
   909   class DfsWizard : public TR
   924   {
   910   {
   925     typedef TR Base;
   911     typedef TR Base;
   926 
   912 
   931     typedef typename Digraph::NodeIt NodeIt;
   917     typedef typename Digraph::NodeIt NodeIt;
   932     typedef typename Digraph::Arc Arc;
   918     typedef typename Digraph::Arc Arc;
   933     typedef typename Digraph::OutArcIt OutArcIt;
   919     typedef typename Digraph::OutArcIt OutArcIt;
   934 
   920 
   935     ///\brief The type of the map that stores the predecessor
   921     ///\brief The type of the map that stores the predecessor
   936     ///arcs of the shortest paths.
   922     ///arcs of the DFS paths.
   937     typedef typename TR::PredMap PredMap;
   923     typedef typename TR::PredMap PredMap;
   938     ///\brief The type of the map that stores the distances of the nodes.
   924     ///\brief The type of the map that stores the distances of the nodes.
   939     typedef typename TR::DistMap DistMap;
   925     typedef typename TR::DistMap DistMap;
   940     ///\brief The type of the map that indicates which nodes are reached.
   926     ///\brief The type of the map that indicates which nodes are reached.
   941     typedef typename TR::ReachedMap ReachedMap;
   927     typedef typename TR::ReachedMap ReachedMap;
   942     ///\brief The type of the map that indicates which nodes are processed.
   928     ///\brief The type of the map that indicates which nodes are processed.
   943     typedef typename TR::ProcessedMap ProcessedMap;
   929     typedef typename TR::ProcessedMap ProcessedMap;
       
   930     ///The type of the DFS paths
       
   931     typedef typename TR::Path Path;
   944 
   932 
   945   public:
   933   public:
   946 
   934 
   947     /// Constructor.
   935     /// Constructor.
   948     DfsWizard() : TR() {}
   936     DfsWizard() : TR() {}
   949 
   937 
   950     /// Constructor that requires parameters.
   938     /// Constructor that requires parameters.
   951 
   939 
   952     /// Constructor that requires parameters.
   940     /// Constructor that requires parameters.
   953     /// These parameters will be the default values for the traits class.
   941     /// These parameters will be the default values for the traits class.
   954     DfsWizard(const Digraph &g, Node s=INVALID) :
   942     /// \param g The digraph the algorithm runs on.
   955       TR(g,s) {}
   943     DfsWizard(const Digraph &g) :
       
   944       TR(g) {}
   956 
   945 
   957     ///Copy constructor
   946     ///Copy constructor
   958     DfsWizard(const TR &b) : TR(b) {}
   947     DfsWizard(const TR &b) : TR(b) {}
   959 
   948 
   960     ~DfsWizard() {}
   949     ~DfsWizard() {}
   961 
   950 
   962     ///Runs DFS algorithm from a source node.
   951     ///Runs DFS algorithm from the given source node.
   963 
   952 
   964     ///Runs DFS algorithm from a source node.
   953     ///This method runs DFS algorithm from node \c s
   965     ///The node can be given with the \ref source() function.
   954     ///in order to compute the DFS path to each node.
       
   955     void run(Node s)
       
   956     {
       
   957       Dfs<Digraph,TR> alg(*reinterpret_cast<const Digraph*>(Base::_g));
       
   958       if (Base::_pred)
       
   959         alg.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
       
   960       if (Base::_dist)
       
   961         alg.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
       
   962       if (Base::_reached)
       
   963         alg.reachedMap(*reinterpret_cast<ReachedMap*>(Base::_reached));
       
   964       if (Base::_processed)
       
   965         alg.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed));
       
   966       if (s!=INVALID)
       
   967         alg.run(s);
       
   968       else
       
   969         alg.run();
       
   970     }
       
   971 
       
   972     ///Finds the DFS path between \c s and \c t.
       
   973 
       
   974     ///This method runs DFS algorithm from node \c s
       
   975     ///in order to compute the DFS path to node \c t
       
   976     ///(it stops searching when \c t is processed).
       
   977     ///
       
   978     ///\return \c true if \c t is reachable form \c s.
       
   979     bool run(Node s, Node t)
       
   980     {
       
   981       if (s==INVALID || t==INVALID) throw UninitializedParameter();
       
   982       Dfs<Digraph,TR> alg(*reinterpret_cast<const Digraph*>(Base::_g));
       
   983       if (Base::_pred)
       
   984         alg.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
       
   985       if (Base::_dist)
       
   986         alg.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
       
   987       if (Base::_reached)
       
   988         alg.reachedMap(*reinterpret_cast<ReachedMap*>(Base::_reached));
       
   989       if (Base::_processed)
       
   990         alg.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed));
       
   991       alg.run(s,t);
       
   992       if (Base::_path)
       
   993         *reinterpret_cast<Path*>(Base::_path) = alg.path(t);
       
   994       if (Base::_di)
       
   995         *Base::_di = alg.dist(t);
       
   996       return alg.reached(t);
       
   997       }
       
   998 
       
   999     ///Runs DFS algorithm to visit all nodes in the digraph.
       
  1000 
       
  1001     ///This method runs DFS algorithm in order to compute
       
  1002     ///the DFS path to each node.
   966     void run()
  1003     void run()
   967     {
  1004     {
   968       if(Base::_source==INVALID) throw UninitializedParameter();
  1005       run(INVALID);
   969       Dfs<Digraph,TR> alg(*reinterpret_cast<const Digraph*>(Base::_g));
       
   970       if(Base::_reached)
       
   971         alg.reachedMap(*reinterpret_cast<ReachedMap*>(Base::_reached));
       
   972       if(Base::_processed)
       
   973         alg.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed));
       
   974       if(Base::_pred)
       
   975         alg.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
       
   976       if(Base::_dist)
       
   977         alg.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
       
   978       alg.run(Base::_source);
       
   979     }
       
   980 
       
   981     ///Runs DFS algorithm from the given node.
       
   982 
       
   983     ///Runs DFS algorithm from the given node.
       
   984     ///\param s is the given source.
       
   985     void run(Node s)
       
   986     {
       
   987       Base::_source=s;
       
   988       run();
       
   989     }
       
   990 
       
   991     /// Sets the source node, from which the Dfs algorithm runs.
       
   992 
       
   993     /// Sets the source node, from which the Dfs algorithm runs.
       
   994     /// \param s is the source node.
       
   995     DfsWizard<TR> &source(Node s)
       
   996     {
       
   997       Base::_source=s;
       
   998       return *this;
       
   999     }
  1006     }
  1000 
  1007 
  1001     template<class T>
  1008     template<class T>
  1002     struct SetPredMapBase : public Base {
  1009     struct SetPredMapBase : public Base {
  1003       typedef T PredMap;
  1010       typedef T PredMap;
  1004       static PredMap *createPredMap(const Digraph &) { return 0; };
  1011       static PredMap *createPredMap(const Digraph &) { return 0; };
  1005       SetPredMapBase(const TR &b) : TR(b) {}
  1012       SetPredMapBase(const TR &b) : TR(b) {}
  1006     };
  1013     };
  1007     ///\brief \ref named-templ-param "Named parameter"
  1014     ///\brief \ref named-func-param "Named parameter"
  1008     ///for setting \ref PredMap object.
  1015     ///for setting \ref PredMap object.
  1009     ///
  1016     ///
  1010     ///\ref named-templ-param "Named parameter"
  1017     ///\ref named-func-param "Named parameter"
  1011     ///for setting \ref PredMap object.
  1018     ///for setting \ref PredMap object.
  1012     template<class T>
  1019     template<class T>
  1013     DfsWizard<SetPredMapBase<T> > predMap(const T &t)
  1020     DfsWizard<SetPredMapBase<T> > predMap(const T &t)
  1014     {
  1021     {
  1015       Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t));
  1022       Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t));
  1020     struct SetReachedMapBase : public Base {
  1027     struct SetReachedMapBase : public Base {
  1021       typedef T ReachedMap;
  1028       typedef T ReachedMap;
  1022       static ReachedMap *createReachedMap(const Digraph &) { return 0; };
  1029       static ReachedMap *createReachedMap(const Digraph &) { return 0; };
  1023       SetReachedMapBase(const TR &b) : TR(b) {}
  1030       SetReachedMapBase(const TR &b) : TR(b) {}
  1024     };
  1031     };
  1025     ///\brief \ref named-templ-param "Named parameter"
  1032     ///\brief \ref named-func-param "Named parameter"
  1026     ///for setting \ref ReachedMap object.
  1033     ///for setting \ref ReachedMap object.
  1027     ///
  1034     ///
  1028     /// \ref named-templ-param "Named parameter"
  1035     /// \ref named-func-param "Named parameter"
  1029     ///for setting \ref ReachedMap object.
  1036     ///for setting \ref ReachedMap object.
  1030     template<class T>
  1037     template<class T>
  1031     DfsWizard<SetReachedMapBase<T> > reachedMap(const T &t)
  1038     DfsWizard<SetReachedMapBase<T> > reachedMap(const T &t)
  1032     {
  1039     {
  1033       Base::_reached=reinterpret_cast<void*>(const_cast<T*>(&t));
  1040       Base::_reached=reinterpret_cast<void*>(const_cast<T*>(&t));
  1034       return DfsWizard<SetReachedMapBase<T> >(*this);
  1041       return DfsWizard<SetReachedMapBase<T> >(*this);
       
  1042     }
       
  1043 
       
  1044     template<class T>
       
  1045     struct SetDistMapBase : public Base {
       
  1046       typedef T DistMap;
       
  1047       static DistMap *createDistMap(const Digraph &) { return 0; };
       
  1048       SetDistMapBase(const TR &b) : TR(b) {}
       
  1049     };
       
  1050     ///\brief \ref named-func-param "Named parameter"
       
  1051     ///for setting \ref DistMap object.
       
  1052     ///
       
  1053     /// \ref named-func-param "Named parameter"
       
  1054     ///for setting \ref DistMap object.
       
  1055     template<class T>
       
  1056     DfsWizard<SetDistMapBase<T> > distMap(const T &t)
       
  1057     {
       
  1058       Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t));
       
  1059       return DfsWizard<SetDistMapBase<T> >(*this);
  1035     }
  1060     }
  1036 
  1061 
  1037     template<class T>
  1062     template<class T>
  1038     struct SetProcessedMapBase : public Base {
  1063     struct SetProcessedMapBase : public Base {
  1039       typedef T ProcessedMap;
  1064       typedef T ProcessedMap;
  1040       static ProcessedMap *createProcessedMap(const Digraph &) { return 0; };
  1065       static ProcessedMap *createProcessedMap(const Digraph &) { return 0; };
  1041       SetProcessedMapBase(const TR &b) : TR(b) {}
  1066       SetProcessedMapBase(const TR &b) : TR(b) {}
  1042     };
  1067     };
  1043     ///\brief \ref named-templ-param "Named parameter"
  1068     ///\brief \ref named-func-param "Named parameter"
  1044     ///for setting \ref ProcessedMap object.
  1069     ///for setting \ref ProcessedMap object.
  1045     ///
  1070     ///
  1046     /// \ref named-templ-param "Named parameter"
  1071     /// \ref named-func-param "Named parameter"
  1047     ///for setting \ref ProcessedMap object.
  1072     ///for setting \ref ProcessedMap object.
  1048     template<class T>
  1073     template<class T>
  1049     DfsWizard<SetProcessedMapBase<T> > processedMap(const T &t)
  1074     DfsWizard<SetProcessedMapBase<T> > processedMap(const T &t)
  1050     {
  1075     {
  1051       Base::_processed=reinterpret_cast<void*>(const_cast<T*>(&t));
  1076       Base::_processed=reinterpret_cast<void*>(const_cast<T*>(&t));
  1052       return DfsWizard<SetProcessedMapBase<T> >(*this);
  1077       return DfsWizard<SetProcessedMapBase<T> >(*this);
  1053     }
  1078     }
  1054 
  1079 
  1055     template<class T>
  1080     template<class T>
  1056     struct SetDistMapBase : public Base {
  1081     struct SetPathBase : public Base {
  1057       typedef T DistMap;
  1082       typedef T Path;
  1058       static DistMap *createDistMap(const Digraph &) { return 0; };
  1083       SetPathBase(const TR &b) : TR(b) {}
  1059       SetDistMapBase(const TR &b) : TR(b) {}
  1084     };
  1060     };
  1085     ///\brief \ref named-func-param "Named parameter"
  1061     ///\brief \ref named-templ-param "Named parameter"
  1086     ///for getting the DFS path to the target node.
  1062     ///for setting \ref DistMap object.
  1087     ///
  1063     ///
  1088     ///\ref named-func-param "Named parameter"
  1064     ///\ref named-templ-param "Named parameter"
  1089     ///for getting the DFS path to the target node.
  1065     ///for setting \ref DistMap object.
       
  1066     template<class T>
  1090     template<class T>
  1067     DfsWizard<SetDistMapBase<T> > distMap(const T &t)
  1091     DfsWizard<SetPathBase<T> > path(const T &t)
  1068     {
  1092     {
  1069       Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t));
  1093       Base::_path=reinterpret_cast<void*>(const_cast<T*>(&t));
  1070       return DfsWizard<SetDistMapBase<T> >(*this);
  1094       return DfsWizard<SetPathBase<T> >(*this);
       
  1095     }
       
  1096 
       
  1097     ///\brief \ref named-func-param "Named parameter"
       
  1098     ///for getting the distance of the target node.
       
  1099     ///
       
  1100     ///\ref named-func-param "Named parameter"
       
  1101     ///for getting the distance of the target node.
       
  1102     DfsWizard dist(const int &d)
       
  1103     {
       
  1104       Base::_di=const_cast<int*>(&d);
       
  1105       return *this;
  1071     }
  1106     }
  1072 
  1107 
  1073   };
  1108   };
  1074 
  1109 
  1075   ///Function type interface for Dfs algorithm.
  1110   ///Function-type interface for DFS algorithm.
  1076 
  1111 
  1077   ///\ingroup search
  1112   ///\ingroup search
  1078   ///Function type interface for Dfs algorithm.
  1113   ///Function-type interface for DFS algorithm.
  1079   ///
  1114   ///
  1080   ///This function also has several
  1115   ///This function also has several \ref named-func-param "named parameters",
  1081   ///\ref named-templ-func-param "named parameters",
       
  1082   ///they are declared as the members of class \ref DfsWizard.
  1116   ///they are declared as the members of class \ref DfsWizard.
  1083   ///The following
  1117   ///The following examples show how to use these parameters.
  1084   ///example shows how to use these parameters.
       
  1085   ///\code
  1118   ///\code
  1086   ///  dfs(g,source).predMap(preds).run();
  1119   ///  // Compute the DFS tree
       
  1120   ///  dfs(g).predMap(preds).distMap(dists).run(s);
       
  1121   ///
       
  1122   ///  // Compute the DFS path from s to t
       
  1123   ///  bool reached = dfs(g).path(p).dist(d).run(s,t);
  1087   ///\endcode
  1124   ///\endcode
       
  1125 
  1088   ///\warning Don't forget to put the \ref DfsWizard::run() "run()"
  1126   ///\warning Don't forget to put the \ref DfsWizard::run() "run()"
  1089   ///to the end of the parameter list.
  1127   ///to the end of the parameter list.
  1090   ///\sa DfsWizard
  1128   ///\sa DfsWizard
  1091   ///\sa Dfs
  1129   ///\sa Dfs
  1092   template<class GR>
  1130   template<class GR>
  1093   DfsWizard<DfsWizardBase<GR> >
  1131   DfsWizard<DfsWizardBase<GR> >
  1094   dfs(const GR &g,typename GR::Node s=INVALID)
  1132   dfs(const GR &digraph)
  1095   {
  1133   {
  1096     return DfsWizard<DfsWizardBase<GR> >(g,s);
  1134     return DfsWizard<DfsWizardBase<GR> >(digraph);
  1097   }
  1135   }
  1098 
  1136 
  1099 #ifdef DOXYGEN
  1137 #ifdef DOXYGEN
  1100   /// \brief Visitor class for DFS.
  1138   /// \brief Visitor class for DFS.
  1101   ///
  1139   ///