Hello boost.graph users,
I would like to use the PBGL with named vertices and later redistribute the graph.
Unfortunately, I cannot compile the attached code, which - following the documentation - should work, since redistribute() just needs a property_map containing the new rank id's. A minimal example is shown below and a more verbose in the attachment.
The example on redistribution in the tests of course works, but uses no named vertices.
Are there any users of the parallel BGL who managed to solve this issue? And how?
Moreover, could the new (serial) labeled_graph be an option?
Thank you very much,
Andreas
#include
#include
#include
using namespace boost;
using boost::graph::distributed::mpi_process_group;
//-----------------------------------------------------------------------------
struct Topo
{
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar & user_id & rank_id ;
}
Topo( int uid=0, int rid=-1 ) : user_id(uid), rank_id(rid) {}
int user_id;
int rank_id;
friend std::ostream& operator<< (std::ostream& o, const Topo& t)
{ o << "uid = " << t.user_id << ", rid = " << t.rank_id; return o; }
};
//-----------------------------------------------------------------------------
// named vertices in a graph
namespace boost { namespace graph {
template<>
struct internal_vertex_name< Topo >
{
typedef multi_index::member< Topo, int, &Topo::user_id > type;
};
template<>
struct internal_vertex_constructor< Topo >
{
typedef vertex_from_name< Topo > type;
};
}}
typedef adjacency_list< vecS, distributedS< mpi_process_group, vecS >,
directedS,
Topo > Graph;
int main(int argc, char* argv[])
{
boost::mpi::environment env(argc,argv);
Graph g;
property_map< Graph, int Topo::*>::type rid_map = get(&Topo::rank_id, g);
g.redistribute( rid_map );
return 0;
}