[Lemon-commits] Peter Kovacs: Rename min mean cycle classes and ...

Lemon HG hg at lemon.cs.elte.hu
Sun Mar 14 08:37:12 CET 2010


details:   http://lemon.cs.elte.hu/hg/lemon/rev/d3ea191c3412
changeset: 942:d3ea191c3412
user:      Peter Kovacs <kpeter [at] inf.elte.hu>
date:      Sat Mar 13 22:01:38 2010 +0100
description:
	Rename min mean cycle classes and their members (#179) with respect
	to the possible introduction of min ratio cycle algorithms in the
	future.

	The renamed classes:
	 - Karp --> KarpMmc
	 - HartmannOrlin --> HartmannOrlinMmc
	 - Howard --> HowardMmc

	The renamed members:
	 - cycleLength() --> cycleCost()
	 - cycleArcNum() --> cycleSize()
	 - findMinMean() --> findCycleMean()
	 - Value --> Cost
	 - LargeValue --> LargeCost
	 - SetLargeValue --> SetLargeCost

diffstat:

 lemon/Makefile.am           |    6 +-
 lemon/cycle_canceling.h     |   14 +-
 lemon/hartmann_orlin.h      |  230 +++++++++++++++++++++++-----------------------
 lemon/howard.h              |  218 +++++++++++++++++++++---------------------
 lemon/karp.h                |  222 ++++++++++++++++++++++----------------------
 test/min_mean_cycle_test.cc |   82 ++++++++--------
 6 files changed, 386 insertions(+), 386 deletions(-)

diffs (truncated from 1859 to 300 lines):

diff --git a/lemon/Makefile.am b/lemon/Makefile.am
--- a/lemon/Makefile.am
+++ b/lemon/Makefile.am
@@ -89,10 +89,10 @@
 	lemon/gomory_hu.h \
 	lemon/graph_to_eps.h \
 	lemon/grid_graph.h \
-	lemon/hartmann_orlin.h \
-	lemon/howard.h \
+	lemon/hartmann_orlin_mmc.h \
+	lemon/howard_mmc.h \
 	lemon/hypercube_graph.h \
-	lemon/karp.h \
+	lemon/karp_mmc.h \
 	lemon/kruskal.h \
 	lemon/hao_orlin.h \
 	lemon/lgf_reader.h \
diff --git a/lemon/cycle_canceling.h b/lemon/cycle_canceling.h
--- a/lemon/cycle_canceling.h
+++ b/lemon/cycle_canceling.h
@@ -34,7 +34,7 @@
 #include <lemon/adaptors.h>
 #include <lemon/circulation.h>
 #include <lemon/bellman_ford.h>
-#include <lemon/howard.h>
+#include <lemon/howard_mmc.h>
 
 namespace lemon {
 
@@ -924,14 +924,14 @@
     void startMinMeanCycleCanceling() {
       typedef SimplePath<StaticDigraph> SPath;
       typedef typename SPath::ArcIt SPathArcIt;
-      typedef typename Howard<StaticDigraph, CostArcMap>
+      typedef typename HowardMmc<StaticDigraph, CostArcMap>
         ::template SetPath<SPath>::Create MMC;
       
       SPath cycle;
       MMC mmc(_sgr, _cost_map);
       mmc.cycle(cycle);
       buildResidualNetwork();
-      while (mmc.findMinMean() && mmc.cycleLength() < 0) {
+      while (mmc.findCycleMean() && mmc.cycleCost() < 0) {
         // Find the cycle
         mmc.findCycle();
 
@@ -1132,17 +1132,17 @@
             }
           }
         } else {
-          typedef Howard<StaticDigraph, CostArcMap> MMC;
+          typedef HowardMmc<StaticDigraph, CostArcMap> MMC;
           typedef typename BellmanFord<StaticDigraph, CostArcMap>
             ::template SetDistMap<CostNodeMap>::Create BF;
 
           // Set epsilon to the minimum cycle mean
           buildResidualNetwork();
           MMC mmc(_sgr, _cost_map);
-          mmc.findMinMean();
+          mmc.findCycleMean();
           epsilon = -mmc.cycleMean();
-          Cost cycle_cost = mmc.cycleLength();
-          int cycle_size = mmc.cycleArcNum();
+          Cost cycle_cost = mmc.cycleCost();
+          int cycle_size = mmc.cycleSize();
           
           // Compute feasible potentials for the current epsilon
           for (int i = 0; i != int(_cost_vec.size()); ++i) {
diff --git a/lemon/hartmann_orlin.h b/lemon/hartmann_orlin_mmc.h
rename from lemon/hartmann_orlin.h
rename to lemon/hartmann_orlin_mmc.h
--- a/lemon/hartmann_orlin.h
+++ b/lemon/hartmann_orlin_mmc.h
@@ -16,8 +16,8 @@
  *
  */
 
-#ifndef LEMON_HARTMANN_ORLIN_H
-#define LEMON_HARTMANN_ORLIN_H
+#ifndef LEMON_HARTMANN_ORLIN_MMC_H
+#define LEMON_HARTMANN_ORLIN_MMC_H
 
 /// \ingroup min_mean_cycle
 ///
@@ -33,37 +33,37 @@
 
 namespace lemon {
 
-  /// \brief Default traits class of HartmannOrlin algorithm.
+  /// \brief Default traits class of HartmannOrlinMmc class.
   ///
-  /// Default traits class of HartmannOrlin algorithm.
+  /// Default traits class of HartmannOrlinMmc class.
   /// \tparam GR The type of the digraph.
-  /// \tparam LEN The type of the length map.
+  /// \tparam CM The type of the cost map.
   /// It must conform to the \ref concepts::Rea_data "Rea_data" concept.
 #ifdef DOXYGEN
-  template <typename GR, typename LEN>
+  template <typename GR, typename CM>
 #else
-  template <typename GR, typename LEN,
-    bool integer = std::numeric_limits<typename LEN::Value>::is_integer>
+  template <typename GR, typename CM,
+    bool integer = std::numeric_limits<typename CM::Value>::is_integer>
 #endif
-  struct HartmannOrlinDefaultTraits
+  struct HartmannOrlinMmcDefaultTraits
   {
     /// The type of the digraph
     typedef GR Digraph;
-    /// The type of the length map
-    typedef LEN LengthMap;
-    /// The type of the arc lengths
-    typedef typename LengthMap::Value Value;
+    /// The type of the cost map
+    typedef CM CostMap;
+    /// The type of the arc costs
+    typedef typename CostMap::Value Cost;
 
-    /// \brief The large value type used for internal computations
+    /// \brief The large cost type used for internal computations
     ///
-    /// The large value type used for internal computations.
-    /// It is \c long \c long if the \c Value type is integer,
+    /// The large cost type used for internal computations.
+    /// It is \c long \c long if the \c Cost type is integer,
     /// otherwise it is \c double.
-    /// \c Value must be convertible to \c LargeValue.
-    typedef double LargeValue;
+    /// \c Cost must be convertible to \c LargeCost.
+    typedef double LargeCost;
 
     /// The tolerance type used for internal computations
-    typedef lemon::Tolerance<LargeValue> Tolerance;
+    typedef lemon::Tolerance<LargeCost> Tolerance;
 
     /// \brief The path type of the found cycles
     ///
@@ -73,19 +73,19 @@
     typedef lemon::Path<Digraph> Path;
   };
 
-  // Default traits class for integer value types
-  template <typename GR, typename LEN>
-  struct HartmannOrlinDefaultTraits<GR, LEN, true>
+  // Default traits class for integer cost types
+  template <typename GR, typename CM>
+  struct HartmannOrlinMmcDefaultTraits<GR, CM, true>
   {
     typedef GR Digraph;
-    typedef LEN LengthMap;
-    typedef typename LengthMap::Value Value;
+    typedef CM CostMap;
+    typedef typename CostMap::Value Cost;
 #ifdef LEMON_HAVE_LONG_LONG
-    typedef long long LargeValue;
+    typedef long long LargeCost;
 #else
-    typedef long LargeValue;
+    typedef long LargeCost;
 #endif
-    typedef lemon::Tolerance<LargeValue> Tolerance;
+    typedef lemon::Tolerance<LargeCost> Tolerance;
     typedef lemon::Path<Digraph> Path;
   };
 
@@ -97,44 +97,44 @@
   /// a minimum mean cycle.
   ///
   /// This class implements the Hartmann-Orlin algorithm for finding
-  /// a directed cycle of minimum mean length (cost) in a digraph
+  /// a directed cycle of minimum mean cost in a digraph
   /// \ref amo93networkflows, \ref dasdan98minmeancycle.
   /// It is an improved version of \ref Karp "Karp"'s original algorithm,
   /// it applies an efficient early termination scheme.
   /// It runs in time O(ne) and uses space O(n<sup>2</sup>+e).
   ///
   /// \tparam GR The type of the digraph the algorithm runs on.
-  /// \tparam LEN The type of the length map. The default
+  /// \tparam CM The type of the cost map. The default
   /// map type is \ref concepts::Digraph::ArcMap "GR::ArcMap<int>".
   /// \tparam TR The traits class that defines various types used by the
-  /// algorithm. By default, it is \ref HartmannOrlinDefaultTraits
-  /// "HartmannOrlinDefaultTraits<GR, LEN>".
+  /// algorithm. By default, it is \ref HartmannOrlinMmcDefaultTraits
+  /// "HartmannOrlinMmcDefaultTraits<GR, CM>".
   /// In most cases, this parameter should not be set directly,
   /// consider to use the named template parameters instead.
 #ifdef DOXYGEN
-  template <typename GR, typename LEN, typename TR>
+  template <typename GR, typename CM, typename TR>
 #else
   template < typename GR,
-             typename LEN = typename GR::template ArcMap<int>,
-             typename TR = HartmannOrlinDefaultTraits<GR, LEN> >
+             typename CM = typename GR::template ArcMap<int>,
+             typename TR = HartmannOrlinMmcDefaultTraits<GR, CM> >
 #endif
-  class HartmannOrlin
+  class HartmannOrlinMmc
   {
   public:
 
     /// The type of the digraph
     typedef typename TR::Digraph Digraph;
-    /// The type of the length map
-    typedef typename TR::LengthMap LengthMap;
-    /// The type of the arc lengths
-    typedef typename TR::Value Value;
+    /// The type of the cost map
+    typedef typename TR::CostMap CostMap;
+    /// The type of the arc costs
+    typedef typename TR::Cost Cost;
 
-    /// \brief The large value type
+    /// \brief The large cost type
     ///
-    /// The large value type used for internal computations.
-    /// By default, it is \c long \c long if the \c Value type is integer,
+    /// The large cost type used for internal computations.
+    /// By default, it is \c long \c long if the \c Cost type is integer,
     /// otherwise it is \c double.
-    typedef typename TR::LargeValue LargeValue;
+    typedef typename TR::LargeCost LargeCost;
 
     /// The tolerance type
     typedef typename TR::Tolerance Tolerance;
@@ -142,11 +142,11 @@
     /// \brief The path type of the found cycles
     ///
     /// The path type of the found cycles.
-    /// Using the \ref HartmannOrlinDefaultTraits "default traits class",
+    /// Using the \ref HartmannOrlinMmcDefaultTraits "default traits class",
     /// it is \ref lemon::Path "Path<Digraph>".
     typedef typename TR::Path Path;
 
-    /// The \ref HartmannOrlinDefaultTraits "traits class" of the algorithm
+    /// The \ref HartmannOrlinMmcDefaultTraits "traits class" of the algorithm
     typedef TR Traits;
 
   private:
@@ -156,9 +156,9 @@
     // Data sturcture for path data
     struct PathData
     {
-      LargeValue dist;
+      LargeCost dist;
       Arc pred;
-      PathData(LargeValue d, Arc p = INVALID) :
+      PathData(LargeCost d, Arc p = INVALID) :
         dist(d), pred(p) {}
     };
 
@@ -169,8 +169,8 @@
 
     // The digraph the algorithm runs on
     const Digraph &_gr;
-    // The length of the arcs
-    const LengthMap &_length;
+    // The cost of the arcs
+    const CostMap &_cost;
 
     // Data for storing the strongly connected components
     int _comp_num;
@@ -181,7 +181,7 @@
 
     // Data for the found cycles
     bool _curr_found, _best_found;
-    LargeValue _curr_length, _best_length;
+    LargeCost _curr_cost, _best_cost;
     int _curr_size, _best_size;
     Node _curr_node, _best_node;
     int _curr_level, _best_level;
@@ -197,7 +197,7 @@
     Tolerance _tolerance;
 
     // Infinite constant
-    const LargeValue INF;
+    const LargeCost INF;
 
   public:
 
@@ -205,20 +205,20 @@
     /// @{
 
     template <typename T>
-    struct SetLargeValueTraits : public Traits {
-      typedef T LargeValue;
+    struct SetLargeCostTraits : public Traits {
+      typedef T LargeCost;
       typedef lemon::Tolerance<T> Tolerance;
     };
 
     /// \brief \ref named-templ-param "Named parameter" for setting
-    /// \c LargeValue type.
+    /// \c LargeCost type.
     ///
-    /// \ref named-templ-param "Named parameter" for setting \c LargeValue
+    /// \ref named-templ-param "Named parameter" for setting \c LargeCost



More information about the Lemon-commits mailing list