Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:42:57

0001 //=======================================================================
0002 // Copyright 2013 University of Warsaw.
0003 // Authors: Piotr Wygocki
0004 //
0005 // Distributed under the Boost Software License, Version 1.0. (See
0006 // accompanying file LICENSE_1_0.txt or copy at
0007 // http://www.boost.org/LICENSE_1_0.txt)
0008 //=======================================================================
0009 #ifndef BOOST_GRAPH_FIND_FLOW_COST_HPP
0010 #define BOOST_GRAPH_FIND_FLOW_COST_HPP
0011 
0012 #include <boost/graph/iteration_macros.hpp>
0013 
0014 namespace boost
0015 {
0016 
0017 template < class Graph, class Capacity, class ResidualCapacity, class Weight >
0018 typename property_traits< Weight >::value_type find_flow_cost(const Graph& g,
0019     Capacity capacity, ResidualCapacity residual_capacity, Weight weight)
0020 {
0021     typedef typename property_traits< Weight >::value_type Cost;
0022 
0023     Cost cost = 0;
0024     BGL_FORALL_EDGES_T(e, g, Graph)
0025     {
0026         if (get(capacity, e) > Cost(0))
0027         {
0028             cost += (get(capacity, e) - get(residual_capacity, e))
0029                 * get(weight, e);
0030         }
0031     }
0032     return cost;
0033 }
0034 
0035 template < class Graph, class P, class T, class R >
0036 typename detail::edge_weight_value< Graph, P, T, R >::type find_flow_cost(
0037     const Graph& g, const bgl_named_params< P, T, R >& params)
0038 {
0039     return find_flow_cost(g,
0040         choose_const_pmap(get_param(params, edge_capacity), g, edge_capacity),
0041         choose_const_pmap(get_param(params, edge_residual_capacity), g,
0042             edge_residual_capacity),
0043         choose_const_pmap(get_param(params, edge_weight), g, edge_weight));
0044 }
0045 
0046 template < class Graph >
0047 typename property_traits<
0048     typename property_map< Graph, edge_capacity_t >::type >::value_type
0049 find_flow_cost(const Graph& g)
0050 {
0051     bgl_named_params< int, buffer_param_t > params(0);
0052     return find_flow_cost(g, params);
0053 }
0054 
0055 } // boost
0056 
0057 #endif /* BOOST_GRAPH_FIND_FLOW_COST_HPP */