Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <boost/graph/use_mpi.hpp>
- #include <boost/graph/distributed/adjacency_list.hpp>
- #include <boost/graph/distributed/mpi_process_group.hpp>
- // METIS Input
- #include <boost/graph/metis.hpp>
- #include <boost/graph/distributed/graphviz.hpp>
- //#include <cstring>
- using namespace boost;
- using boost::graph::distributed::mpi_process_group;
- int main(int argc, char* argv[])
- {
- mpi::environment env(argc, argv);
- typedef adjacency_list<vecS,
- distributedS<mpi_process_group, vecS>,
- undirectedS,
- property<vertex_centrality_t,float>,
- property<edge_weight_t, int> > Graph;
- const char* filename = "weighted_graph.gr";
- std::ifstream in(filename);
- graph::metis_reader reader(in);
- Graph g(reader.begin(), reader.end(), reader.weight_begin(),
- reader.num_vertices());
- //clear edges and remove first vertex
- boost::graph_traits<Graph>::vertex_descriptor v = vertex(0,g);
- if(owner(v) == process_id(process_group(g)))
- {
- clear_vertex(v,g);
- }
- synchronize(g);
- if(owner(v) == process_id(process_group(g)))
- {
- remove_vertex(v,g);
- }
- synchronize(g);
- // Output a Graphviz DOT file
- std::string outfile = filename;
- size_t i = outfile.rfind('.');
- if (i != std::string::npos)
- outfile.erase(outfile.begin() + i, outfile.end());
- outfile += "-dijkstra-2.dot";
- if (process_id(process_group(g)) == 0) {
- int pcount = num_processes(process_group(g));
- std::cout << "Writing GraphViz output to " << outfile << "..." << pcount << "... ";
- std::cout.flush();
- }
- write_graphviz(outfile, g,
- make_label_writer(get(vertex_index, g)),
- make_label_writer(get(edge_weight, g)));
- if (process_id(process_group(g)) == 0)
- std::cout << "Done." << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement