lemon/bfs.h
changeset 803 1b89e29c9fc7
parent 787 c2230649a493
parent 786 e20173729589
child 825 75e6020b19b1
     1.1 --- a/lemon/bfs.h	Thu Dec 10 17:05:35 2009 +0100
     1.2 +++ b/lemon/bfs.h	Thu Dec 10 17:18:25 2009 +0100
     1.3 @@ -47,7 +47,7 @@
     1.4      ///
     1.5      ///The type of the map that stores the predecessor
     1.6      ///arcs of the shortest paths.
     1.7 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     1.8 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
     1.9      typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
    1.10      ///Instantiates a \c PredMap.
    1.11  
    1.12 @@ -62,7 +62,8 @@
    1.13      ///The type of the map that indicates which nodes are processed.
    1.14  
    1.15      ///The type of the map that indicates which nodes are processed.
    1.16 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    1.17 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    1.18 +    ///By default, it is a NullMap.
    1.19      typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
    1.20      ///Instantiates a \c ProcessedMap.
    1.21  
    1.22 @@ -81,7 +82,7 @@
    1.23      ///The type of the map that indicates which nodes are reached.
    1.24  
    1.25      ///The type of the map that indicates which nodes are reached.
    1.26 -    ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    1.27 +    ///It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    1.28      typedef typename Digraph::template NodeMap<bool> ReachedMap;
    1.29      ///Instantiates a \c ReachedMap.
    1.30  
    1.31 @@ -96,7 +97,7 @@
    1.32      ///The type of the map that stores the distances of the nodes.
    1.33  
    1.34      ///The type of the map that stores the distances of the nodes.
    1.35 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    1.36 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    1.37      typedef typename Digraph::template NodeMap<int> DistMap;
    1.38      ///Instantiates a \c DistMap.
    1.39  
    1.40 @@ -225,7 +226,7 @@
    1.41      ///
    1.42      ///\ref named-templ-param "Named parameter" for setting
    1.43      ///\c PredMap type.
    1.44 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    1.45 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    1.46      template <class T>
    1.47      struct SetPredMap : public Bfs< Digraph, SetPredMapTraits<T> > {
    1.48        typedef Bfs< Digraph, SetPredMapTraits<T> > Create;
    1.49 @@ -245,7 +246,7 @@
    1.50      ///
    1.51      ///\ref named-templ-param "Named parameter" for setting
    1.52      ///\c DistMap type.
    1.53 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    1.54 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    1.55      template <class T>
    1.56      struct SetDistMap : public Bfs< Digraph, SetDistMapTraits<T> > {
    1.57        typedef Bfs< Digraph, SetDistMapTraits<T> > Create;
    1.58 @@ -265,7 +266,7 @@
    1.59      ///
    1.60      ///\ref named-templ-param "Named parameter" for setting
    1.61      ///\c ReachedMap type.
    1.62 -    ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    1.63 +    ///It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    1.64      template <class T>
    1.65      struct SetReachedMap : public Bfs< Digraph, SetReachedMapTraits<T> > {
    1.66        typedef Bfs< Digraph, SetReachedMapTraits<T> > Create;
    1.67 @@ -285,7 +286,7 @@
    1.68      ///
    1.69      ///\ref named-templ-param "Named parameter" for setting
    1.70      ///\c ProcessedMap type.
    1.71 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    1.72 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    1.73      template <class T>
    1.74      struct SetProcessedMap : public Bfs< Digraph, SetProcessedMapTraits<T> > {
    1.75        typedef Bfs< Digraph, SetProcessedMapTraits<T> > Create;
    1.76 @@ -413,8 +414,8 @@
    1.77      ///\name Execution Control
    1.78      ///The simplest way to execute the BFS algorithm is to use one of the
    1.79      ///member functions called \ref run(Node) "run()".\n
    1.80 -    ///If you need more control on the execution, first you have to call
    1.81 -    ///\ref init(), then you can add several source nodes with
    1.82 +    ///If you need better control on the execution, you have to call
    1.83 +    ///\ref init() first, then you can add several source nodes with
    1.84      ///\ref addSource(). Finally the actual path computation can be
    1.85      ///performed with one of the \ref start() functions.
    1.86  
    1.87 @@ -700,12 +701,8 @@
    1.88  
    1.89      ///Runs the algorithm to visit all nodes in the digraph.
    1.90  
    1.91 -    ///This method runs the %BFS algorithm in order to
    1.92 -    ///compute the shortest path to each node.
    1.93 -    ///
    1.94 -    ///The algorithm computes
    1.95 -    ///- the shortest path tree (forest),
    1.96 -    ///- the distance of each node from the root(s).
    1.97 +    ///This method runs the %BFS algorithm in order to visit all nodes
    1.98 +    ///in the digraph.
    1.99      ///
   1.100      ///\note <tt>b.run(s)</tt> is just a shortcut of the following code.
   1.101      ///\code
   1.102 @@ -737,9 +734,9 @@
   1.103  
   1.104      ///@{
   1.105  
   1.106 -    ///The shortest path to a node.
   1.107 +    ///The shortest path to the given node.
   1.108  
   1.109 -    ///Returns the shortest path to a node.
   1.110 +    ///Returns the shortest path to the given node from the root(s).
   1.111      ///
   1.112      ///\warning \c t should be reached from the root(s).
   1.113      ///
   1.114 @@ -747,9 +744,9 @@
   1.115      ///must be called before using this function.
   1.116      Path path(Node t) const { return Path(*G, *_pred, t); }
   1.117  
   1.118 -    ///The distance of a node from the root(s).
   1.119 +    ///The distance of the given node from the root(s).
   1.120  
   1.121 -    ///Returns the distance of a node from the root(s).
   1.122 +    ///Returns the distance of the given node from the root(s).
   1.123      ///
   1.124      ///\warning If node \c v is not reached from the root(s), then
   1.125      ///the return value of this function is undefined.
   1.126 @@ -758,29 +755,31 @@
   1.127      ///must be called before using this function.
   1.128      int dist(Node v) const { return (*_dist)[v]; }
   1.129  
   1.130 -    ///Returns the 'previous arc' of the shortest path tree for a node.
   1.131 -
   1.132 +    ///\brief Returns the 'previous arc' of the shortest path tree for
   1.133 +    ///the given node.
   1.134 +    ///
   1.135      ///This function returns the 'previous arc' of the shortest path
   1.136      ///tree for the node \c v, i.e. it returns the last arc of a
   1.137      ///shortest path from a root to \c v. It is \c INVALID if \c v
   1.138      ///is not reached from the root(s) or if \c v is a root.
   1.139      ///
   1.140      ///The shortest path tree used here is equal to the shortest path
   1.141 -    ///tree used in \ref predNode().
   1.142 +    ///tree used in \ref predNode() and \ref predMap().
   1.143      ///
   1.144      ///\pre Either \ref run(Node) "run()" or \ref init()
   1.145      ///must be called before using this function.
   1.146      Arc predArc(Node v) const { return (*_pred)[v];}
   1.147  
   1.148 -    ///Returns the 'previous node' of the shortest path tree for a node.
   1.149 -
   1.150 +    ///\brief Returns the 'previous node' of the shortest path tree for
   1.151 +    ///the given node.
   1.152 +    ///
   1.153      ///This function returns the 'previous node' of the shortest path
   1.154      ///tree for the node \c v, i.e. it returns the last but one node
   1.155 -    ///from a shortest path from a root to \c v. It is \c INVALID
   1.156 +    ///of a shortest path from a root to \c v. It is \c INVALID
   1.157      ///if \c v is not reached from the root(s) or if \c v is a root.
   1.158      ///
   1.159      ///The shortest path tree used here is equal to the shortest path
   1.160 -    ///tree used in \ref predArc().
   1.161 +    ///tree used in \ref predArc() and \ref predMap().
   1.162      ///
   1.163      ///\pre Either \ref run(Node) "run()" or \ref init()
   1.164      ///must be called before using this function.
   1.165 @@ -801,13 +800,13 @@
   1.166      ///predecessor arcs.
   1.167      ///
   1.168      ///Returns a const reference to the node map that stores the predecessor
   1.169 -    ///arcs, which form the shortest path tree.
   1.170 +    ///arcs, which form the shortest path tree (forest).
   1.171      ///
   1.172      ///\pre Either \ref run(Node) "run()" or \ref init()
   1.173      ///must be called before using this function.
   1.174      const PredMap &predMap() const { return *_pred;}
   1.175  
   1.176 -    ///Checks if a node is reached from the root(s).
   1.177 +    ///Checks if the given node is reached from the root(s).
   1.178  
   1.179      ///Returns \c true if \c v is reached from the root(s).
   1.180      ///
   1.181 @@ -833,7 +832,7 @@
   1.182      ///
   1.183      ///The type of the map that stores the predecessor
   1.184      ///arcs of the shortest paths.
   1.185 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   1.186 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   1.187      typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
   1.188      ///Instantiates a PredMap.
   1.189  
   1.190 @@ -848,8 +847,8 @@
   1.191      ///The type of the map that indicates which nodes are processed.
   1.192  
   1.193      ///The type of the map that indicates which nodes are processed.
   1.194 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   1.195 -    ///By default it is a NullMap.
   1.196 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   1.197 +    ///By default, it is a NullMap.
   1.198      typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
   1.199      ///Instantiates a ProcessedMap.
   1.200  
   1.201 @@ -868,7 +867,7 @@
   1.202      ///The type of the map that indicates which nodes are reached.
   1.203  
   1.204      ///The type of the map that indicates which nodes are reached.
   1.205 -    ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
   1.206 +    ///It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
   1.207      typedef typename Digraph::template NodeMap<bool> ReachedMap;
   1.208      ///Instantiates a ReachedMap.
   1.209  
   1.210 @@ -883,7 +882,7 @@
   1.211      ///The type of the map that stores the distances of the nodes.
   1.212  
   1.213      ///The type of the map that stores the distances of the nodes.
   1.214 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   1.215 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   1.216      typedef typename Digraph::template NodeMap<int> DistMap;
   1.217      ///Instantiates a DistMap.
   1.218  
   1.219 @@ -898,18 +897,14 @@
   1.220      ///The type of the shortest paths.
   1.221  
   1.222      ///The type of the shortest paths.
   1.223 -    ///It must meet the \ref concepts::Path "Path" concept.
   1.224 +    ///It must conform to the \ref concepts::Path "Path" concept.
   1.225      typedef lemon::Path<Digraph> Path;
   1.226    };
   1.227  
   1.228    /// Default traits class used by BfsWizard
   1.229  
   1.230 -  /// To make it easier to use Bfs algorithm
   1.231 -  /// we have created a wizard class.
   1.232 -  /// This \ref BfsWizard class needs default traits,
   1.233 -  /// as well as the \ref Bfs class.
   1.234 -  /// The \ref BfsWizardBase is a class to be the default traits of the
   1.235 -  /// \ref BfsWizard class.
   1.236 +  /// Default traits class used by BfsWizard.
   1.237 +  /// \tparam GR The type of the digraph.
   1.238    template<class GR>
   1.239    class BfsWizardBase : public BfsWizardDefaultTraits<GR>
   1.240    {
   1.241 @@ -937,7 +932,7 @@
   1.242      public:
   1.243      /// Constructor.
   1.244  
   1.245 -    /// This constructor does not require parameters, therefore it initiates
   1.246 +    /// This constructor does not require parameters, it initiates
   1.247      /// all of the attributes to \c 0.
   1.248      BfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0),
   1.249                        _dist(0), _path(0), _di(0) {}
   1.250 @@ -967,7 +962,6 @@
   1.251    {
   1.252      typedef TR Base;
   1.253  
   1.254 -    ///The type of the digraph the algorithm runs on.
   1.255      typedef typename TR::Digraph Digraph;
   1.256  
   1.257      typedef typename Digraph::Node Node;
   1.258 @@ -975,16 +969,10 @@
   1.259      typedef typename Digraph::Arc Arc;
   1.260      typedef typename Digraph::OutArcIt OutArcIt;
   1.261  
   1.262 -    ///\brief The type of the map that stores the predecessor
   1.263 -    ///arcs of the shortest paths.
   1.264      typedef typename TR::PredMap PredMap;
   1.265 -    ///\brief The type of the map that stores the distances of the nodes.
   1.266      typedef typename TR::DistMap DistMap;
   1.267 -    ///\brief The type of the map that indicates which nodes are reached.
   1.268      typedef typename TR::ReachedMap ReachedMap;
   1.269 -    ///\brief The type of the map that indicates which nodes are processed.
   1.270      typedef typename TR::ProcessedMap ProcessedMap;
   1.271 -    ///The type of the shortest paths
   1.272      typedef typename TR::Path Path;
   1.273  
   1.274    public:
   1.275 @@ -1054,8 +1042,8 @@
   1.276  
   1.277      ///Runs BFS algorithm to visit all nodes in the digraph.
   1.278  
   1.279 -    ///This method runs BFS algorithm in order to compute
   1.280 -    ///the shortest path to each node.
   1.281 +    ///This method runs BFS algorithm in order to visit all nodes
   1.282 +    ///in the digraph.
   1.283      void run()
   1.284      {
   1.285        run(INVALID);
   1.286 @@ -1067,11 +1055,12 @@
   1.287        static PredMap *createPredMap(const Digraph &) { return 0; };
   1.288        SetPredMapBase(const TR &b) : TR(b) {}
   1.289      };
   1.290 -    ///\brief \ref named-func-param "Named parameter"
   1.291 -    ///for setting PredMap object.
   1.292 +
   1.293 +    ///\brief \ref named-templ-param "Named parameter" for setting
   1.294 +    ///the predecessor map.
   1.295      ///
   1.296 -    ///\ref named-func-param "Named parameter"
   1.297 -    ///for setting PredMap object.
   1.298 +    ///\ref named-templ-param "Named parameter" function for setting
   1.299 +    ///the map that stores the predecessor arcs of the nodes.
   1.300      template<class T>
   1.301      BfsWizard<SetPredMapBase<T> > predMap(const T &t)
   1.302      {
   1.303 @@ -1085,11 +1074,12 @@
   1.304        static ReachedMap *createReachedMap(const Digraph &) { return 0; };
   1.305        SetReachedMapBase(const TR &b) : TR(b) {}
   1.306      };
   1.307 -    ///\brief \ref named-func-param "Named parameter"
   1.308 -    ///for setting ReachedMap object.
   1.309 +
   1.310 +    ///\brief \ref named-templ-param "Named parameter" for setting
   1.311 +    ///the reached map.
   1.312      ///
   1.313 -    /// \ref named-func-param "Named parameter"
   1.314 -    ///for setting ReachedMap object.
   1.315 +    ///\ref named-templ-param "Named parameter" function for setting
   1.316 +    ///the map that indicates which nodes are reached.
   1.317      template<class T>
   1.318      BfsWizard<SetReachedMapBase<T> > reachedMap(const T &t)
   1.319      {
   1.320 @@ -1103,11 +1093,13 @@
   1.321        static DistMap *createDistMap(const Digraph &) { return 0; };
   1.322        SetDistMapBase(const TR &b) : TR(b) {}
   1.323      };
   1.324 -    ///\brief \ref named-func-param "Named parameter"
   1.325 -    ///for setting DistMap object.
   1.326 +
   1.327 +    ///\brief \ref named-templ-param "Named parameter" for setting
   1.328 +    ///the distance map.
   1.329      ///
   1.330 -    /// \ref named-func-param "Named parameter"
   1.331 -    ///for setting DistMap object.
   1.332 +    ///\ref named-templ-param "Named parameter" function for setting
   1.333 +    ///the map that stores the distances of the nodes calculated
   1.334 +    ///by the algorithm.
   1.335      template<class T>
   1.336      BfsWizard<SetDistMapBase<T> > distMap(const T &t)
   1.337      {
   1.338 @@ -1121,11 +1113,12 @@
   1.339        static ProcessedMap *createProcessedMap(const Digraph &) { return 0; };
   1.340        SetProcessedMapBase(const TR &b) : TR(b) {}
   1.341      };
   1.342 -    ///\brief \ref named-func-param "Named parameter"
   1.343 -    ///for setting ProcessedMap object.
   1.344 +
   1.345 +    ///\brief \ref named-func-param "Named parameter" for setting
   1.346 +    ///the processed map.
   1.347      ///
   1.348 -    /// \ref named-func-param "Named parameter"
   1.349 -    ///for setting ProcessedMap object.
   1.350 +    ///\ref named-templ-param "Named parameter" function for setting
   1.351 +    ///the map that indicates which nodes are processed.
   1.352      template<class T>
   1.353      BfsWizard<SetProcessedMapBase<T> > processedMap(const T &t)
   1.354      {
   1.355 @@ -1264,7 +1257,7 @@
   1.356      /// \brief The type of the map that indicates which nodes are reached.
   1.357      ///
   1.358      /// The type of the map that indicates which nodes are reached.
   1.359 -    /// It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
   1.360 +    /// It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
   1.361      typedef typename Digraph::template NodeMap<bool> ReachedMap;
   1.362  
   1.363      /// \brief Instantiates a ReachedMap.
   1.364 @@ -1425,8 +1418,8 @@
   1.365      /// \name Execution Control
   1.366      /// The simplest way to execute the BFS algorithm is to use one of the
   1.367      /// member functions called \ref run(Node) "run()".\n
   1.368 -    /// If you need more control on the execution, first you have to call
   1.369 -    /// \ref init(), then you can add several source nodes with
   1.370 +    /// If you need better control on the execution, you have to call
   1.371 +    /// \ref init() first, then you can add several source nodes with
   1.372      /// \ref addSource(). Finally the actual path computation can be
   1.373      /// performed with one of the \ref start() functions.
   1.374  
   1.375 @@ -1698,12 +1691,8 @@
   1.376  
   1.377      /// \brief Runs the algorithm to visit all nodes in the digraph.
   1.378      ///
   1.379 -    /// This method runs the %BFS algorithm in order to
   1.380 -    /// compute the shortest path to each node.
   1.381 -    ///
   1.382 -    /// The algorithm computes
   1.383 -    /// - the shortest path tree (forest),
   1.384 -    /// - the distance of each node from the root(s).
   1.385 +    /// This method runs the %BFS algorithm in order to visit all nodes
   1.386 +    /// in the digraph.
   1.387      ///
   1.388      /// \note <tt>b.run(s)</tt> is just a shortcut of the following code.
   1.389      ///\code
   1.390 @@ -1735,7 +1724,7 @@
   1.391  
   1.392      ///@{
   1.393  
   1.394 -    /// \brief Checks if a node is reached from the root(s).
   1.395 +    /// \brief Checks if the given node is reached from the root(s).
   1.396      ///
   1.397      /// Returns \c true if \c v is reached from the root(s).
   1.398      ///