COIN-OR::LEMON - Graph Library

Changeset 759:d66ff32624e2 in lemon-main


Ignore:
Timestamp:
08/03/09 14:35:38 (15 years ago)
Author:
Peter Kovacs <kpeter@…>
Branch:
default
Phase:
public
Message:

Simplify the interface of MinMeanCycle? (#179)
Remove init() and reset(), and move their content into findMinMean().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/min_mean_cycle.h

    r758 r759  
    123123    ///
    124124    /// If you don't call this function before calling \ref run() or
    125     /// \ref init(), it will allocate a local \ref Path "path"
     125    /// \ref findMinMean(), it will allocate a local \ref Path "path"
    126126    /// structure. The destuctor deallocates this automatically
    127127    /// allocated object, of course.
     
    145145    /// The simplest way to execute the algorithm is to call the \ref run()
    146146    /// function.\n
    147     /// If you only need the minimum mean length, you may call \ref init()
    148     /// and \ref findMinMean().
    149     /// If you would like to run the algorithm again (e.g. the underlying
    150     /// digraph and/or the arc lengths has been modified), you may not
    151     /// create a new instance of the class, rather call \ref reset(),
    152     /// \ref findMinMean() and \ref findCycle() instead.
     147    /// If you only need the minimum mean length, you may call
     148    /// \ref findMinMean().
    153149
    154150    /// @{
     
    157153    ///
    158154    /// This function runs the algorithm.
     155    /// It can be called more than once (e.g. if the underlying digraph
     156    /// and/or the arc lengths have been modified).
    159157    ///
    160158    /// \return \c true if a directed cycle exists in the digraph.
    161159    ///
    162     /// \note Apart from the return value, <tt>mmc.run()</tt> is just a
    163     /// shortcut of the following code.
     160    /// \note <tt>mmc.run()</tt> is just a shortcut of the following code.
    164161    /// \code
    165     ///   mmc.init();
    166     ///   mmc.findMinMean();
    167     ///   mmc.findCycle();
     162    ///   return mmc.findMinMean() && mmc.findCycle();
    168163    /// \endcode
    169164    bool run() {
    170       init();
    171165      return findMinMean() && findCycle();
    172166    }
    173167
    174     /// \brief Initialize the internal data structures.
    175     ///
    176     /// This function initializes the internal data structures.
    177     ///
    178     /// \sa reset()
    179     void init() {
     168    /// \brief Find the minimum cycle mean.
     169    ///
     170    /// This function finds the minimum mean length of the directed
     171    /// cycles in the digraph.
     172    ///
     173    /// \return \c true if a directed cycle exists in the digraph.
     174    bool findMinMean() {
     175      // Initialize
    180176      _tol.epsilon(1e-6);
    181177      if (!_cycle_path) {
     
    183179        _cycle_path = new Path;
    184180      }
     181      _cycle_path->clear();
    185182      _cycle_found = false;
     183
     184      // Find the minimum cycle mean in the components
    186185      _comp_num = stronglyConnectedComponents(_gr, _comp);
    187     }
    188 
    189     /// \brief Reset the internal data structures.
    190     ///
    191     /// This function resets the internal data structures so that
    192     /// findMinMean() and findCycle() can be called again (e.g. when the
    193     /// underlying digraph and/or the arc lengths has been modified).
    194     ///
    195     /// \sa init()
    196     void reset() {
    197       if (_cycle_path) _cycle_path->clear();
    198       _cycle_found = false;
    199       _comp_num = stronglyConnectedComponents(_gr, _comp);
    200     }
    201 
    202     /// \brief Find the minimum cycle mean.
    203     ///
    204     /// This function computes all the required data and finds the
    205     /// minimum mean length of the directed cycles in the digraph.
    206     ///
    207     /// \return \c true if a directed cycle exists in the digraph.
    208     ///
    209     /// \pre \ref init() must be called before using this function.
    210     bool findMinMean() {
    211       // Find the minimum cycle mean in the components
    212186      for (int comp = 0; comp < _comp_num; ++comp) {
    213187        if (!initCurrentComponent(comp)) continue;
     
    228202    /// \return \c true if a directed cycle exists in the digraph.
    229203    ///
    230     /// \pre \ref init() and \ref findMinMean() must be called before
    231     /// using this function.
     204    /// \pre \ref findMinMean() must be called before using this function.
    232205    bool findCycle() {
    233206      if (!_cycle_found) return false;
     
    243216
    244217    /// \name Query Functions
    245     /// The result of the algorithm can be obtained using these
     218    /// The results of the algorithm can be obtained using these
    246219    /// functions.\n
    247220    /// The algorithm should be executed before using them.
Note: See TracChangeset for help on using the changeset viewer.