lemon/cycle_canceling.h
changeset 828 5fd7fafc4470
parent 816 277ef0218f0c
child 830 75c97c3786d6
child 839 f3bc4e9b5f3a
equal deleted inserted replaced
2:97332f9a8bd4 3:545c55115fed
   150     typedef std::vector<Cost> CostVector;
   150     typedef std::vector<Cost> CostVector;
   151 
   151 
   152   private:
   152   private:
   153   
   153   
   154     template <typename KT, typename VT>
   154     template <typename KT, typename VT>
   155     class VectorMap {
   155     class StaticVectorMap {
   156     public:
   156     public:
   157       typedef KT Key;
   157       typedef KT Key;
   158       typedef VT Value;
   158       typedef VT Value;
   159       
   159       
   160       VectorMap(std::vector<Value>& v) : _v(v) {}
   160       StaticVectorMap(std::vector<Value>& v) : _v(v) {}
   161       
   161       
   162       const Value& operator[](const Key& key) const {
   162       const Value& operator[](const Key& key) const {
   163         return _v[StaticDigraph::id(key)];
   163         return _v[StaticDigraph::id(key)];
   164       }
   164       }
   165 
   165 
   173 
   173 
   174     private:
   174     private:
   175       std::vector<Value>& _v;
   175       std::vector<Value>& _v;
   176     };
   176     };
   177 
   177 
   178     typedef VectorMap<StaticDigraph::Node, Cost> CostNodeMap;
   178     typedef StaticVectorMap<StaticDigraph::Node, Cost> CostNodeMap;
   179     typedef VectorMap<StaticDigraph::Arc, Cost> CostArcMap;
   179     typedef StaticVectorMap<StaticDigraph::Arc, Cost> CostArcMap;
   180 
   180 
   181   private:
   181   private:
   182 
   182 
   183 
   183 
   184     // Data related to the underlying digraph
   184     // Data related to the underlying digraph
   798     void startSimpleCycleCanceling() {
   798     void startSimpleCycleCanceling() {
   799       // Constants for computing the iteration limits
   799       // Constants for computing the iteration limits
   800       const int BF_FIRST_LIMIT  = 2;
   800       const int BF_FIRST_LIMIT  = 2;
   801       const double BF_LIMIT_FACTOR = 1.5;
   801       const double BF_LIMIT_FACTOR = 1.5;
   802       
   802       
   803       typedef VectorMap<StaticDigraph::Arc, Value> FilterMap;
   803       typedef StaticVectorMap<StaticDigraph::Arc, Value> FilterMap;
   804       typedef FilterArcs<StaticDigraph, FilterMap> ResDigraph;
   804       typedef FilterArcs<StaticDigraph, FilterMap> ResDigraph;
   805       typedef VectorMap<StaticDigraph::Node, StaticDigraph::Arc> PredMap;
   805       typedef StaticVectorMap<StaticDigraph::Node, StaticDigraph::Arc> PredMap;
   806       typedef typename BellmanFord<ResDigraph, CostArcMap>
   806       typedef typename BellmanFord<ResDigraph, CostArcMap>
   807         ::template SetDistMap<CostNodeMap>
   807         ::template SetDistMap<CostNodeMap>
   808         ::template SetPredMap<PredMap>::Create BF;
   808         ::template SetPredMap<PredMap>::Create BF;
   809       
   809       
   810       // Build the residual network
   810       // Build the residual network