COIN-OR::LEMON - Graph Library

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/bfs.h

    r301 r956  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2010
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    4848    ///The type of the map that stores the predecessor
    4949    ///arcs of the shortest paths.
    50     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     50    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    5151    typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
    52     ///Instantiates a PredMap.
    53 
    54     ///This function instantiates a PredMap.
     52    ///Instantiates a \c PredMap.
     53
     54    ///This function instantiates a \ref PredMap.
    5555    ///\param g is the digraph, to which we would like to define the
    56     ///PredMap.
     56    ///\ref PredMap.
    5757    static PredMap *createPredMap(const Digraph &g)
    5858    {
     
    6363
    6464    ///The type of the map that indicates which nodes are processed.
    65     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     65    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
     66    ///By default, it is a NullMap.
    6667    typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
    67     ///Instantiates a ProcessedMap.
    68 
    69     ///This function instantiates a ProcessedMap.
     68    ///Instantiates a \c ProcessedMap.
     69
     70    ///This function instantiates a \ref ProcessedMap.
    7071    ///\param g is the digraph, to which
    71     ///we would like to define the ProcessedMap
     72    ///we would like to define the \ref ProcessedMap
    7273#ifdef DOXYGEN
    7374    static ProcessedMap *createProcessedMap(const Digraph &g)
     
    8283
    8384    ///The type of the map that indicates which nodes are reached.
    84     ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     85    ///It must conform to
     86    ///the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    8587    typedef typename Digraph::template NodeMap<bool> ReachedMap;
    86     ///Instantiates a ReachedMap.
    87 
    88     ///This function instantiates a ReachedMap.
     88    ///Instantiates a \c ReachedMap.
     89
     90    ///This function instantiates a \ref ReachedMap.
    8991    ///\param g is the digraph, to which
    90     ///we would like to define the ReachedMap.
     92    ///we would like to define the \ref ReachedMap.
    9193    static ReachedMap *createReachedMap(const Digraph &g)
    9294    {
     
    9799
    98100    ///The type of the map that stores the distances of the nodes.
    99     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     101    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    100102    typedef typename Digraph::template NodeMap<int> DistMap;
    101     ///Instantiates a DistMap.
    102 
    103     ///This function instantiates a DistMap.
     103    ///Instantiates a \c DistMap.
     104
     105    ///This function instantiates a \ref DistMap.
    104106    ///\param g is the digraph, to which we would like to define the
    105     ///DistMap.
     107    ///\ref DistMap.
    106108    static DistMap *createDistMap(const Digraph &g)
    107109    {
     
    120122  ///
    121123  ///\tparam GR The type of the digraph the algorithm runs on.
    122   ///The default value is \ref ListDigraph. The value of GR is not used
    123   ///directly by \ref Bfs, it is only passed to \ref BfsDefaultTraits.
    124   ///\tparam TR Traits class to set various data types used by the algorithm.
    125   ///The default traits class is
    126   ///\ref BfsDefaultTraits "BfsDefaultTraits<GR>".
    127   ///See \ref BfsDefaultTraits for the documentation of
    128   ///a Bfs traits class.
     124  ///The default type is \ref ListDigraph.
     125  ///\tparam TR The traits class that defines various types used by the
     126  ///algorithm. By default, it is \ref BfsDefaultTraits
     127  ///"BfsDefaultTraits<GR>".
     128  ///In most cases, this parameter should not be set directly,
     129  ///consider to use the named template parameters instead.
    129130#ifdef DOXYGEN
    130131  template <typename GR,
     
    152153    typedef PredMapPath<Digraph, PredMap> Path;
    153154
    154     ///The traits class.
     155    ///The \ref BfsDefaultTraits "traits class" of the algorithm.
    155156    typedef TR Traits;
    156157
     
    214215    typedef Bfs Create;
    215216
    216     ///\name Named template parameters
     217    ///\name Named Template Parameters
    217218
    218219    ///@{
     
    228229    };
    229230    ///\brief \ref named-templ-param "Named parameter" for setting
    230     ///PredMap type.
     231    ///\c PredMap type.
    231232    ///
    232233    ///\ref named-templ-param "Named parameter" for setting
    233     ///PredMap type.
     234    ///\c PredMap type.
     235    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    234236    template <class T>
    235237    struct SetPredMap : public Bfs< Digraph, SetPredMapTraits<T> > {
     
    247249    };
    248250    ///\brief \ref named-templ-param "Named parameter" for setting
    249     ///DistMap type.
     251    ///\c DistMap type.
    250252    ///
    251253    ///\ref named-templ-param "Named parameter" for setting
    252     ///DistMap type.
     254    ///\c DistMap type.
     255    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    253256    template <class T>
    254257    struct SetDistMap : public Bfs< Digraph, SetDistMapTraits<T> > {
     
    266269    };
    267270    ///\brief \ref named-templ-param "Named parameter" for setting
    268     ///ReachedMap type.
     271    ///\c ReachedMap type.
    269272    ///
    270273    ///\ref named-templ-param "Named parameter" for setting
    271     ///ReachedMap type.
     274    ///\c ReachedMap type.
     275    ///It must conform to
     276    ///the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    272277    template <class T>
    273278    struct SetReachedMap : public Bfs< Digraph, SetReachedMapTraits<T> > {
     
    285290    };
    286291    ///\brief \ref named-templ-param "Named parameter" for setting
    287     ///ProcessedMap type.
     292    ///\c ProcessedMap type.
    288293    ///
    289294    ///\ref named-templ-param "Named parameter" for setting
    290     ///ProcessedMap type.
     295    ///\c ProcessedMap type.
     296    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    291297    template <class T>
    292298    struct SetProcessedMap : public Bfs< Digraph, SetProcessedMapTraits<T> > {
     
    303309    };
    304310    ///\brief \ref named-templ-param "Named parameter" for setting
    305     ///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.
     311    ///\c ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.
    306312    ///
    307313    ///\ref named-templ-param "Named parameter" for setting
    308     ///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.
     314    ///\c ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.
    309315    ///If you don't set it explicitly, it will be automatically allocated.
    310316    struct SetStandardProcessedMap :
     
    341347
    342348    ///Sets the map that stores the predecessor arcs.
    343     ///If you don't use this function before calling \ref run(),
    344     ///it will allocate one. The destructor deallocates this
    345     ///automatically allocated map, of course.
     349    ///If you don't use this function before calling \ref run(Node) "run()"
     350    ///or \ref init(), an instance will be allocated automatically.
     351    ///The destructor deallocates this automatically allocated map,
     352    ///of course.
    346353    ///\return <tt> (*this) </tt>
    347354    Bfs &predMap(PredMap &m)
     
    358365
    359366    ///Sets the map that indicates which nodes are reached.
    360     ///If you don't use this function before calling \ref run(),
    361     ///it will allocate one. The destructor deallocates this
    362     ///automatically allocated map, of course.
     367    ///If you don't use this function before calling \ref run(Node) "run()"
     368    ///or \ref init(), an instance will be allocated automatically.
     369    ///The destructor deallocates this automatically allocated map,
     370    ///of course.
    363371    ///\return <tt> (*this) </tt>
    364372    Bfs &reachedMap(ReachedMap &m)
     
    375383
    376384    ///Sets the map that indicates which nodes are processed.
    377     ///If you don't use this function before calling \ref run(),
    378     ///it will allocate one. The destructor deallocates this
    379     ///automatically allocated map, of course.
     385    ///If you don't use this function before calling \ref run(Node) "run()"
     386    ///or \ref init(), an instance will be allocated automatically.
     387    ///The destructor deallocates this automatically allocated map,
     388    ///of course.
    380389    ///\return <tt> (*this) </tt>
    381390    Bfs &processedMap(ProcessedMap &m)
     
    393402    ///Sets the map that stores the distances of the nodes calculated by
    394403    ///the algorithm.
    395     ///If you don't use this function before calling \ref run(),
    396     ///it will allocate one. The destructor deallocates this
    397     ///automatically allocated map, of course.
     404    ///If you don't use this function before calling \ref run(Node) "run()"
     405    ///or \ref init(), an instance will be allocated automatically.
     406    ///The destructor deallocates this automatically allocated map,
     407    ///of course.
    398408    ///\return <tt> (*this) </tt>
    399409    Bfs &distMap(DistMap &m)
     
    409419  public:
    410420
    411     ///\name Execution control
    412     ///The simplest way to execute the algorithm is to use
    413     ///one of the member functions called \ref lemon::Bfs::run() "run()".
    414     ///\n
    415     ///If you need more control on the execution, first you must call
    416     ///\ref lemon::Bfs::init() "init()", then you can add several source
    417     ///nodes with \ref lemon::Bfs::addSource() "addSource()".
    418     ///Finally \ref lemon::Bfs::start() "start()" will perform the
    419     ///actual path computation.
     421    ///\name Execution Control
     422    ///The simplest way to execute the BFS algorithm is to use one of the
     423    ///member functions called \ref run(Node) "run()".\n
     424    ///If you need better control on the execution, you have to call
     425    ///\ref init() first, then you can add several source nodes with
     426    ///\ref addSource(). Finally the actual path computation can be
     427    ///performed with one of the \ref start() functions.
    420428
    421429    ///@{
    422430
     431    ///\brief Initializes the internal data structures.
     432    ///
    423433    ///Initializes the internal data structures.
    424 
    425     ///Initializes the internal data structures.
    426     ///
    427434    void init()
    428435    {
     
    558565    }
    559566
    560     ///\brief Returns \c false if there are nodes
    561     ///to be processed.
    562     ///
    563     ///Returns \c false if there are nodes
    564     ///to be processed in the queue.
     567    ///Returns \c false if there are nodes to be processed.
     568
     569    ///Returns \c false if there are nodes to be processed
     570    ///in the queue.
    565571    bool emptyQueue() const { return _queue_tail==_queue_head; }
    566572
    567573    ///Returns the number of the nodes to be processed.
    568574
    569     ///Returns the number of the nodes to be processed in the queue.
     575    ///Returns the number of the nodes to be processed
     576    ///in the queue.
    570577    int queueSize() const { return _queue_head-_queue_tail; }
    571578
     
    702709    ///Runs the algorithm to visit all nodes in the digraph.
    703710
    704     ///This method runs the %BFS algorithm in order to
    705     ///compute the shortest path to each node.
    706     ///
    707     ///The algorithm computes
    708     ///- the shortest path tree (forest),
    709     ///- the distance of each node from the root(s).
     711    ///This method runs the %BFS algorithm in order to visit all nodes
     712    ///in the digraph.
    710713    ///
    711714    ///\note <tt>b.run(s)</tt> is just a shortcut of the following code.
     
    732735
    733736    ///\name Query Functions
    734     ///The result of the %BFS algorithm can be obtained using these
     737    ///The results of the BFS algorithm can be obtained using these
    735738    ///functions.\n
    736     ///Either \ref lemon::Bfs::run() "run()" or \ref lemon::Bfs::start()
    737     ///"start()" must be called before using them.
     739    ///Either \ref run(Node) "run()" or \ref start() should be called
     740    ///before using them.
    738741
    739742    ///@{
    740743
    741     ///The shortest path to a node.
    742 
    743     ///Returns the shortest path to a node.
    744     ///
    745     ///\warning \c t should be reachable from the root(s).
    746     ///
    747     ///\pre Either \ref run() or \ref start() must be called before
    748     ///using this function.
     744    ///The shortest path to the given node.
     745
     746    ///Returns the shortest path to the given node from the root(s).
     747    ///
     748    ///\warning \c t should be reached from the root(s).
     749    ///
     750    ///\pre Either \ref run(Node) "run()" or \ref init()
     751    ///must be called before using this function.
    749752    Path path(Node t) const { return Path(*G, *_pred, t); }
    750753
    751     ///The distance of a node from the root(s).
    752 
    753     ///Returns the distance of a node from the root(s).
    754     ///
    755     ///\warning If node \c v is not reachable from the root(s), then
     754    ///The distance of the given node from the root(s).
     755
     756    ///Returns the distance of the given node from the root(s).
     757    ///
     758    ///\warning If node \c v is not reached from the root(s), then
    756759    ///the return value of this function is undefined.
    757760    ///
    758     ///\pre Either \ref run() or \ref start() must be called before
    759     ///using this function.
     761    ///\pre Either \ref run(Node) "run()" or \ref init()
     762    ///must be called before using this function.
    760763    int dist(Node v) const { return (*_dist)[v]; }
    761764
    762     ///Returns the 'previous arc' of the shortest path tree for a node.
    763 
     765    ///\brief Returns the 'previous arc' of the shortest path tree for
     766    ///the given node.
     767    ///
    764768    ///This function returns the 'previous arc' of the shortest path
    765769    ///tree for the node \c v, i.e. it returns the last arc of a
    766     ///shortest path from the root(s) to \c v. It is \c INVALID if \c v
    767     ///is not reachable from the root(s) or if \c v is a root.
     770    ///shortest path from a root to \c v. It is \c INVALID if \c v
     771    ///is not reached from the root(s) or if \c v is a root.
    768772    ///
    769773    ///The shortest path tree used here is equal to the shortest path
    770     ///tree used in \ref predNode().
    771     ///
    772     ///\pre Either \ref run() or \ref start() must be called before
    773     ///using this function.
     774    ///tree used in \ref predNode() and \ref predMap().
     775    ///
     776    ///\pre Either \ref run(Node) "run()" or \ref init()
     777    ///must be called before using this function.
    774778    Arc predArc(Node v) const { return (*_pred)[v];}
    775779
    776     ///Returns the 'previous node' of the shortest path tree for a node.
    777 
     780    ///\brief Returns the 'previous node' of the shortest path tree for
     781    ///the given node.
     782    ///
    778783    ///This function returns the 'previous node' of the shortest path
    779784    ///tree for the node \c v, i.e. it returns the last but one node
    780     ///from a shortest path from the root(s) to \c v. It is \c INVALID
    781     ///if \c v is not reachable from the root(s) or if \c v is a root.
     785    ///of a shortest path from a root to \c v. It is \c INVALID
     786    ///if \c v is not reached from the root(s) or if \c v is a root.
    782787    ///
    783788    ///The shortest path tree used here is equal to the shortest path
    784     ///tree used in \ref predArc().
    785     ///
    786     ///\pre Either \ref run() or \ref start() must be called before
    787     ///using this function.
     789    ///tree used in \ref predArc() and \ref predMap().
     790    ///
     791    ///\pre Either \ref run(Node) "run()" or \ref init()
     792    ///must be called before using this function.
    788793    Node predNode(Node v) const { return (*_pred)[v]==INVALID ? INVALID:
    789794                                  G->source((*_pred)[v]); }
     
    795800    ///of the nodes calculated by the algorithm.
    796801    ///
    797     ///\pre Either \ref run() or \ref init()
     802    ///\pre Either \ref run(Node) "run()" or \ref init()
    798803    ///must be called before using this function.
    799804    const DistMap &distMap() const { return *_dist;}
     
    803808    ///
    804809    ///Returns a const reference to the node map that stores the predecessor
    805     ///arcs, which form the shortest path tree.
    806     ///
    807     ///\pre Either \ref run() or \ref init()
     810    ///arcs, which form the shortest path tree (forest).
     811    ///
     812    ///\pre Either \ref run(Node) "run()" or \ref init()
    808813    ///must be called before using this function.
    809814    const PredMap &predMap() const { return *_pred;}
    810815
    811     ///Checks if a node is reachable from the root(s).
    812 
    813     ///Returns \c true if \c v is reachable from the root(s).
    814     ///\pre Either \ref run() or \ref start()
     816    ///Checks if the given node is reached from the root(s).
     817
     818    ///Returns \c true if \c v is reached from the root(s).
     819    ///
     820    ///\pre Either \ref run(Node) "run()" or \ref init()
    815821    ///must be called before using this function.
    816822    bool reached(Node v) const { return (*_reached)[v]; }
     
    834840    ///The type of the map that stores the predecessor
    835841    ///arcs of the shortest paths.
    836     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     842    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    837843    typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
    838844    ///Instantiates a PredMap.
     
    849855
    850856    ///The type of the map that indicates which nodes are processed.
    851     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    852     ///By default it is a NullMap.
     857    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
     858    ///By default, it is a NullMap.
    853859    typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
    854860    ///Instantiates a ProcessedMap.
     
    869875
    870876    ///The type of the map that indicates which nodes are reached.
    871     ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     877    ///It must conform to
     878    ///the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    872879    typedef typename Digraph::template NodeMap<bool> ReachedMap;
    873880    ///Instantiates a ReachedMap.
     
    884891
    885892    ///The type of the map that stores the distances of the nodes.
    886     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     893    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    887894    typedef typename Digraph::template NodeMap<int> DistMap;
    888895    ///Instantiates a DistMap.
     
    899906
    900907    ///The type of the shortest paths.
    901     ///It must meet the \ref concepts::Path "Path" concept.
     908    ///It must conform to the \ref concepts::Path "Path" concept.
    902909    typedef lemon::Path<Digraph> Path;
    903910  };
     
    905912  /// Default traits class used by BfsWizard
    906913
    907   /// To make it easier to use Bfs algorithm
    908   /// we have created a wizard class.
    909   /// This \ref BfsWizard class needs default traits,
    910   /// as well as the \ref Bfs class.
    911   /// The \ref BfsWizardBase is a class to be the default traits of the
    912   /// \ref BfsWizard class.
     914  /// Default traits class used by BfsWizard.
     915  /// \tparam GR The type of the digraph.
    913916  template<class GR>
    914917  class BfsWizardBase : public BfsWizardDefaultTraits<GR>
     
    938941    /// Constructor.
    939942
    940     /// This constructor does not require parameters, therefore it initiates
     943    /// This constructor does not require parameters, it initiates
    941944    /// all of the attributes to \c 0.
    942945    BfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0),
     
    958961  /// This auxiliary class is created to implement the
    959962  /// \ref bfs() "function-type interface" of \ref Bfs algorithm.
    960   /// It does not have own \ref run() method, it uses the functions
    961   /// and features of the plain \ref Bfs.
     963  /// It does not have own \ref run(Node) "run()" method, it uses the
     964  /// functions and features of the plain \ref Bfs.
    962965  ///
    963966  /// This class should only be used through the \ref bfs() function,
    964967  /// which makes it easier to use the algorithm.
     968  ///
     969  /// \tparam TR The traits class that defines various types used by the
     970  /// algorithm.
    965971  template<class TR>
    966972  class BfsWizard : public TR
     
    968974    typedef TR Base;
    969975
    970     ///The type of the digraph the algorithm runs on.
    971976    typedef typename TR::Digraph Digraph;
    972977
     
    976981    typedef typename Digraph::OutArcIt OutArcIt;
    977982
    978     ///\brief The type of the map that stores the predecessor
    979     ///arcs of the shortest paths.
    980983    typedef typename TR::PredMap PredMap;
    981     ///\brief The type of the map that stores the distances of the nodes.
    982984    typedef typename TR::DistMap DistMap;
    983     ///\brief The type of the map that indicates which nodes are reached.
    984985    typedef typename TR::ReachedMap ReachedMap;
    985     ///\brief The type of the map that indicates which nodes are processed.
    986986    typedef typename TR::ProcessedMap ProcessedMap;
    987     ///The type of the shortest paths
    988987    typedef typename TR::Path Path;
    989988
     
    10551054    ///Runs BFS algorithm to visit all nodes in the digraph.
    10561055
    1057     ///This method runs BFS algorithm in order to compute
    1058     ///the shortest path to each node.
     1056    ///This method runs BFS algorithm in order to visit all nodes
     1057    ///in the digraph.
    10591058    void run()
    10601059    {
     
    10681067      SetPredMapBase(const TR &b) : TR(b) {}
    10691068    };
    1070     ///\brief \ref named-func-param "Named parameter"
    1071     ///for setting PredMap object.
    1072     ///
    1073     ///\ref named-func-param "Named parameter"
    1074     ///for setting PredMap object.
     1069
     1070    ///\brief \ref named-templ-param "Named parameter" for setting
     1071    ///the predecessor map.
     1072    ///
     1073    ///\ref named-templ-param "Named parameter" function for setting
     1074    ///the map that stores the predecessor arcs of the nodes.
    10751075    template<class T>
    10761076    BfsWizard<SetPredMapBase<T> > predMap(const T &t)
     
    10861086      SetReachedMapBase(const TR &b) : TR(b) {}
    10871087    };
    1088     ///\brief \ref named-func-param "Named parameter"
    1089     ///for setting ReachedMap object.
    1090     ///
    1091     /// \ref named-func-param "Named parameter"
    1092     ///for setting ReachedMap object.
     1088
     1089    ///\brief \ref named-templ-param "Named parameter" for setting
     1090    ///the reached map.
     1091    ///
     1092    ///\ref named-templ-param "Named parameter" function for setting
     1093    ///the map that indicates which nodes are reached.
    10931094    template<class T>
    10941095    BfsWizard<SetReachedMapBase<T> > reachedMap(const T &t)
     
    11041105      SetDistMapBase(const TR &b) : TR(b) {}
    11051106    };
    1106     ///\brief \ref named-func-param "Named parameter"
    1107     ///for setting DistMap object.
    1108     ///
    1109     /// \ref named-func-param "Named parameter"
    1110     ///for setting DistMap object.
     1107
     1108    ///\brief \ref named-templ-param "Named parameter" for setting
     1109    ///the distance map.
     1110    ///
     1111    ///\ref named-templ-param "Named parameter" function for setting
     1112    ///the map that stores the distances of the nodes calculated
     1113    ///by the algorithm.
    11111114    template<class T>
    11121115    BfsWizard<SetDistMapBase<T> > distMap(const T &t)
     
    11221125      SetProcessedMapBase(const TR &b) : TR(b) {}
    11231126    };
    1124     ///\brief \ref named-func-param "Named parameter"
    1125     ///for setting ProcessedMap object.
    1126     ///
    1127     /// \ref named-func-param "Named parameter"
    1128     ///for setting ProcessedMap object.
     1127
     1128    ///\brief \ref named-func-param "Named parameter" for setting
     1129    ///the processed map.
     1130    ///
     1131    ///\ref named-templ-param "Named parameter" function for setting
     1132    ///the map that indicates which nodes are processed.
    11291133    template<class T>
    11301134    BfsWizard<SetProcessedMapBase<T> > processedMap(const T &t)
     
    11791183  ///  bool reached = bfs(g).path(p).dist(d).run(s,t);
    11801184  ///\endcode
    1181   ///\warning Don't forget to put the \ref BfsWizard::run() "run()"
     1185  ///\warning Don't forget to put the \ref BfsWizard::run(Node) "run()"
    11821186  ///to the end of the parameter list.
    11831187  ///\sa BfsWizard
     
    11951199  /// This class defines the interface of the BfsVisit events, and
    11961200  /// it could be the base of a real visitor class.
    1197   template <typename _Digraph>
     1201  template <typename GR>
    11981202  struct BfsVisitor {
    1199     typedef _Digraph Digraph;
     1203    typedef GR Digraph;
    12001204    typedef typename Digraph::Arc Arc;
    12011205    typedef typename Digraph::Node Node;
     
    12251229  };
    12261230#else
    1227   template <typename _Digraph>
     1231  template <typename GR>
    12281232  struct BfsVisitor {
    1229     typedef _Digraph Digraph;
     1233    typedef GR Digraph;
    12301234    typedef typename Digraph::Arc Arc;
    12311235    typedef typename Digraph::Node Node;
     
    12551259  ///
    12561260  /// Default traits class of BfsVisit class.
    1257   /// \tparam _Digraph The type of the digraph the algorithm runs on.
    1258   template<class _Digraph>
     1261  /// \tparam GR The type of the digraph the algorithm runs on.
     1262  template<class GR>
    12591263  struct BfsVisitDefaultTraits {
    12601264
    12611265    /// \brief The type of the digraph the algorithm runs on.
    1262     typedef _Digraph Digraph;
     1266    typedef GR Digraph;
    12631267
    12641268    /// \brief The type of the map that indicates which nodes are reached.
    12651269    ///
    12661270    /// The type of the map that indicates which nodes are reached.
    1267     /// It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     1271    /// It must conform to
     1272    ///the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    12681273    typedef typename Digraph::template NodeMap<bool> ReachedMap;
    12691274
     
    12811286  /// \ingroup search
    12821287  ///
    1283   /// \brief %BFS algorithm class with visitor interface.
     1288  /// \brief BFS algorithm class with visitor interface.
    12841289  ///
    1285   /// This class provides an efficient implementation of the %BFS algorithm
     1290  /// This class provides an efficient implementation of the BFS algorithm
    12861291  /// with visitor interface.
    12871292  ///
    1288   /// The %BfsVisit class provides an alternative interface to the Bfs
     1293  /// The BfsVisit class provides an alternative interface to the Bfs
    12891294  /// class. It works with callback mechanism, the BfsVisit object calls
    12901295  /// the member functions of the \c Visitor class on every BFS event.
     
    12951300  /// instead.
    12961301  ///
    1297   /// \tparam _Digraph The type of the digraph the algorithm runs on.
    1298   /// The default value is
    1299   /// \ref ListDigraph. The value of _Digraph is not used directly by
    1300   /// \ref BfsVisit, it is only passed to \ref BfsVisitDefaultTraits.
    1301   /// \tparam _Visitor The Visitor type that is used by the algorithm.
    1302   /// \ref BfsVisitor "BfsVisitor<_Digraph>" is an empty visitor, which
     1302  /// \tparam GR The type of the digraph the algorithm runs on.
     1303  /// The default type is \ref ListDigraph.
     1304  /// The value of GR is not used directly by \ref BfsVisit,
     1305  /// it is only passed to \ref BfsVisitDefaultTraits.
     1306  /// \tparam VS The Visitor type that is used by the algorithm.
     1307  /// \ref BfsVisitor "BfsVisitor<GR>" is an empty visitor, which
    13031308  /// does not observe the BFS events. If you want to observe the BFS
    13041309  /// events, you should implement your own visitor class.
    1305   /// \tparam _Traits Traits class to set various data types used by the
    1306   /// algorithm. The default traits class is
    1307   /// \ref BfsVisitDefaultTraits "BfsVisitDefaultTraits<_Digraph>".
    1308   /// See \ref BfsVisitDefaultTraits for the documentation of
    1309   /// a BFS visit traits class.
     1310  /// \tparam TR The traits class that defines various types used by the
     1311  /// algorithm. By default, it is \ref BfsVisitDefaultTraits
     1312  /// "BfsVisitDefaultTraits<GR>".
     1313  /// In most cases, this parameter should not be set directly,
     1314  /// consider to use the named template parameters instead.
    13101315#ifdef DOXYGEN
    1311   template <typename _Digraph, typename _Visitor, typename _Traits>
     1316  template <typename GR, typename VS, typename TR>
    13121317#else
    1313   template <typename _Digraph = ListDigraph,
    1314             typename _Visitor = BfsVisitor<_Digraph>,
    1315             typename _Traits = BfsVisitDefaultTraits<_Digraph> >
     1318  template <typename GR = ListDigraph,
     1319            typename VS = BfsVisitor<GR>,
     1320            typename TR = BfsVisitDefaultTraits<GR> >
    13161321#endif
    13171322  class BfsVisit {
     
    13191324
    13201325    ///The traits class.
    1321     typedef _Traits Traits;
     1326    typedef TR Traits;
    13221327
    13231328    ///The type of the digraph the algorithm runs on.
     
    13251330
    13261331    ///The visitor type used by the algorithm.
    1327     typedef _Visitor Visitor;
     1332    typedef VS Visitor;
    13281333
    13291334    ///The type of the map that indicates which nodes are reached.
     
    13651370    typedef BfsVisit Create;
    13661371
    1367     /// \name Named template parameters
     1372    /// \name Named Template Parameters
    13681373
    13691374    ///@{
     
    14071412    ///
    14081413    /// Sets the map that indicates which nodes are reached.
    1409     /// If you don't use this function before calling \ref run(),
    1410     /// it will allocate one. The destructor deallocates this
    1411     /// automatically allocated map, of course.
     1414    /// If you don't use this function before calling \ref run(Node) "run()"
     1415    /// or \ref init(), an instance will be allocated automatically.
     1416    /// The destructor deallocates this automatically allocated map,
     1417    /// of course.
    14121418    /// \return <tt> (*this) </tt>
    14131419    BfsVisit &reachedMap(ReachedMap &m) {
     
    14221428  public:
    14231429
    1424     /// \name Execution control
    1425     /// The simplest way to execute the algorithm is to use
    1426     /// one of the member functions called \ref lemon::BfsVisit::run()
    1427     /// "run()".
    1428     /// \n
    1429     /// If you need more control on the execution, first you must call
    1430     /// \ref lemon::BfsVisit::init() "init()", then you can add several
    1431     /// source nodes with \ref lemon::BfsVisit::addSource() "addSource()".
    1432     /// Finally \ref lemon::BfsVisit::start() "start()" will perform the
    1433     /// actual path computation.
     1430    /// \name Execution Control
     1431    /// The simplest way to execute the BFS algorithm is to use one of the
     1432    /// member functions called \ref run(Node) "run()".\n
     1433    /// If you need better control on the execution, you have to call
     1434    /// \ref init() first, then you can add several source nodes with
     1435    /// \ref addSource(). Finally the actual path computation can be
     1436    /// performed with one of the \ref start() functions.
    14341437
    14351438    /// @{
     
    17011704    /// \brief Runs the algorithm to visit all nodes in the digraph.
    17021705    ///
    1703     /// This method runs the %BFS algorithm in order to
    1704     /// compute the shortest path to each node.
    1705     ///
    1706     /// The algorithm computes
    1707     /// - the shortest path tree (forest),
    1708     /// - the distance of each node from the root(s).
     1706    /// This method runs the %BFS algorithm in order to visit all nodes
     1707    /// in the digraph.
    17091708    ///
    17101709    /// \note <tt>b.run(s)</tt> is just a shortcut of the following code.
     
    17311730
    17321731    /// \name Query Functions
    1733     /// The result of the %BFS algorithm can be obtained using these
     1732    /// The results of the BFS algorithm can be obtained using these
    17341733    /// functions.\n
    1735     /// Either \ref lemon::BfsVisit::run() "run()" or
    1736     /// \ref lemon::BfsVisit::start() "start()" must be called before
    1737     /// using them.
     1734    /// Either \ref run(Node) "run()" or \ref start() should be called
     1735    /// before using them.
     1736
    17381737    ///@{
    17391738
    1740     /// \brief Checks if a node is reachable from the root(s).
    1741     ///
    1742     /// Returns \c true if \c v is reachable from the root(s).
    1743     /// \pre Either \ref run() or \ref start()
     1739    /// \brief Checks if the given node is reached from the root(s).
     1740    ///
     1741    /// Returns \c true if \c v is reached from the root(s).
     1742    ///
     1743    /// \pre Either \ref run(Node) "run()" or \ref init()
    17441744    /// must be called before using this function.
    1745     bool reached(Node v) { return (*_reached)[v]; }
     1745    bool reached(Node v) const { return (*_reached)[v]; }
    17461746
    17471747    ///@}
Note: See TracChangeset for help on using the changeset viewer.