Index: lemon/capacity_scaling.h
===================================================================
--- lemon/capacity_scaling.h	(revision 2553)
+++ lemon/capacity_scaling.h	(revision 2556)
@@ -23,6 +23,5 @@
 ///
 /// \file
-/// \brief The capacity scaling algorithm for finding a minimum cost
-/// flow.
+/// \brief The capacity scaling algorithm for finding a minimum cost flow.
 
 #include <lemon/graph_adaptor.h>
@@ -50,5 +49,5 @@
   ///
   /// \warning
-  /// - Edge capacities and costs should be nonnegative integers.
+  /// - Edge capacities and costs should be non-negative integers.
   ///   However \c CostMap::Value should be signed type.
   /// - Supply values should be signed integers.
@@ -67,10 +66,5 @@
   class CapacityScaling
   {
-    typedef typename Graph::Node Node;
-    typedef typename Graph::NodeIt NodeIt;
-    typedef typename Graph::Edge Edge;
-    typedef typename Graph::EdgeIt EdgeIt;
-    typedef typename Graph::InEdgeIt InEdgeIt;
-    typedef typename Graph::OutEdgeIt OutEdgeIt;
+    GRAPH_TYPEDEFS(typename Graph);
 
     typedef typename LowerMap::Value Lower;
@@ -78,11 +72,11 @@
     typedef typename CostMap::Value Cost;
     typedef typename SupplyMap::Value Supply;
-    typedef typename Graph::template EdgeMap<Capacity> CapacityRefMap;
-    typedef typename Graph::template NodeMap<Supply> SupplyRefMap;
+    typedef typename Graph::template EdgeMap<Capacity> CapacityEdgeMap;
+    typedef typename Graph::template NodeMap<Supply> SupplyNodeMap;
     typedef typename Graph::template NodeMap<Edge> PredMap;
 
   public:
 
-    /// \brief Type to enable or disable capacity scaling.
+    /// Type to enable or disable capacity scaling.
     enum ScalingEnum {
       WITH_SCALING = 0,
@@ -90,7 +84,7 @@
     };
 
-    /// \brief The type of the flow map.
-    typedef CapacityRefMap FlowMap;
-    /// \brief The type of the potential map.
+    /// The type of the flow map.
+    typedef typename Graph::template EdgeMap<Capacity> FlowMap;
+    /// The type of the potential map.
     typedef typename Graph::template NodeMap<Cost> PotentialMap;
 
@@ -111,32 +105,32 @@
     protected:
 
-      /// \brief The directed graph the algorithm runs on.
+      /// The directed graph the algorithm runs on.
       const Graph &graph;
 
-      /// \brief The flow map.
+      /// The flow map.
       const FlowMap &flow;
-      /// \brief The residual capacity map.
-      const CapacityRefMap &res_cap;
-      /// \brief The cost map.
+      /// The residual capacity map.
+      const CapacityEdgeMap &res_cap;
+      /// The cost map.
       const CostMap &cost;
-      /// \brief The excess map.
-      const SupplyRefMap &excess;
-
-      /// \brief The potential map.
+      /// The excess map.
+      const SupplyNodeMap &excess;
+
+      /// The potential map.
       PotentialMap &potential;
 
-      /// \brief The distance map.
+      /// The distance map.
       CostNodeMap dist;
-      /// \brief The map of predecessors edges.
+      /// The map of predecessors edges.
       PredMap &pred;
-      /// \brief The processed (i.e. permanently labeled) nodes.
+      /// The processed (i.e. permanently labeled) nodes.
       std::vector<Node> proc_nodes;
 
     public:
 
-      /// \brief The constructor of the class.
+      /// The constructor of the class.
       ResidualDijkstra( const Graph &_graph,
                         const FlowMap &_flow,
-                        const CapacityRefMap &_res_cap,
+                        const CapacityEdgeMap &_res_cap,
                         const CostMap &_cost,
                         const SupplyMap &_excess,
@@ -148,5 +142,5 @@
       {}
 
-      /// \brief Runs the algorithm from the given source node.
+      /// Runs the algorithm from the given source node.
       Node run(Node s, Capacity delta) {
         HeapCrossRef heap_cross_ref(graph, Heap::PRE_HEAP);
@@ -223,44 +217,41 @@
   protected:
 
-    /// \brief The directed graph the algorithm runs on.
+    /// The directed graph the algorithm runs on.
     const Graph &graph;
-    /// \brief The original lower bound map.
+    /// The original lower bound map.
     const LowerMap *lower;
-    /// \brief The modified capacity map.
-    CapacityRefMap capacity;
-    /// \brief The cost map.
+    /// The modified capacity map.
+    CapacityEdgeMap capacity;
+    /// The cost map.
     const CostMap &cost;
-    /// \brief The modified supply map.
-    SupplyRefMap supply;
-    /// \brief The sum of supply values equals zero.
+    /// The modified supply map.
+    SupplyNodeMap supply;
     bool valid_supply;
 
-    /// \brief The edge map of the current flow.
+    /// The edge map of the current flow.
     FlowMap flow;
-    /// \brief The potential node map.
+    /// The potential node map.
     PotentialMap potential;
 
-    /// \brief The residual capacity map.
-    CapacityRefMap res_cap;
-    /// \brief The excess map.
-    SupplyRefMap excess;
-    /// \brief The excess nodes (i.e. nodes with positive excess).
+    /// The residual capacity map.
+    CapacityEdgeMap res_cap;
+    /// The excess map.
+    SupplyNodeMap excess;
+    /// The excess nodes (i.e. the nodes with positive excess).
     std::vector<Node> excess_nodes;
-    /// \brief The index of the next excess node.
-    int next_node;
-
-    /// \brief The scaling status (enabled or disabled).
+    /// The deficit nodes (i.e. the nodes with negative excess).
+    std::vector<Node> deficit_nodes;
+
+    /// The scaling status (enabled or disabled).
     ScalingEnum scaling;
-    /// \brief The delta parameter used for capacity scaling.
+    /// The \c delta parameter used for capacity scaling.
     Capacity delta;
-    /// \brief The maximum number of phases.
-    Capacity phase_num;
-    /// \brief The deficit nodes.
-    std::vector<Node> deficit_nodes;
+    /// The maximum number of phases.
+    int phase_num;
 
     /// \brief Implementation of the \ref Dijkstra algorithm for
     /// finding augmenting shortest paths in the residual network.
     ResidualDijkstra dijkstra;
-    /// \brief The map of predecessors edges.
+    /// The map of predecessors edges.
     PredMap pred;
 
@@ -286,5 +277,5 @@
       dijkstra(graph, flow, res_cap, cost, excess, potential, pred)
     {
-      // Removing nonzero lower bounds
+      // Removing non-zero lower bounds
       capacity = subMap(_capacity, _lower);
       res_cap = capacity;
@@ -336,6 +327,5 @@
     /// \param _t The target node.
     /// \param _flow_value The required amount of flow from node \c _s
-    /// to node \c _t (i.e. the supply of \c _s and the demand of
-    /// \c _t).
+    /// to node \c _t (i.e. the supply of \c _s and the demand of \c _t).
     CapacityScaling( const Graph &_graph,
                      const LowerMap &_lower,
@@ -349,5 +339,5 @@
       dijkstra(graph, flow, res_cap, cost, excess, potential)
     {
-      // Removing nonzero lower bounds
+      // Removing non-zero lower bounds
       capacity = subMap(_capacity, _lower);
       res_cap = capacity;
@@ -375,6 +365,5 @@
     /// \param _t The target node.
     /// \param _flow_value The required amount of flow from node \c _s
-    /// to node \c _t (i.e. the supply of \c _s and the demand of
-    /// \c _t).
+    /// to node \c _t (i.e. the supply of \c _s and the demand of \c _t).
     CapacityScaling( const Graph &_graph,
                      const CapacityMap &_capacity,
@@ -392,4 +381,20 @@
     }
 
+    /// \brief Runs the algorithm.
+    ///
+    /// Runs the algorithm.
+    ///
+    /// \param scaling_mode The scaling mode. In case of WITH_SCALING
+    /// capacity scaling is enabled in the algorithm (this is the
+    /// default) otherwise it is disabled.
+    /// If the maximum edge capacity and/or the amount of total supply
+    /// is small, the algorithm could be slightly faster without
+    /// scaling.
+    ///
+    /// \return \c true if a feasible flow can be found.
+    bool run(int scaling_mode = WITH_SCALING) {
+      return init(scaling_mode) && start();
+    }
+
     /// \brief Returns a const reference to the flow map.
     ///
@@ -425,22 +430,7 @@
     }
 
-    /// \brief Runs the algorithm.
-    ///
-    /// Runs the algorithm.
-    ///
-    /// \param scaling_mode The scaling mode. In case of WITH_SCALING
-    /// capacity scaling is enabled in the algorithm (this is the
-    /// default value) otherwise it is disabled.
-    /// If the maximum edge capacity and/or the amount of total supply
-    /// is small, the algorithm could be faster without scaling.
-    ///
-    /// \return \c true if a feasible flow can be found.
-    bool run(int scaling_mode = WITH_SCALING) {
-      return init(scaling_mode) && start();
-    }
-
   protected:
 
-    /// \brief Initializes the algorithm.
+    /// Initializes the algorithm.
     bool init(int scaling_mode) {
       if (!valid_supply) return false;
@@ -466,5 +456,5 @@
     }
 
-    /// \brief Executes the algorithm.
+    /// Executes the algorithm.
     bool start() {
       if (delta > 1)
@@ -507,5 +497,5 @@
           if (excess[n] <= -delta) deficit_nodes.push_back(n);
         }
-        next_node = 0;
+        int next_node = 0;
 
         // Finding augmenting shortest paths
@@ -573,5 +563,5 @@
       }
 
-      // Handling nonzero lower bounds
+      // Handling non-zero lower bounds
       if (lower) {
         for (EdgeIt e(graph); e != INVALID; ++e)
@@ -585,9 +575,8 @@
     bool startWithoutScaling() {
       // Finding excess nodes
-      for (NodeIt n(graph); n != INVALID; ++n) {
+      for (NodeIt n(graph); n != INVALID; ++n)
         if (excess[n] > 0) excess_nodes.push_back(n);
-      }
       if (excess_nodes.size() == 0) return true;
-      next_node = 0;
+      int next_node = 0;
 
       // Finding shortest paths
@@ -632,5 +621,5 @@
       }
 
-      // Handling nonzero lower bounds
+      // Handling non-zero lower bounds
       if (lower) {
         for (EdgeIt e(graph); e != INVALID; ++e)
