MPI_Dist_graph_neighbors(graph_communicator, indrgee, sources,
sources_weight, outdegree, destinations, destinations_weight);
while ( not global_done ) {
// 對圖中的每一個點,接收鄰居的 destination_to_source
MPI_Neighbor_allgather(&distance_to_source, 1,
MPI_INT, neighbors_dest_to_source, 1, MPI_INT, graph_communicator);
bool local_done = true;
for ( ssize_t i = 0; i < indrgee; ++i) {
if (neighbors_dest_to_source[i] == std::numeric_limits<int32_t>::max())
continue;
const int32_t your_weight = neighbors_dest_to_source[i] + sources_weight[i];
if ( your_weight < distance_to_source) {
distance_to_source = your_weight;
parent = sources[i];
local_done = false;
}
}
// reduce local_done with logical and
MPI_Allreduce(&local_done, &global_done, 1, MPI::BOOL, MPI_LAND,
graph_communicator);
}