Pregunta: | 67320 - MAPAS DE PROPIEDAD EN GRAFOS DISTRIBUIDOS DE LA BOOST |
Autor: | Yenisleidi Lora Dominguez |
Usando la librería de la boost, cree un grafo distribuido, el problema es cuando tengo una arista entre dos procesadores, y uno de ellos le cambia alguna propiedad a la arista, en el otro procesador no se actualiza el nuevo valor. Este es código #include "mpi.h" #include <boost/config.hpp> #include <boost/graph/use_mpi.hpp> #include <boost/graph/distributed/mpi_process_group.hpp> #include <boost/graph/distributed/adjacency_list.hpp> #include <boost/property_map/parallel/distributed_property_map.hpp> #include <boost/serialization/list.hpp> #include <list> using namespace std; //===============================Vertex================================ struct Vertex{ int id; // Serialization support is required! template<typename Archiver> void serialize(Archiver& ar, const unsigned int ) { ar & id ; } Vertex(int id = 0): id(id){} }; //===============================Edge================================ struct Edge{ int type; Edge( int type = 0): type(type){ } // Serialization support is required! template<typename Archiver> void serialize(Archiver& ar,const unsigned int ) { ar & type; } }; using namespace boost; using boost::graph::distributed::mpi_process_group; typedef adjacency_list < listS, distributedS<mpi_process_group, listS>, undirectedS, Vertex, Edge > Graph; typedef typename Graph::edge_descriptor edge_descriptor; typedef typename Graph::vertex_descriptor vertex_descriptor; int main (int argc, char ** argv){ boost::mpi::environment env(argc,argv); mpi::communicator world; Graph g; vertex_descriptor vi,vj; property_map<Graph, int Edge::*>::type type1 = get(&Edge::type, g); if (g.processor()==0) vi = add_vertex(Vertex(1),g); if (g.processor()==1) vj = add_vertex(Vertex(2),g); broadcast(world, vj, 1); broadcast(world, vi, 0); if (g.processor()==0){ pair<edge_descriptor,bool> p = add_edge(vi, vj, Edge(1), g); std::cout<<"Process "<<g.processor()<<std::endl; std::cout<<"Process owner of edge "<<owner(p.first)<<std::endl; std::cout<<"Property type of edge :"<<get(type1,p.first)<<std::endl; } synchronize(g); if (g.processor()==1){ pair<edge_descriptor,bool> p = edge(vi, vj, g); if(p.second){ std::cout<<" Process "<<g.processor()<<std::endl; std::cout<<"Process owner of edge "<<owner(p.first)<<std::endl; put(type1,p.first,3); std::cout<<"Change property type of edge :"<<get(type1,p.first)<<std::endl; } } synchronize(g); if (g.processor()==0){ pair<edge_descriptor,bool> p = edge(vi, vj, g); std::cout<<" Process "<<g.processor()<<std::endl; std::cout<<"Property type of edge :"<<get(type1,p.first)<<std::endl; } return 0; } La salida es la siguiente Process 0 Process owner of edge 0 Property type of edge :1 Process 1 Process owner of edge 1 Change property type of edge :3 Process 0 Property type of edge :1 El procesador 1 puso una arista que tiene tipo 1 y el procesador 1 la cambio por tipo 3 pero cuando el procesador 1 accede a la arista se mantiene con el tipo 1, otra cosa es que me dice que ambos procesadores son dueños de la arista.... |