lemon/min_cost_max_flow.h
changeset 2531 426a4e35e167
parent 2507 6520edb2c3f3
child 2533 aea952a1af99
equal deleted inserted replaced
1:c49330d8a5a7 2:1b9beea9a112
    90     /// \brief The target node.
    90     /// \brief The target node.
    91     Node target;
    91     Node target;
    92     /// \brief The edge map of the found flow.
    92     /// \brief The edge map of the found flow.
    93     FlowMap flow;
    93     FlowMap flow;
    94 
    94 
    95     typedef Preflow<Graph, Capacity, CapacityMap, FlowMap> PreflowImpl;
    95     typedef Preflow<Graph, CapacityMap> PreflowImpl;
    96     /// \brief \ref lemon::Preflow "Preflow" class for finding the
    96     /// \brief \ref lemon::Preflow "Preflow" class for finding the
    97     /// maximum flow value.
    97     /// maximum flow value.
    98     PreflowImpl preflow;
    98     PreflowImpl preflow;
    99 
    99 
   100   public:
   100   public:
   112 		    const CapacityMap &_capacity,
   112 		    const CapacityMap &_capacity,
   113 		    const CostMap &_cost,
   113 		    const CostMap &_cost,
   114 		    Node _s, Node _t ) :
   114 		    Node _s, Node _t ) :
   115       graph(_graph), capacity(_capacity), cost(_cost),
   115       graph(_graph), capacity(_capacity), cost(_cost),
   116       source(_s), target(_t), flow(_graph),
   116       source(_s), target(_t), flow(_graph),
   117       preflow(_graph, _s, _t, _capacity, flow)
   117       preflow(_graph, _capacity, _s, _t)
   118     {}
   118     {}
   119 
   119 
   120     /// \brief Returns a const reference to the flow map.
   120     /// \brief Returns a const reference to the flow map.
   121     ///
   121     ///
   122     /// Returns a const reference to the flow map.
   122     /// Returns a const reference to the flow map.
   139       return c;
   139       return c;
   140     }
   140     }
   141 
   141 
   142     /// \brief Runs the algorithm.
   142     /// \brief Runs the algorithm.
   143     void run() {
   143     void run() {
   144       preflow.phase1();
   144       preflow.flowMap(flow);
       
   145       preflow.runMinCut();
   145       MinCostFlowImpl mcf_impl( graph, capacity, cost,
   146       MinCostFlowImpl mcf_impl( graph, capacity, cost,
   146 				source, target, preflow.flowValue() );
   147 				source, target, preflow.flowValue() );
   147       mcf_impl.run();
   148       mcf_impl.run();
   148       flow = mcf_impl.flowMap();
   149       flow = mcf_impl.flowMap();
   149     }
   150     }