Boost logo

Boost Users :

Subject: [Boost-users] Printing local edge list in PBGL
From: Alexander Frolov (alexndr.frolov_at_[hidden])
Date: 2015-06-23 11:35:38


Hi,

I have a simple program using PBGL (boost 1.58) which creates an undirected
graph and prints local edge list for the specified process. However, only
for zero process the list (edges(g)) contains edge descriptors, while for
non-zero processes the list is empty, which is strange, is it not?

The program text is following:

using namespace boost;
using boost::graph::distributed::mpi_process_group;
using boost::graph::parallel::process_group;

std::size_t nVertices = 16;

int main(int argc, char **argv) {
  boost::mpi::environment env(argc, argv);
  mpi_process_group pg;

  typedef adjacency_list<listS,
                         distributedS<mpi_process_group, vecS>,
                         undirectedS,
                         // Vertex properties
                         no_property,
                         // Edge properties
                         property<edge_weight_t, int> > Graph;
  Graph g(nVertices);

  if (process_id(pg) == 0) {
    std::cout << "MST Boost running..." << std::endl;
    std::cout << "\tnumber of mpi processes is " << num_processes(pg) <<
std::endl;
    std::cout << "\tnumber of vertices is " << nVertices << std::endl;
    std::cout << "\tnumber of edges is " << /*nEdges*/ nVertices <<
std::endl;
    std::cout << "Constructing graph...";

    for (int i = 0; i < nVertices; i++) {
      uint64_t s = (i < nVertices/2) ? 0 : nVertices/2;
      //uint64_t s = 0;
      uint64_t d = i;
      uint64_t w = rand();
      add_edge(vertex(s, g), vertex(d, g), w, g);
    }
    std::cout << "...completed" << std::endl;
  }

  synchronize(pg);

typedef property_map<Graph, edge_weight_t>::type WeightMap;
  WeightMap weight_map = get(edge_weight, g);

  if (process_id(pg) == atoi(argv[1])){
    std::cout << "printing vertices:\n";
    Graph::vertex_iterator v, v_end;
    for (boost::tie(v,v_end) = vertices(g); v != v_end; v++) {
      std::cout << process_id(pg) << ": ("
        << local(*v) << "@" << owner(*v) << ")\n";
    }
    std::cout << "end of vertex list.\n";
    std::cout << "printing edges:\n";
    for (typename Graph::edge_iterator ei = edges(g).first; ei !=
edges(g).second; ei++) {
      std::cout << process_id(pg) << ": ("
        << local(source(*ei, g)) << "@" << owner(source(*ei,g)) << ","
        << local(target(*ei, g)) << "@" << owner(target(*ei,g)) << ","
        << get(weight_map, *ei) << ")\n";
    }
    std::cout << "end of edge list.\n";
  }

  return 0;
}

The output for the process 0:

mpirun -np 2 ./simple_test 0

MST Boost running...
        number of mpi processes is 2
        number of vertices is 16
        number of edges is 16
Constructing graph......completed
printing vertices:
0: (0_at_0)
0: (1_at_0)
0: (2_at_0)
0: (3_at_0)
0: (4_at_0)
0: (5_at_0)
0: (6_at_0)
0: (7_at_0)
end of vertex list.
printing edges:
0: (0_at_0,0_at_0,1804289383)
0: (0_at_0,1_at_0,846930886)
0: (0_at_0,2_at_0,1681692777)
0: (0_at_0,3_at_0,1714636915)
0: (0_at_0,4_at_0,1957747793)
0: (0_at_0,5_at_0,424238335)
0: (0_at_0,6_at_0,719885386)
0: (0_at_0,7_at_0,1649760492)
0: (0_at_0,0_at_1,596516649)
0: (0_at_0,1_at_1,1189641421)
0: (0_at_0,2_at_1,1025202362)
0: (0_at_0,3_at_1,1350490027)
0: (0_at_0,4_at_1,783368690)
0: (0_at_0,5_at_1,1102520059)
0: (0_at_0,6_at_1,2044897763)
0: (0_at_0,7_at_1,1967513926)
end of edge list.

The output for the process 1:

mpirun -np 2 ./simple_test 1

MST Boost running...
        number of mpi processes is 2
        number of vertices is 16
        number of edges is 16
Constructing graph......completed
printing vertices:
1: (0_at_1)
1: (1_at_1)
1: (2_at_1)
1: (3_at_1)
1: (4_at_1)
1: (5_at_1)
1: (6_at_1)
1: (7_at_1)
end of vertex list.
printing edges:
end of edge list.

Is it ok? or there is a bug in the code? Appreciate any help. Thanks a lot.

Best, Alex



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net