COIN-OR::LEMON - Graph Library

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/bfs.h

    r764 r463  
    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;
    52     ///Instantiates a \c PredMap.
    53 
    54     ///This function instantiates a \ref PredMap.
     52    ///Instantiates a PredMap.
     53
     54    ///This function instantiates a PredMap.
    5555    ///\param g is the digraph, to which we would like to define the
    56     ///\ref PredMap.
     56    ///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 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;
    68     ///Instantiates a \c ProcessedMap.
    69 
    70     ///This function instantiates a \ref ProcessedMap.
     67    ///Instantiates a ProcessedMap.
     68
     69    ///This function instantiates a ProcessedMap.
    7170    ///\param g is the digraph, to which
    72     ///we would like to define the \ref ProcessedMap
     71    ///we would like to define the ProcessedMap
    7372#ifdef DOXYGEN
    7473    static ProcessedMap *createProcessedMap(const Digraph &g)
     
    8382
    8483    ///The type of the map that indicates which nodes are reached.
    85     ///It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     84    ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    8685    typedef typename Digraph::template NodeMap<bool> ReachedMap;
    87     ///Instantiates a \c ReachedMap.
    88 
    89     ///This function instantiates a \ref ReachedMap.
     86    ///Instantiates a ReachedMap.
     87
     88    ///This function instantiates a ReachedMap.
    9089    ///\param g is the digraph, to which
    91     ///we would like to define the \ref ReachedMap.
     90    ///we would like to define the ReachedMap.
    9291    static ReachedMap *createReachedMap(const Digraph &g)
    9392    {
     
    9897
    9998    ///The type of the map that stores the distances of the nodes.
    100     ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
     99    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    101100    typedef typename Digraph::template NodeMap<int> DistMap;
    102     ///Instantiates a \c DistMap.
    103 
    104     ///This function instantiates a \ref DistMap.
     101    ///Instantiates a DistMap.
     102
     103    ///This function instantiates a DistMap.
    105104    ///\param g is the digraph, to which we would like to define the
    106     ///\ref DistMap.
     105    ///DistMap.
    107106    static DistMap *createDistMap(const Digraph &g)
    108107    {
     
    223222    };
    224223    ///\brief \ref named-templ-param "Named parameter" for setting
    225     ///\c PredMap type.
     224    ///PredMap type.
    226225    ///
    227226    ///\ref named-templ-param "Named parameter" for setting
    228     ///\c PredMap type.
    229     ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
     227    ///PredMap type.
     228    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    230229    template <class T>
    231230    struct SetPredMap : public Bfs< Digraph, SetPredMapTraits<T> > {
     
    243242    };
    244243    ///\brief \ref named-templ-param "Named parameter" for setting
    245     ///\c DistMap type.
     244    ///DistMap type.
    246245    ///
    247246    ///\ref named-templ-param "Named parameter" for setting
    248     ///\c DistMap type.
    249     ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
     247    ///DistMap type.
     248    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    250249    template <class T>
    251250    struct SetDistMap : public Bfs< Digraph, SetDistMapTraits<T> > {
     
    263262    };
    264263    ///\brief \ref named-templ-param "Named parameter" for setting
    265     ///\c ReachedMap type.
     264    ///ReachedMap type.
    266265    ///
    267266    ///\ref named-templ-param "Named parameter" for setting
    268     ///\c ReachedMap type.
    269     ///It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     267    ///ReachedMap type.
     268    ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    270269    template <class T>
    271270    struct SetReachedMap : public Bfs< Digraph, SetReachedMapTraits<T> > {
     
    283282    };
    284283    ///\brief \ref named-templ-param "Named parameter" for setting
    285     ///\c ProcessedMap type.
     284    ///ProcessedMap type.
    286285    ///
    287286    ///\ref named-templ-param "Named parameter" for setting
    288     ///\c ProcessedMap type.
    289     ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
     287    ///ProcessedMap type.
     288    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    290289    template <class T>
    291290    struct SetProcessedMap : public Bfs< Digraph, SetProcessedMapTraits<T> > {
     
    302301    };
    303302    ///\brief \ref named-templ-param "Named parameter" for setting
    304     ///\c ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.
     303    ///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.
    305304    ///
    306305    ///\ref named-templ-param "Named parameter" for setting
    307     ///\c ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.
     306    ///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.
    308307    ///If you don't set it explicitly, it will be automatically allocated.
    309308    struct SetStandardProcessedMap :
     
    415414    ///The simplest way to execute the BFS algorithm is to use one of the
    416415    ///member functions called \ref run(Node) "run()".\n
    417     ///If you need better control on the execution, you have to call
    418     ///\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
    419418    ///\ref addSource(). Finally the actual path computation can be
    420419    ///performed with one of the \ref start() functions.
     
    739738    ///@{
    740739
    741     ///The shortest path to the given node.
    742 
    743     ///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.
    744743    ///
    745744    ///\warning \c t should be reached from the root(s).
     
    749748    Path path(Node t) const { return Path(*G, *_pred, t); }
    750749
    751     ///The distance of the given node from the root(s).
    752 
    753     ///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).
    754753    ///
    755754    ///\warning If node \c v is not reached from the root(s), then
     
    760759    int dist(Node v) const { return (*_dist)[v]; }
    761760
    762     ///\brief Returns the 'previous arc' of the shortest path tree for
    763     ///the given node.
    764     ///
     761    ///Returns the 'previous arc' of the shortest path tree for a node.
     762
    765763    ///This function returns the 'previous arc' of the shortest path
    766764    ///tree for the node \c v, i.e. it returns the last arc of a
     
    769767    ///
    770768    ///The shortest path tree used here is equal to the shortest path
    771     ///tree used in \ref predNode() and \ref predMap().
     769    ///tree used in \ref predNode().
    772770    ///
    773771    ///\pre Either \ref run(Node) "run()" or \ref init()
     
    775773    Arc predArc(Node v) const { return (*_pred)[v];}
    776774
    777     ///\brief Returns the 'previous node' of the shortest path tree for
    778     ///the given node.
    779     ///
     775    ///Returns the 'previous node' of the shortest path tree for a node.
     776
    780777    ///This function returns the 'previous node' of the shortest path
    781778    ///tree for the node \c v, i.e. it returns the last but one node
    782     ///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
    783780    ///if \c v is not reached from the root(s) or if \c v is a root.
    784781    ///
    785782    ///The shortest path tree used here is equal to the shortest path
    786     ///tree used in \ref predArc() and \ref predMap().
     783    ///tree used in \ref predArc().
    787784    ///
    788785    ///\pre Either \ref run(Node) "run()" or \ref init()
     
    805802    ///
    806803    ///Returns a const reference to the node map that stores the predecessor
    807     ///arcs, which form the shortest path tree (forest).
     804    ///arcs, which form the shortest path tree.
    808805    ///
    809806    ///\pre Either \ref run(Node) "run()" or \ref init()
     
    811808    const PredMap &predMap() const { return *_pred;}
    812809
    813     ///Checks if the given node is reached from the root(s).
     810    ///Checks if a node is reached from the root(s).
    814811
    815812    ///Returns \c true if \c v is reached from the root(s).
     
    837834    ///The type of the map that stores the predecessor
    838835    ///arcs of the shortest paths.
    839     ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
     836    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    840837    typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
    841838    ///Instantiates a PredMap.
     
    852849
    853850    ///The type of the map that indicates which nodes are processed.
    854     ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
     851    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    855852    ///By default it is a NullMap.
    856853    typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
     
    872869
    873870    ///The type of the map that indicates which nodes are reached.
    874     ///It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     871    ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    875872    typedef typename Digraph::template NodeMap<bool> ReachedMap;
    876873    ///Instantiates a ReachedMap.
     
    887884
    888885    ///The type of the map that stores the distances of the nodes.
    889     ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
     886    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    890887    typedef typename Digraph::template NodeMap<int> DistMap;
    891888    ///Instantiates a DistMap.
     
    902899
    903900    ///The type of the shortest paths.
    904     ///It must conform to the \ref concepts::Path "Path" concept.
     901    ///It must meet the \ref concepts::Path "Path" concept.
    905902    typedef lemon::Path<Digraph> Path;
    906903  };
     
    908905  /// Default traits class used by BfsWizard
    909906
    910   /// Default traits class used by BfsWizard.
    911   /// \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.
    912913  template<class GR>
    913914  class BfsWizardBase : public BfsWizardDefaultTraits<GR>
     
    937938    /// Constructor.
    938939
    939     /// This constructor does not require parameters, it initiates
     940    /// This constructor does not require parameters, therefore it initiates
    940941    /// all of the attributes to \c 0.
    941942    BfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0),
     
    967968    typedef TR Base;
    968969
     970    ///The type of the digraph the algorithm runs on.
    969971    typedef typename TR::Digraph Digraph;
    970972
     
    974976    typedef typename Digraph::OutArcIt OutArcIt;
    975977
     978    ///\brief The type of the map that stores the predecessor
     979    ///arcs of the shortest paths.
    976980    typedef typename TR::PredMap PredMap;
     981    ///\brief The type of the map that stores the distances of the nodes.
    977982    typedef typename TR::DistMap DistMap;
     983    ///\brief The type of the map that indicates which nodes are reached.
    978984    typedef typename TR::ReachedMap ReachedMap;
     985    ///\brief The type of the map that indicates which nodes are processed.
    979986    typedef typename TR::ProcessedMap ProcessedMap;
     987    ///The type of the shortest paths
    980988    typedef typename TR::Path Path;
    981989
     
    10601068      SetPredMapBase(const TR &b) : TR(b) {}
    10611069    };
    1062 
    1063     ///\brief \ref named-templ-param "Named parameter" for setting
    1064     ///the predecessor map.
    1065     ///
    1066     ///\ref named-templ-param "Named parameter" function for setting
    1067     ///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.
    10681075    template<class T>
    10691076    BfsWizard<SetPredMapBase<T> > predMap(const T &t)
     
    10791086      SetReachedMapBase(const TR &b) : TR(b) {}
    10801087    };
    1081 
    1082     ///\brief \ref named-templ-param "Named parameter" for setting
    1083     ///the reached map.
    1084     ///
    1085     ///\ref named-templ-param "Named parameter" function for setting
    1086     ///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.
    10871093    template<class T>
    10881094    BfsWizard<SetReachedMapBase<T> > reachedMap(const T &t)
     
    10981104      SetDistMapBase(const TR &b) : TR(b) {}
    10991105    };
    1100 
    1101     ///\brief \ref named-templ-param "Named parameter" for setting
    1102     ///the distance map.
    1103     ///
    1104     ///\ref named-templ-param "Named parameter" function for setting
    1105     ///the map that stores the distances of the nodes calculated
    1106     ///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.
    11071111    template<class T>
    11081112    BfsWizard<SetDistMapBase<T> > distMap(const T &t)
     
    11181122      SetProcessedMapBase(const TR &b) : TR(b) {}
    11191123    };
    1120 
    1121     ///\brief \ref named-func-param "Named parameter" for setting
    1122     ///the processed map.
    1123     ///
    1124     ///\ref named-templ-param "Named parameter" function for setting
    1125     ///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.
    11261129    template<class T>
    11271130    BfsWizard<SetProcessedMapBase<T> > processedMap(const T &t)
     
    11921195  /// This class defines the interface of the BfsVisit events, and
    11931196  /// it could be the base of a real visitor class.
    1194   template <typename GR>
     1197  template <typename _Digraph>
    11951198  struct BfsVisitor {
    1196     typedef GR Digraph;
     1199    typedef _Digraph Digraph;
    11971200    typedef typename Digraph::Arc Arc;
    11981201    typedef typename Digraph::Node Node;
     
    12221225  };
    12231226#else
    1224   template <typename GR>
     1227  template <typename _Digraph>
    12251228  struct BfsVisitor {
    1226     typedef GR Digraph;
     1229    typedef _Digraph Digraph;
    12271230    typedef typename Digraph::Arc Arc;
    12281231    typedef typename Digraph::Node Node;
     
    12521255  ///
    12531256  /// Default traits class of BfsVisit class.
    1254   /// \tparam GR The type of the digraph the algorithm runs on.
    1255   template<class GR>
     1257  /// \tparam _Digraph The type of the digraph the algorithm runs on.
     1258  template<class _Digraph>
    12561259  struct BfsVisitDefaultTraits {
    12571260
    12581261    /// \brief The type of the digraph the algorithm runs on.
    1259     typedef GR Digraph;
     1262    typedef _Digraph Digraph;
    12601263
    12611264    /// \brief The type of the map that indicates which nodes are reached.
    12621265    ///
    12631266    /// The type of the map that indicates which nodes are reached.
    1264     /// It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     1267    /// It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    12651268    typedef typename Digraph::template NodeMap<bool> ReachedMap;
    12661269
     
    12781281  /// \ingroup search
    12791282  ///
    1280   /// \brief BFS algorithm class with visitor interface.
     1283  /// \brief %BFS algorithm class with visitor interface.
    12811284  ///
    1282   /// This class provides an efficient implementation of the BFS algorithm
     1285  /// This class provides an efficient implementation of the %BFS algorithm
    12831286  /// with visitor interface.
    12841287  ///
    1285   /// The BfsVisit class provides an alternative interface to the Bfs
     1288  /// The %BfsVisit class provides an alternative interface to the Bfs
    12861289  /// class. It works with callback mechanism, the BfsVisit object calls
    12871290  /// the member functions of the \c Visitor class on every BFS event.
     
    12921295  /// instead.
    12931296  ///
    1294   /// \tparam GR The type of the digraph the algorithm runs on.
    1295   /// The default type is \ref ListDigraph.
    1296   /// The value of GR is not used directly by \ref BfsVisit,
    1297   /// it is only passed to \ref BfsVisitDefaultTraits.
    1298   /// \tparam VS The Visitor type that is used by the algorithm.
    1299   /// \ref BfsVisitor "BfsVisitor<GR>" is an empty visitor, which
     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
    13001303  /// does not observe the BFS events. If you want to observe the BFS
    13011304  /// events, you should implement your own visitor class.
    1302   /// \tparam TR Traits class to set various data types used by the
     1305  /// \tparam _Traits Traits class to set various data types used by the
    13031306  /// algorithm. The default traits class is
    1304   /// \ref BfsVisitDefaultTraits "BfsVisitDefaultTraits<GR>".
     1307  /// \ref BfsVisitDefaultTraits "BfsVisitDefaultTraits<_Digraph>".
    13051308  /// See \ref BfsVisitDefaultTraits for the documentation of
    13061309  /// a BFS visit traits class.
    13071310#ifdef DOXYGEN
    1308   template <typename GR, typename VS, typename TR>
     1311  template <typename _Digraph, typename _Visitor, typename _Traits>
    13091312#else
    1310   template <typename GR = ListDigraph,
    1311             typename VS = BfsVisitor<GR>,
    1312             typename TR = BfsVisitDefaultTraits<GR> >
     1313  template <typename _Digraph = ListDigraph,
     1314            typename _Visitor = BfsVisitor<_Digraph>,
     1315            typename _Traits = BfsVisitDefaultTraits<_Digraph> >
    13131316#endif
    13141317  class BfsVisit {
     
    13161319
    13171320    ///The traits class.
    1318     typedef TR Traits;
     1321    typedef _Traits Traits;
    13191322
    13201323    ///The type of the digraph the algorithm runs on.
     
    13221325
    13231326    ///The visitor type used by the algorithm.
    1324     typedef VS Visitor;
     1327    typedef _Visitor Visitor;
    13251328
    13261329    ///The type of the map that indicates which nodes are reached.
     
    14231426    /// The simplest way to execute the BFS algorithm is to use one of the
    14241427    /// member functions called \ref run(Node) "run()".\n
    1425     /// If you need better control on the execution, you have to call
    1426     /// \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
    14271430    /// \ref addSource(). Finally the actual path computation can be
    14281431    /// performed with one of the \ref start() functions.
     
    17331736    ///@{
    17341737
    1735     /// \brief Checks if the given node is reached from the root(s).
     1738    /// \brief Checks if a node is reached from the root(s).
    17361739    ///
    17371740    /// Returns \c true if \c v is reached from the root(s).
Note: See TracChangeset for help on using the changeset viewer.