COIN-OR::LEMON - Graph Library

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/bfs.h

    r956 r525  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2010
     5 * Copyright (C) 2003-2009
    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 conform to the \ref concepts::WriteMap "WriteMap" concept.
     50    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    5151    typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
    5252    ///Instantiates a \c PredMap.
     
    6363
    6464    ///The type of the map that indicates which nodes are processed.
    65     ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    66     ///By default, it is a NullMap.
     65    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    6766    typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
    6867    ///Instantiates a \c ProcessedMap.
     
    8382
    8483    ///The type of the map that indicates which nodes are reached.
    85     ///It must conform to
    86     ///the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     84    ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    8785    typedef typename Digraph::template NodeMap<bool> ReachedMap;
    8886    ///Instantiates a \c ReachedMap.
     
    9997
    10098    ///The type of the map that stores the distances of the nodes.
    101     ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
     99    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    102100    typedef typename Digraph::template NodeMap<int> DistMap;
    103101    ///Instantiates a \c DistMap.
     
    123121  ///\tparam GR The type of the digraph the algorithm runs on.
    124122  ///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.
    130123#ifdef DOXYGEN
    131124  template <typename GR,
     
    233226    ///\ref named-templ-param "Named parameter" for setting
    234227    ///\c PredMap type.
    235     ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
     228    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    236229    template <class T>
    237230    struct SetPredMap : public Bfs< Digraph, SetPredMapTraits<T> > {
     
    253246    ///\ref named-templ-param "Named parameter" for setting
    254247    ///\c DistMap type.
    255     ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
     248    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    256249    template <class T>
    257250    struct SetDistMap : public Bfs< Digraph, SetDistMapTraits<T> > {
     
    273266    ///\ref named-templ-param "Named parameter" for setting
    274267    ///\c ReachedMap type.
    275     ///It must conform to
    276     ///the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     268    ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    277269    template <class T>
    278270    struct SetReachedMap : public Bfs< Digraph, SetReachedMapTraits<T> > {
     
    294286    ///\ref named-templ-param "Named parameter" for setting
    295287    ///\c ProcessedMap type.
    296     ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
     288    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    297289    template <class T>
    298290    struct SetProcessedMap : public Bfs< Digraph, SetProcessedMapTraits<T> > {
     
    422414    ///The simplest way to execute the BFS algorithm is to use one of the
    423415    ///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
     416    ///If you need more control on the execution, first you have to call
     417    ///\ref init(), then you can add several source nodes with
    426418    ///\ref addSource(). Finally the actual path computation can be
    427419    ///performed with one of the \ref start() functions.
     
    709701    ///Runs the algorithm to visit all nodes in the digraph.
    710702
    711     ///This method runs the %BFS algorithm in order to visit all nodes
    712     ///in the digraph.
     703    ///This method runs the %BFS algorithm in order to
     704    ///compute the shortest path to each node.
     705    ///
     706    ///The algorithm computes
     707    ///- the shortest path tree (forest),
     708    ///- the distance of each node from the root(s).
    713709    ///
    714710    ///\note <tt>b.run(s)</tt> is just a shortcut of the following code.
     
    742738    ///@{
    743739
    744     ///The shortest path to the given node.
    745 
    746     ///Returns the shortest path to the given node from the root(s).
     740    ///The shortest path to a node.
     741
     742    ///Returns the shortest path to a node.
    747743    ///
    748744    ///\warning \c t should be reached from the root(s).
     
    752748    Path path(Node t) const { return Path(*G, *_pred, t); }
    753749
    754     ///The distance of the given node from the root(s).
    755 
    756     ///Returns the distance of the given node from the root(s).
     750    ///The distance of a node from the root(s).
     751
     752    ///Returns the distance of a node from the root(s).
    757753    ///
    758754    ///\warning If node \c v is not reached from the root(s), then
     
    763759    int dist(Node v) const { return (*_dist)[v]; }
    764760
    765     ///\brief Returns the 'previous arc' of the shortest path tree for
    766     ///the given node.
    767     ///
     761    ///Returns the 'previous arc' of the shortest path tree for a node.
     762
    768763    ///This function returns the 'previous arc' of the shortest path
    769764    ///tree for the node \c v, i.e. it returns the last arc of a
     
    772767    ///
    773768    ///The shortest path tree used here is equal to the shortest path
    774     ///tree used in \ref predNode() and \ref predMap().
     769    ///tree used in \ref predNode().
    775770    ///
    776771    ///\pre Either \ref run(Node) "run()" or \ref init()
     
    778773    Arc predArc(Node v) const { return (*_pred)[v];}
    779774
    780     ///\brief Returns the 'previous node' of the shortest path tree for
    781     ///the given node.
    782     ///
     775    ///Returns the 'previous node' of the shortest path tree for a node.
     776
    783777    ///This function returns the 'previous node' of the shortest path
    784778    ///tree for the node \c v, i.e. it returns the last but one node
    785     ///of a shortest path from a root to \c v. It is \c INVALID
     779    ///from a shortest path from a root to \c v. It is \c INVALID
    786780    ///if \c v is not reached from the root(s) or if \c v is a root.
    787781    ///
    788782    ///The shortest path tree used here is equal to the shortest path
    789     ///tree used in \ref predArc() and \ref predMap().
     783    ///tree used in \ref predArc().
    790784    ///
    791785    ///\pre Either \ref run(Node) "run()" or \ref init()
     
    808802    ///
    809803    ///Returns a const reference to the node map that stores the predecessor
    810     ///arcs, which form the shortest path tree (forest).
     804    ///arcs, which form the shortest path tree.
    811805    ///
    812806    ///\pre Either \ref run(Node) "run()" or \ref init()
     
    814808    const PredMap &predMap() const { return *_pred;}
    815809
    816     ///Checks if the given node is reached from the root(s).
     810    ///Checks if a node is reached from the root(s).
    817811
    818812    ///Returns \c true if \c v is reached from the root(s).
     
    840834    ///The type of the map that stores the predecessor
    841835    ///arcs of the shortest paths.
    842     ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
     836    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    843837    typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
    844838    ///Instantiates a PredMap.
     
    855849
    856850    ///The type of the map that indicates which nodes are processed.
    857     ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    858     ///By default, it is a NullMap.
     851    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     852    ///By default it is a NullMap.
    859853    typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
    860854    ///Instantiates a ProcessedMap.
     
    875869
    876870    ///The type of the map that indicates which nodes are reached.
    877     ///It must conform to
    878     ///the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     871    ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    879872    typedef typename Digraph::template NodeMap<bool> ReachedMap;
    880873    ///Instantiates a ReachedMap.
     
    891884
    892885    ///The type of the map that stores the distances of the nodes.
    893     ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
     886    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    894887    typedef typename Digraph::template NodeMap<int> DistMap;
    895888    ///Instantiates a DistMap.
     
    906899
    907900    ///The type of the shortest paths.
    908     ///It must conform to the \ref concepts::Path "Path" concept.
     901    ///It must meet the \ref concepts::Path "Path" concept.
    909902    typedef lemon::Path<Digraph> Path;
    910903  };
     
    912905  /// Default traits class used by BfsWizard
    913906
    914   /// Default traits class used by BfsWizard.
    915   /// \tparam GR The type of the digraph.
     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.
    916913  template<class GR>
    917914  class BfsWizardBase : public BfsWizardDefaultTraits<GR>
     
    941938    /// Constructor.
    942939
    943     /// This constructor does not require parameters, it initiates
     940    /// This constructor does not require parameters, therefore it initiates
    944941    /// all of the attributes to \c 0.
    945942    BfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0),
     
    966963  /// This class should only be used through the \ref bfs() function,
    967964  /// which makes it easier to use the algorithm.
    968   ///
    969   /// \tparam TR The traits class that defines various types used by the
    970   /// algorithm.
    971965  template<class TR>
    972966  class BfsWizard : public TR
     
    974968    typedef TR Base;
    975969
     970    ///The type of the digraph the algorithm runs on.
    976971    typedef typename TR::Digraph Digraph;
    977972
     
    981976    typedef typename Digraph::OutArcIt OutArcIt;
    982977
     978    ///\brief The type of the map that stores the predecessor
     979    ///arcs of the shortest paths.
    983980    typedef typename TR::PredMap PredMap;
     981    ///\brief The type of the map that stores the distances of the nodes.
    984982    typedef typename TR::DistMap DistMap;
     983    ///\brief The type of the map that indicates which nodes are reached.
    985984    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
    987988    typedef typename TR::Path Path;
    988989
     
    10541055    ///Runs BFS algorithm to visit all nodes in the digraph.
    10551056
    1056     ///This method runs BFS algorithm in order to visit all nodes
    1057     ///in the digraph.
     1057    ///This method runs BFS algorithm in order to compute
     1058    ///the shortest path to each node.
    10581059    void run()
    10591060    {
     
    10671068      SetPredMapBase(const TR &b) : TR(b) {}
    10681069    };
    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.
     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.
    10751075    template<class T>
    10761076    BfsWizard<SetPredMapBase<T> > predMap(const T &t)
     
    10861086      SetReachedMapBase(const TR &b) : TR(b) {}
    10871087    };
    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.
     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.
    10941093    template<class T>
    10951094    BfsWizard<SetReachedMapBase<T> > reachedMap(const T &t)
     
    11051104      SetDistMapBase(const TR &b) : TR(b) {}
    11061105    };
    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.
     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.
    11141111    template<class T>
    11151112    BfsWizard<SetDistMapBase<T> > distMap(const T &t)
     
    11251122      SetProcessedMapBase(const TR &b) : TR(b) {}
    11261123    };
    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.
     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.
    11331129    template<class T>
    11341130    BfsWizard<SetProcessedMapBase<T> > processedMap(const T &t)
     
    12691265    ///
    12701266    /// The type of the map that indicates which nodes are reached.
    1271     /// It must conform to
    1272     ///the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     1267    /// It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    12731268    typedef typename Digraph::template NodeMap<bool> ReachedMap;
    12741269
     
    13081303  /// does not observe the BFS events. If you want to observe the BFS
    13091304  /// events, you should implement your own visitor 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.
     1305  /// \tparam TR Traits class to set various data types used by the
     1306  /// algorithm. The default traits class is
     1307  /// \ref BfsVisitDefaultTraits "BfsVisitDefaultTraits<GR>".
     1308  /// See \ref BfsVisitDefaultTraits for the documentation of
     1309  /// a BFS visit traits class.
    13151310#ifdef DOXYGEN
    13161311  template <typename GR, typename VS, typename TR>
     
    14311426    /// The simplest way to execute the BFS algorithm is to use one of the
    14321427    /// 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
     1428    /// If you need more control on the execution, first you have to call
     1429    /// \ref init(), then you can add several source nodes with
    14351430    /// \ref addSource(). Finally the actual path computation can be
    14361431    /// performed with one of the \ref start() functions.
     
    17041699    /// \brief Runs the algorithm to visit all nodes in the digraph.
    17051700    ///
    1706     /// This method runs the %BFS algorithm in order to visit all nodes
    1707     /// in the digraph.
     1701    /// This method runs the %BFS algorithm in order to
     1702    /// compute the shortest path to each node.
     1703    ///
     1704    /// The algorithm computes
     1705    /// - the shortest path tree (forest),
     1706    /// - the distance of each node from the root(s).
    17081707    ///
    17091708    /// \note <tt>b.run(s)</tt> is just a shortcut of the following code.
     
    17371736    ///@{
    17381737
    1739     /// \brief Checks if the given node is reached from the root(s).
     1738    /// \brief Checks if a node is reached from the root(s).
    17401739    ///
    17411740    /// Returns \c true if \c v is reached from the root(s).
Note: See TracChangeset for help on using the changeset viewer.