Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,9 @@ run(Vertex s)
relax(u, target(e, g), u_dist + get(weight, e));
}

// Go to the next bucket: the current bucket must already be empty.
++current_bucket;
// Floating-point rounding can put a heavy-edge target back in this
// bucket. Let the next global nonempty-bucket search advance the cursor
// only after that work has also been processed.
} while (true);

// Delete all of the buckets.
Expand Down
1 change: 1 addition & 0 deletions test/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ test-suite graph_parallel
[ mpi-test mesh_generator_test : : <testing.arg>"1000 1000 1 0" : 2 ]
[ mpi-test named_vertices_seq : : : 1 ]
[ mpi-test distributed_shortest_paths_test : : : 2 ]
[ mpi-test delta_stepping_rounding_test : : : 2 ]
[ mpi-test distributed_csr_algorithm_test : : : 1 ]
[ mpi-test distributed_betweenness_centrality_test : : : 2 ]
[ mpi-test distributed_dimacs_reader : : : 2 ]
Expand Down
54 changes: 54 additions & 0 deletions test/delta_stepping_rounding_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

// Distributed under the Boost Software License, Version 1.0.
#include <boost/graph/use_mpi.hpp>
#include <boost/graph/distributed/delta_stepping_shortest_paths.hpp>
#include <boost/graph/distributed/mpi_process_group.hpp>
#include <boost/graph/distributed/adjacency_list.hpp>
#include <boost/graph/iteration_macros.hpp>
#include <boost/mpi.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cstdlib>
#include <utility>
#include <vector>

template<class W> struct WeightedEdge {
W weight;
WeightedEdge(W value=0) : weight(value) {}
template<class Archive> void serialize(Archive& ar, unsigned) {ar & weight;}
};
template<class W> struct VertexProperties {
W distance;
VertexProperties(W value=0) : distance(value) {}
template<class Archive> void serialize(Archive& ar, unsigned) {ar & distance;}
};
template<class W> void run_case(const char* const weights[4],const char* delta_text) {
using namespace boost;
typedef adjacency_list<listS,distributedS<graph::distributed::mpi_process_group,vecS>,
directedS,VertexProperties<W>,WeightedEdge<W> > Graph;
std::vector<std::pair<unsigned long,unsigned long> > edges;
std::vector<WeightedEdge<W> > values;
W expected[5]={0,0,0,0,0};
for(unsigned i=0;i<4;++i) {
edges.push_back(std::make_pair(i,i+1));
W value=static_cast<W>(std::strtod(weights[i],0));
values.push_back(WeightedEdge<W>(value));
expected[i+1]=expected[i]+value;
}
Graph graph(edges.begin(),edges.end(),values.begin(),5);
graph::distributed::delta_stepping_shortest_paths(graph,vertex(0,graph),
dummy_property_map(),get(&VertexProperties<W>::distance,graph),
get(&WeightedEdge<W>::weight,graph),static_cast<W>(std::strtod(delta_text,0)));
typename property_map<Graph,vertex_global_t>::const_type global=get(vertex_global,graph);
BGL_FORALL_VERTICES_T(v,graph,Graph) {
unsigned index=graph.distribution().global(get(global,v).first,get(global,v).second);
BOOST_TEST_EQ(get(&VertexProperties<W>::distance,graph,v),expected[index]);
}
}
int main(int argc,char** argv) {
boost::mpi::environment environment(argc,argv);
{ const char* weights[4]={"0x1.1a7d68e8aa4eep+13","0x1.350c7b8632a9bp+4","0x1.9c10a4b2ee374p+2","0x1.9c10a4b2ee374p+2"};
run_case<double>(weights,"0x1.350c7b8632a97p+4"); }
{ const char* weights[4]={"0x1.0771920000000p+13","0x1.f407c20000000p+2","0x1.4d5a7c0000000p+1","0x1.4d5a7c0000000p+1"};
run_case<float>(weights,"0x1.f407ba0000000p+2"); }
return boost::report_errors();
}