COIN-OR::LEMON - Graph Library

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/bfs.h

    r463 r764  
    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 the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    8586    typedef typename Digraph::template NodeMap<bool> ReachedMap;
    86     ///Instantiates a ReachedMap.
    87 
    88     ///This function instantiates a ReachedMap.
     87    ///Instantiates a \c ReachedMap.
     88
     89    ///This function instantiates a \ref ReachedMap.
    8990    ///\param g is the digraph, to which
    90     ///we would like to define the ReachedMap.
     91    ///we would like to define the \ref ReachedMap.
    9192    static ReachedMap *createReachedMap(const Digraph &g)
    9293    {
     
    9798
    9899    ///The type of the map that stores the distances of the nodes.
    99     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     100    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    100101    typedef typename Digraph::template NodeMap<int> DistMap;
    101     ///Instantiates a DistMap.
    102 
    103     ///This function instantiates a DistMap.
     102    ///Instantiates a \c DistMap.
     103
     104    ///This function instantiates a \ref DistMap.
    104105    ///\param g is the digraph, to which we would like to define the
    105     ///DistMap.
     106    ///\ref DistMap.
    106107    static DistMap *createDistMap(const Digraph &g)
    107108    {
     
    222223    };
    223224    ///\brief \ref named-templ-param "Named parameter" for setting
    224     ///PredMap type.
     225    ///\c PredMap type.
    225226    ///
    226227    ///\ref named-templ-param "Named parameter" for setting
    227     ///PredMap type.
    228     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     228    ///\c PredMap type.
     229    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    229230    template <class T>
    230231    struct SetPredMap : public Bfs< Digraph, SetPredMapTraits<T> > {
     
    242243    };
    243244    ///\brief \ref named-templ-param "Named parameter" for setting
    244     ///DistMap type.
     245    ///\c DistMap type.
    245246    ///
    246247    ///\ref named-templ-param "Named parameter" for setting
    247     ///DistMap type.
    248     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     248    ///\c DistMap type.
     249    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    249250    template <class T>
    250251    struct SetDistMap : public Bfs< Digraph, SetDistMapTraits<T> > {
     
    262263    };
    263264    ///\brief \ref named-templ-param "Named parameter" for setting
    264     ///ReachedMap type.
     265    ///\c ReachedMap type.
    265266    ///
    266267    ///\ref named-templ-param "Named parameter" for setting
    267     ///ReachedMap type.
    268     ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     268    ///\c ReachedMap type.
     269    ///It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    269270    template <class T>
    270271    struct SetReachedMap : public Bfs< Digraph, SetReachedMapTraits<T> > {
     
    282283    };
    283284    ///\brief \ref named-templ-param "Named parameter" for setting
    284     ///ProcessedMap type.
     285    ///\c ProcessedMap type.
    285286    ///
    286287    ///\ref named-templ-param "Named parameter" for setting
    287     ///ProcessedMap type.
    288     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     288    ///\c ProcessedMap type.
     289    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    289290    template <class T>
    290291    struct SetProcessedMap : public Bfs< Digraph, SetProcessedMapTraits<T> > {
     
    301302    };
    302303    ///\brief \ref named-templ-param "Named parameter" for setting
    303     ///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.
     304    ///\c ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.
    304305    ///
    305306    ///\ref named-templ-param "Named parameter" for setting
    306     ///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.
     307    ///\c ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.
    307308    ///If you don't set it explicitly, it will be automatically allocated.
    308309    struct SetStandardProcessedMap :
     
    414415    ///The simplest way to execute the BFS algorithm is to use one of the
    415416    ///member functions called \ref run(Node) "run()".\n
    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
     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
    418419    ///\ref addSource(). Finally the actual path computation can be
    419420    ///performed with one of the \ref start() functions.
     
    738739    ///@{
    739740
    740     ///The shortest path to a node.
    741 
    742     ///Returns the shortest path to a node.
     741    ///The shortest path to the given node.
     742
     743    ///Returns the shortest path to the given node from the root(s).
    743744    ///
    744745    ///\warning \c t should be reached from the root(s).
     
    748749    Path path(Node t) const { return Path(*G, *_pred, t); }
    749750
    750     ///The distance of a node from the root(s).
    751 
    752     ///Returns the distance of a node from the root(s).
     751    ///The distance of the given node from the root(s).
     752
     753    ///Returns the distance of the given node from the root(s).
    753754    ///
    754755    ///\warning If node \c v is not reached from the root(s), then
     
    759760    int dist(Node v) const { return (*_dist)[v]; }
    760761
    761     ///Returns the 'previous arc' of the shortest path tree for a node.
    762 
     762    ///\brief Returns the 'previous arc' of the shortest path tree for
     763    ///the given node.
     764    ///
    763765    ///This function returns the 'previous arc' of the shortest path
    764766    ///tree for the node \c v, i.e. it returns the last arc of a
     
    767769    ///
    768770    ///The shortest path tree used here is equal to the shortest path
    769     ///tree used in \ref predNode().
     771    ///tree used in \ref predNode() and \ref predMap().
    770772    ///
    771773    ///\pre Either \ref run(Node) "run()" or \ref init()
     
    773775    Arc predArc(Node v) const { return (*_pred)[v];}
    774776
    775     ///Returns the 'previous node' of the shortest path tree for a node.
    776 
     777    ///\brief Returns the 'previous node' of the shortest path tree for
     778    ///the given node.
     779    ///
    777780    ///This function returns the 'previous node' of the shortest path
    778781    ///tree for the node \c v, i.e. it returns the last but one node
    779     ///from a shortest path from a root to \c v. It is \c INVALID
     782    ///of a shortest path from a root to \c v. It is \c INVALID
    780783    ///if \c v is not reached from the root(s) or if \c v is a root.
    781784    ///
    782785    ///The shortest path tree used here is equal to the shortest path
    783     ///tree used in \ref predArc().
     786    ///tree used in \ref predArc() and \ref predMap().
    784787    ///
    785788    ///\pre Either \ref run(Node) "run()" or \ref init()
     
    802805    ///
    803806    ///Returns a const reference to the node map that stores the predecessor
    804     ///arcs, which form the shortest path tree.
     807    ///arcs, which form the shortest path tree (forest).
    805808    ///
    806809    ///\pre Either \ref run(Node) "run()" or \ref init()
     
    808811    const PredMap &predMap() const { return *_pred;}
    809812
    810     ///Checks if a node is reached from the root(s).
     813    ///Checks if the given node is reached from the root(s).
    811814
    812815    ///Returns \c true if \c v is reached from the root(s).
     
    834837    ///The type of the map that stores the predecessor
    835838    ///arcs of the shortest paths.
    836     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     839    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    837840    typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
    838841    ///Instantiates a PredMap.
     
    849852
    850853    ///The type of the map that indicates which nodes are processed.
    851     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     854    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    852855    ///By default it is a NullMap.
    853856    typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
     
    869872
    870873    ///The type of the map that indicates which nodes are reached.
    871     ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     874    ///It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    872875    typedef typename Digraph::template NodeMap<bool> ReachedMap;
    873876    ///Instantiates a ReachedMap.
     
    884887
    885888    ///The type of the map that stores the distances of the nodes.
    886     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     889    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    887890    typedef typename Digraph::template NodeMap<int> DistMap;
    888891    ///Instantiates a DistMap.
     
    899902
    900903    ///The type of the shortest paths.
    901     ///It must meet the \ref concepts::Path "Path" concept.
     904    ///It must conform to the \ref concepts::Path "Path" concept.
    902905    typedef lemon::Path<Digraph> Path;
    903906  };
     
    905908  /// Default traits class used by BfsWizard
    906909
    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.
     910  /// Default traits class used by BfsWizard.
     911  /// \tparam GR The type of the digraph.
    913912  template<class GR>
    914913  class BfsWizardBase : public BfsWizardDefaultTraits<GR>
     
    938937    /// Constructor.
    939938
    940     /// This constructor does not require parameters, therefore it initiates
     939    /// This constructor does not require parameters, it initiates
    941940    /// all of the attributes to \c 0.
    942941    BfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0),
     
    968967    typedef TR Base;
    969968
    970     ///The type of the digraph the algorithm runs on.
    971969    typedef typename TR::Digraph Digraph;
    972970
     
    976974    typedef typename Digraph::OutArcIt OutArcIt;
    977975
    978     ///\brief The type of the map that stores the predecessor
    979     ///arcs of the shortest paths.
    980976    typedef typename TR::PredMap PredMap;
    981     ///\brief The type of the map that stores the distances of the nodes.
    982977    typedef typename TR::DistMap DistMap;
    983     ///\brief The type of the map that indicates which nodes are reached.
    984978    typedef typename TR::ReachedMap ReachedMap;
    985     ///\brief The type of the map that indicates which nodes are processed.
    986979    typedef typename TR::ProcessedMap ProcessedMap;
    987     ///The type of the shortest paths
    988980    typedef typename TR::Path Path;
    989981
     
    10681060      SetPredMapBase(const TR &b) : TR(b) {}
    10691061    };
    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.
     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.
    10751068    template<class T>
    10761069    BfsWizard<SetPredMapBase<T> > predMap(const T &t)
     
    10861079      SetReachedMapBase(const TR &b) : TR(b) {}
    10871080    };
    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.
     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.
    10931087    template<class T>
    10941088    BfsWizard<SetReachedMapBase<T> > reachedMap(const T &t)
     
    11041098      SetDistMapBase(const TR &b) : TR(b) {}
    11051099    };
    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.
     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.
    11111107    template<class T>
    11121108    BfsWizard<SetDistMapBase<T> > distMap(const T &t)
     
    11221118      SetProcessedMapBase(const TR &b) : TR(b) {}
    11231119    };
    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.
     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.
    11291126    template<class T>
    11301127    BfsWizard<SetProcessedMapBase<T> > processedMap(const T &t)
     
    11951192  /// This class defines the interface of the BfsVisit events, and
    11961193  /// it could be the base of a real visitor class.
    1197   template <typename _Digraph>
     1194  template <typename GR>
    11981195  struct BfsVisitor {
    1199     typedef _Digraph Digraph;
     1196    typedef GR Digraph;
    12001197    typedef typename Digraph::Arc Arc;
    12011198    typedef typename Digraph::Node Node;
     
    12251222  };
    12261223#else
    1227   template <typename _Digraph>
     1224  template <typename GR>
    12281225  struct BfsVisitor {
    1229     typedef _Digraph Digraph;
     1226    typedef GR Digraph;
    12301227    typedef typename Digraph::Arc Arc;
    12311228    typedef typename Digraph::Node Node;
     
    12551252  ///
    12561253  /// Default traits class of BfsVisit class.
    1257   /// \tparam _Digraph The type of the digraph the algorithm runs on.
    1258   template<class _Digraph>
     1254  /// \tparam GR The type of the digraph the algorithm runs on.
     1255  template<class GR>
    12591256  struct BfsVisitDefaultTraits {
    12601257
    12611258    /// \brief The type of the digraph the algorithm runs on.
    1262     typedef _Digraph Digraph;
     1259    typedef GR Digraph;
    12631260
    12641261    /// \brief The type of the map that indicates which nodes are reached.
    12651262    ///
    12661263    /// The type of the map that indicates which nodes are reached.
    1267     /// It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     1264    /// It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    12681265    typedef typename Digraph::template NodeMap<bool> ReachedMap;
    12691266
     
    12811278  /// \ingroup search
    12821279  ///
    1283   /// \brief %BFS algorithm class with visitor interface.
     1280  /// \brief BFS algorithm class with visitor interface.
    12841281  ///
    1285   /// This class provides an efficient implementation of the %BFS algorithm
     1282  /// This class provides an efficient implementation of the BFS algorithm
    12861283  /// with visitor interface.
    12871284  ///
    1288   /// The %BfsVisit class provides an alternative interface to the Bfs
     1285  /// The BfsVisit class provides an alternative interface to the Bfs
    12891286  /// class. It works with callback mechanism, the BfsVisit object calls
    12901287  /// the member functions of the \c Visitor class on every BFS event.
     
    12951292  /// instead.
    12961293  ///
    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
     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
    13031300  /// does not observe the BFS events. If you want to observe the BFS
    13041301  /// events, you should implement your own visitor class.
    1305   /// \tparam _Traits Traits class to set various data types used by the
     1302  /// \tparam TR Traits class to set various data types used by the
    13061303  /// algorithm. The default traits class is
    1307   /// \ref BfsVisitDefaultTraits "BfsVisitDefaultTraits<_Digraph>".
     1304  /// \ref BfsVisitDefaultTraits "BfsVisitDefaultTraits<GR>".
    13081305  /// See \ref BfsVisitDefaultTraits for the documentation of
    13091306  /// a BFS visit traits class.
    13101307#ifdef DOXYGEN
    1311   template <typename _Digraph, typename _Visitor, typename _Traits>
     1308  template <typename GR, typename VS, typename TR>
    13121309#else
    1313   template <typename _Digraph = ListDigraph,
    1314             typename _Visitor = BfsVisitor<_Digraph>,
    1315             typename _Traits = BfsVisitDefaultTraits<_Digraph> >
     1310  template <typename GR = ListDigraph,
     1311            typename VS = BfsVisitor<GR>,
     1312            typename TR = BfsVisitDefaultTraits<GR> >
    13161313#endif
    13171314  class BfsVisit {
     
    13191316
    13201317    ///The traits class.
    1321     typedef _Traits Traits;
     1318    typedef TR Traits;
    13221319
    13231320    ///The type of the digraph the algorithm runs on.
     
    13251322
    13261323    ///The visitor type used by the algorithm.
    1327     typedef _Visitor Visitor;
     1324    typedef VS Visitor;
    13281325
    13291326    ///The type of the map that indicates which nodes are reached.
     
    14261423    /// The simplest way to execute the BFS algorithm is to use one of the
    14271424    /// member functions called \ref run(Node) "run()".\n
    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
     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
    14301427    /// \ref addSource(). Finally the actual path computation can be
    14311428    /// performed with one of the \ref start() functions.
     
    17361733    ///@{
    17371734
    1738     /// \brief Checks if a node is reached from the root(s).
     1735    /// \brief Checks if the given node is reached from the root(s).
    17391736    ///
    17401737    /// Returns \c true if \c v is reached from the root(s).
Note: See TracChangeset for help on using the changeset viewer.