28 #ifndef INCLUDE_MINCUT_PGR_STOERWAGNER_HPP_
29 #define INCLUDE_MINCUT_PGR_STOERWAGNER_HPP_
32 #include <boost/config.hpp>
33 #include <boost/graph/adjacency_list.hpp>
34 #include <boost/graph/graph_traits.hpp>
35 #include <boost/graph/one_bit_color_map.hpp>
36 #include <boost/graph/stoer_wagner_min_cut.hpp>
37 #include <boost/property_map/property_map.hpp>
38 #include <boost/typeof/typeof.hpp>
61 typedef typename G::E_i
E_i;
67 std::vector< pgr_stoerWagner_t >
70 std::vector< pgr_stoerWagner_t > results;
71 auto parities = boost::make_one_bit_color_map(
72 num_vertices(graph.graph),
73 get(boost::vertex_index, graph.graph));
75 double w = stoer_wagner_min_cut(
77 get(&G::G_T_E::cost, graph.graph),
78 boost::parity_map(parities));
82 for (boost::tie(ei, ei_end) = edges(graph.graph); ei != ei_end; ei++) {
83 auto s = source(*ei, graph.graph);
84 auto t = target(*ei, graph.graph);
86 if (get(parities, s) != get(parities, t)) {
89 tmp.
cost = graph[*ei].cost;
93 source(*ei, graph.graph),
94 target(*ei, graph.graph),
98 totalcost += tmp.
cost;
100 results.push_back(tmp);
110 std::vector<pgr_stoerWagner_t>
113 pgassert(num_vertices(graph.graph) > 1);
114 return generatestoerWagner(
119 #endif // INCLUDE_MINCUT_PGR_STOERWAGNER_HPP_