[Lemon-commits] Peter Kovacs: Internal restructuring and renamin...

Lemon HG hg at lemon.cs.elte.hu
Tue Apr 21 16:33:30 CEST 2009


details:   http://lemon.cs.elte.hu/hg/lemon/rev/425cc8328c0e
changeset: 635:425cc8328c0e
user:      Peter Kovacs <kpeter [at] inf.elte.hu>
date:      Mon Mar 23 23:54:42 2009 +0100
description:
	Internal restructuring and renamings in NetworkSimplex (#234)

diffstat:

 lemon/network_simplex.h |  223 +++++++++++++++++++++-----------------------
 1 files changed, 105 insertions(+), 118 deletions(-)

diffs (truncated from 610 to 300 lines):

diff --git a/lemon/network_simplex.h b/lemon/network_simplex.h
--- a/lemon/network_simplex.h
+++ b/lemon/network_simplex.h
@@ -28,6 +28,7 @@
 #include <limits>
 #include <algorithm>
 
+#include <lemon/core.h>
 #include <lemon/math.h>
 
 namespace lemon {
@@ -120,7 +121,7 @@
   private:
 
     // References for the original data
-    const Digraph &_orig_graph;
+    const Digraph &_graph;
     const LowerMap *_orig_lower;
     const CapacityMap &_orig_cap;
     const CostMap &_orig_cost;
@@ -130,22 +131,21 @@
     Capacity _orig_flow_value;
 
     // Result maps
-    FlowMap *_flow_result;
-    PotentialMap *_potential_result;
+    FlowMap *_flow_map;
+    PotentialMap *_potential_map;
     bool _local_flow;
     bool _local_potential;
 
-    // Data structures for storing the graph
-    ArcVector _arc;
-    NodeVector _node;
-    IntNodeMap _node_id;
-    IntVector _source;
-    IntVector _target;
-
     // The number of nodes and arcs in the original graph
     int _node_num;
     int _arc_num;
 
+    // Data structures for storing the graph
+    IntNodeMap _node_id;
+    ArcVector _arc_ref;
+    IntVector _source;
+    IntVector _target;
+
     // Node and arc maps
     CapacityVector _cap;
     CostVector _cost;
@@ -153,23 +153,18 @@
     CapacityVector _flow;
     CostVector _pi;
 
-    // Node and arc maps for the spanning tree structure
+    // Data for storing the spanning tree structure
     IntVector _depth;
     IntVector _parent;
     IntVector _pred;
     IntVector _thread;
     BoolVector _forward;
     IntVector _state;
-
-    // The root node
     int _root;
 
-    // The entering arc in the current pivot iteration
-    int _in_arc;
-
     // Temporary data used in the current pivot iteration
-    int join, u_in, v_in, u_out, v_out;
-    int right, first, second, last;
+    int in_arc, join, u_in, v_in, u_out, v_out;
+    int first, second, right, last;
     int stem, par_stem, new_stem;
     Capacity delta;
 
@@ -187,7 +182,6 @@
     private:
 
       // References to the NetworkSimplex class
-      const ArcVector &_arc;
       const IntVector  &_source;
       const IntVector  &_target;
       const CostVector &_cost;
@@ -203,9 +197,9 @@
 
       /// Constructor
       FirstEligiblePivotRule(NetworkSimplex &ns) :
-        _arc(ns._arc), _source(ns._source), _target(ns._target),
+        _source(ns._source), _target(ns._target),
         _cost(ns._cost), _state(ns._state), _pi(ns._pi),
-        _in_arc(ns._in_arc), _arc_num(ns._arc_num), _next_arc(0)
+        _in_arc(ns.in_arc), _arc_num(ns._arc_num), _next_arc(0)
       {}
 
       /// Find next entering arc
@@ -245,7 +239,6 @@
     private:
 
       // References to the NetworkSimplex class
-      const ArcVector &_arc;
       const IntVector  &_source;
       const IntVector  &_target;
       const CostVector &_cost;
@@ -258,9 +251,9 @@
 
       /// Constructor
       BestEligiblePivotRule(NetworkSimplex &ns) :
-        _arc(ns._arc), _source(ns._source), _target(ns._target),
+        _source(ns._source), _target(ns._target),
         _cost(ns._cost), _state(ns._state), _pi(ns._pi),
-        _in_arc(ns._in_arc), _arc_num(ns._arc_num)
+        _in_arc(ns.in_arc), _arc_num(ns._arc_num)
       {}
 
       /// Find next entering arc
@@ -291,7 +284,6 @@
     private:
 
       // References to the NetworkSimplex class
-      const ArcVector &_arc;
       const IntVector  &_source;
       const IntVector  &_target;
       const CostVector &_cost;
@@ -308,9 +300,9 @@
 
       /// Constructor
       BlockSearchPivotRule(NetworkSimplex &ns) :
-        _arc(ns._arc), _source(ns._source), _target(ns._target),
+        _source(ns._source), _target(ns._target),
         _cost(ns._cost), _state(ns._state), _pi(ns._pi),
-        _in_arc(ns._in_arc), _arc_num(ns._arc_num), _next_arc(0)
+        _in_arc(ns.in_arc), _arc_num(ns._arc_num), _next_arc(0)
       {
         // The main parameters of the pivot rule
         const double BLOCK_SIZE_FACTOR = 2.0;
@@ -370,7 +362,6 @@
     private:
 
       // References to the NetworkSimplex class
-      const ArcVector &_arc;
       const IntVector  &_source;
       const IntVector  &_target;
       const CostVector &_cost;
@@ -389,9 +380,9 @@
 
       /// Constructor
       CandidateListPivotRule(NetworkSimplex &ns) :
-        _arc(ns._arc), _source(ns._source), _target(ns._target),
+        _source(ns._source), _target(ns._target),
         _cost(ns._cost), _state(ns._state), _pi(ns._pi),
-        _in_arc(ns._in_arc), _arc_num(ns._arc_num), _next_arc(0)
+        _in_arc(ns.in_arc), _arc_num(ns._arc_num), _next_arc(0)
       {
         // The main parameters of the pivot rule
         const double LIST_LENGTH_FACTOR = 1.0;
@@ -482,7 +473,6 @@
     private:
 
       // References to the NetworkSimplex class
-      const ArcVector &_arc;
       const IntVector  &_source;
       const IntVector  &_target;
       const CostVector &_cost;
@@ -515,9 +505,9 @@
 
       /// Constructor
       AlteringListPivotRule(NetworkSimplex &ns) :
-        _arc(ns._arc), _source(ns._source), _target(ns._target),
+        _source(ns._source), _target(ns._target),
         _cost(ns._cost), _state(ns._state), _pi(ns._pi),
-        _in_arc(ns._in_arc), _arc_num(ns._arc_num),
+        _in_arc(ns.in_arc), _arc_num(ns._arc_num),
         _next_arc(0), _cand_cost(ns._arc_num), _sort_func(_cand_cost)
       {
         // The main parameters of the pivot rule
@@ -549,7 +539,7 @@
 
         // Extend the list
         int cnt = _block_size;
-        int last_edge = 0;
+        int last_arc = 0;
         int limit = _head_length;
 
         for (int e = _next_arc; e < _arc_num; ++e) {
@@ -557,7 +547,7 @@
             (_cost[e] + _pi[_source[e]] - _pi[_target[e]]);
           if (_cand_cost[e] < 0) {
             _candidates[_curr_length++] = e;
-            last_edge = e;
+            last_arc = e;
           }
           if (--cnt == 0) {
             if (_curr_length > limit) break;
@@ -571,7 +561,7 @@
               (_cost[e] + _pi[_source[e]] - _pi[_target[e]]);
             if (_cand_cost[e] < 0) {
               _candidates[_curr_length++] = e;
-              last_edge = e;
+              last_arc = e;
             }
             if (--cnt == 0) {
               if (_curr_length > limit) break;
@@ -581,7 +571,7 @@
           }
         }
         if (_curr_length == 0) return false;
-        _next_arc = last_edge + 1;
+        _next_arc = last_arc + 1;
 
         // Make heap of the candidate list (approximating a partial sort)
         make_heap( _candidates.begin(), _candidates.begin() + _curr_length,
@@ -603,47 +593,47 @@
     ///
     /// General constructor (with lower bounds).
     ///
-    /// \param digraph The digraph the algorithm runs on.
+    /// \param graph The digraph the algorithm runs on.
     /// \param lower The lower bounds of the arcs.
     /// \param capacity The capacities (upper bounds) of the arcs.
     /// \param cost The cost (length) values of the arcs.
     /// \param supply The supply values of the nodes (signed).
-    NetworkSimplex( const Digraph &digraph,
+    NetworkSimplex( const Digraph &graph,
                     const LowerMap &lower,
                     const CapacityMap &capacity,
                     const CostMap &cost,
                     const SupplyMap &supply ) :
-      _orig_graph(digraph), _orig_lower(&lower), _orig_cap(capacity),
+      _graph(graph), _orig_lower(&lower), _orig_cap(capacity),
       _orig_cost(cost), _orig_supply(&supply),
-      _flow_result(NULL), _potential_result(NULL),
+      _flow_map(NULL), _potential_map(NULL),
       _local_flow(false), _local_potential(false),
-      _node_id(digraph)
+      _node_id(graph)
     {}
 
     /// \brief General constructor (without lower bounds).
     ///
     /// General constructor (without lower bounds).
     ///
-    /// \param digraph The digraph the algorithm runs on.
+    /// \param graph The digraph the algorithm runs on.
     /// \param capacity The capacities (upper bounds) of the arcs.
     /// \param cost The cost (length) values of the arcs.
     /// \param supply The supply values of the nodes (signed).
-    NetworkSimplex( const Digraph &digraph,
+    NetworkSimplex( const Digraph &graph,
                     const CapacityMap &capacity,
                     const CostMap &cost,
                     const SupplyMap &supply ) :
-      _orig_graph(digraph), _orig_lower(NULL), _orig_cap(capacity),
+      _graph(graph), _orig_lower(NULL), _orig_cap(capacity),
       _orig_cost(cost), _orig_supply(&supply),
-      _flow_result(NULL), _potential_result(NULL),
+      _flow_map(NULL), _potential_map(NULL),
       _local_flow(false), _local_potential(false),
-      _node_id(digraph)
+      _node_id(graph)
     {}
 
     /// \brief Simple constructor (with lower bounds).
     ///
     /// Simple constructor (with lower bounds).
     ///
-    /// \param digraph The digraph the algorithm runs on.
+    /// \param graph The digraph the algorithm runs on.
     /// \param lower The lower bounds of the arcs.
     /// \param capacity The capacities (upper bounds) of the arcs.
     /// \param cost The cost (length) values of the arcs.
@@ -651,48 +641,48 @@
     /// \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).
-    NetworkSimplex( const Digraph &digraph,
+    NetworkSimplex( const Digraph &graph,
                     const LowerMap &lower,
                     const CapacityMap &capacity,
                     const CostMap &cost,
                     Node s, Node t,
                     Capacity flow_value ) :
-      _orig_graph(digraph), _orig_lower(&lower), _orig_cap(capacity),
+      _graph(graph), _orig_lower(&lower), _orig_cap(capacity),
       _orig_cost(cost), _orig_supply(NULL),
       _orig_source(s), _orig_target(t), _orig_flow_value(flow_value),
-      _flow_result(NULL), _potential_result(NULL),
+      _flow_map(NULL), _potential_map(NULL),
       _local_flow(false), _local_potential(false),
-      _node_id(digraph)
+      _node_id(graph)
     {}
 
     /// \brief Simple constructor (without lower bounds).
     ///
     /// Simple constructor (without lower bounds).
     ///
-    /// \param digraph The digraph the algorithm runs on.



More information about the Lemon-commits mailing list