19 #include <boost/graph/adjacency_list.hpp>
25 std::vector<std::pair<int,int>> edges_p {{1,2},{1,5},{2,3},{2,5},{2,6},
26 {3,4},{3,7},{4,7},{4,0},{5,6},{6,7},{7,0}};
27 std::vector<int> costs{2,3,3,2,2,4,2,2,2,3,1,3};
28 boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS,
30 boost::property<boost::edge_index_t, std::size_t>
32 for (std::size_t i = 0; i < edges_p.size(); ++i) {
33 add_edge(edges_p[i].first, edges_p[i].second, i, graph);
37 auto edge_id =
get(boost::edge_index, graph);
38 auto weight = make_iterator_property_map(costs.begin(), edge_id);
42 std::vector<std::pair<int,int>> vertices_parts;
44 boost::weight_map(weight));
51 std::cout <<
"cost cut:" << cost_cut << std::endl;
52 std::vector<int> vertices_to_parts;
53 for (
auto i: vertices_parts) {
54 std::cout << i.first <<
"(" << i.second <<
"), ";
56 std::cout << std::endl;
int main()
[K Cut Example]
auto k_cut(const InGraph &graph, unsigned int number_of_parts, OutputIterator result, VertexIndexMap index_map, EdgeWeightMap weight_map) -> typename boost::property_traits< EdgeWeightMap >::value_type
this is solve k_cut problem and return cut_cost example: