1//=======================================================================
2// Copyright 2013 University of Warsaw.
3// Authors: Piotr Wygocki
4//
5// Distributed under the Boost Software License, Version 1.0. (See
6// accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//=======================================================================
9#ifndef BOOST_GRAPH_FIND_FLOW_COST_HPP
10#define BOOST_GRAPH_FIND_FLOW_COST_HPP
11
12#include <boost/graph/iteration_macros.hpp>
13
14namespace boost {
15
16template<class Graph, class Capacity, class ResidualCapacity, class Weight>
17typename property_traits<typename property_map < Graph, edge_capacity_t >::type>::value_type
18find_flow_cost(const Graph & g, Capacity capacity, ResidualCapacity residual_capacity, Weight weight) {
19 typedef typename property_traits<typename property_map<Graph, edge_weight_t>::const_type>::value_type Cost;
20
21 Cost cost = 0;
22 BGL_FORALL_EDGES_T(e, g, Graph) {
23 if(get(capacity, e) > Cost(0)) {
24 cost += (get(capacity, e) - get(residual_capacity, e)) * get(weight, e);
25 }
26 }
27 return cost;
28}
29
30template <class Graph, class P, class T, class R>
31typename property_traits<typename property_map < Graph, edge_capacity_t >::type>::value_type
32find_flow_cost(const Graph & g,
33 const bgl_named_params<P, T, R>& params) {
34 return find_flow_cost(g,
35 choose_const_pmap(get_param(params, edge_capacity), g, edge_capacity),
36 choose_const_pmap(get_param(params, edge_residual_capacity),
37 g, edge_residual_capacity),
38 choose_const_pmap(get_param(params, edge_weight), g, edge_weight));
39}
40
41template <class Graph>
42typename property_traits<typename property_map < Graph, edge_capacity_t >::type>::value_type
43find_flow_cost(const Graph &g) {
44 bgl_named_params<int, buffer_param_t> params(0);
45 return find_flow_cost(g, params);
46}
47
48
49} //boost
50
51#endif /* BOOST_GRAPH_FIND_FLOW_COST_HPP */
52
53

source code of boost/boost/graph/find_flow_cost.hpp