Commit 5d851ae0 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

distance_histogram(): fix bug with openmp

This fixes issue #721
parent 31050f10
......@@ -183,17 +183,19 @@ public:
void gather()
{
if (_sum != 0)
#pragma omp critical
{
#pragma omp critical
if (_sum != nullptr)
{
typename Histogram::bin_t idx;
typename Histogram::bin_t shape;
for (size_t i = 0; i < this->_counts.num_dimensions(); ++i)
for (size_t i = 0; i < this->_counts.num_dimensions(); ++i)
shape[i] = std::max(this->_counts.shape()[i],
_sum->get_array().shape()[i]);
_sum->get_array().resize(shape);
for (size_t i = 0; i < this->_counts.num_elements(); ++i)
{
size_t offset = 1;
......@@ -210,8 +212,9 @@ public:
if (_sum->get_bins()[i].size() < this->_bins[i].size())
_sum->get_bins()[i] = this->_bins[i];
}
_sum = nullptr;
}
_sum = 0;
}
}
private:
......
......@@ -115,8 +115,8 @@ struct get_distance_histogram
{
template <class Graph, class Vertex, class VertexIndex,
class DistanceMap, class WeightMap>
void operator()(const Graph& g, Vertex s, VertexIndex vertex_index,
DistanceMap dist_map, WeightMap weights) const
void operator()(const Graph& g, Vertex s, VertexIndex& vertex_index,
DistanceMap& dist_map, WeightMap& weights) const
{
dijkstra_shortest_paths(g, s, vertex_index_map(vertex_index).
weight_map(weights).distance_map(dist_map));
......@@ -128,8 +128,8 @@ struct get_distance_histogram
{
template <class Graph, class Vertex, class VertexIndex,
class DistanceMap>
void operator()(const Graph& g, Vertex s, VertexIndex vertex_index,
DistanceMap dist_map, no_weightS) const
void operator()(const Graph& g, Vertex s, VertexIndex& vertex_index,
DistanceMap& dist_map, no_weightS) const
{
typedef typename graph_traits<Graph>::vertex_descriptor vertex_t;
typedef gt_hash_map<vertex_t,default_color_type,
......
......@@ -132,8 +132,8 @@ struct get_sampled_distance_histogram
{
template <class Graph, class Vertex, class VertexIndex,
class DistanceMap, class WeightMap>
void operator()(const Graph& g, Vertex s, VertexIndex vertex_index,
DistanceMap dist_map, WeightMap weights) const
void operator()(const Graph& g, Vertex s, VertexIndex& vertex_index,
DistanceMap& dist_map, WeightMap& weights) const
{
dijkstra_shortest_paths(g, s, vertex_index_map(vertex_index).
weight_map(weights).distance_map(dist_map));
......@@ -145,8 +145,8 @@ struct get_sampled_distance_histogram
{
template <class Graph, class Vertex, class VertexIndex,
class DistanceMap>
void operator()(const Graph& g, Vertex s, VertexIndex vertex_index,
DistanceMap dist_map, no_weightS) const
void operator()(const Graph& g, Vertex s, VertexIndex& vertex_index,
DistanceMap& dist_map, no_weightS) const
{
typedef typename vprop_map_t<default_color_type>::type::unchecked_t vmap_t;
vmap_t color_map(vertex_index, num_vertices(g));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment