I want to use the dense_boruvka_minimum_spanning_tree
function in Boost Graph Library, C++. What I want to do is to generate a random graph and then input it into that function to run the Boruvka's algorithm in parallel. Could anybody help me with couple of lines of code as for how the function is used?
Asked
Active
Viewed 154 times
-1

Logan Yang
- 2,364
- 6
- 27
- 43
-
This question shows no sign of research. Read docs, google, try some code. If still stuck, post code and ask for specific help. – ravenspoint Aug 02 '13 at 14:22
1 Answers
2
Does this help?
typedef adjacency_list<listS,
distributedS<mpi_process_group, vecS>,
undirectedS,
no_property,
property<edge_weight_t, int> > Graph;
typedef graph_traits<Graph>::vertex_descriptor vertex_descriptor;
typedef graph_traits<Graph>::vertex_iterator vertex_iterator;
typedef graph_traits<Graph>::edge_descriptor edge_descriptor;
typedef std::pair<int, int> E;
const int num_nodes = 5;
E edge_array[] = { E(0, 2), E(1, 3), E(1, 4), E(2, 1), E(2, 3),
E(3, 4), E(4, 0), E(4, 1)
};
int weights[] = { 1, 1, 2, 7, 3, 1, 1, 1 };
std::size_t num_edges = sizeof(edge_array) / sizeof(E);
Graph g(edge_array, edge_array + num_edges, weights, num_nodes);
typedef property_map<Graph, edge_weight_t>::type WeightMap;
WeightMap weight_map = get(edge_weight, g);
std::vector<edge_descriptor> mst_edges;
dense_boruvka_minimum_spanning_tree(make_vertex_list_adaptor(g),
weight_map,
std::back_inserter(mst_edges));

doctorlove
- 18,872
- 2
- 46
- 62