Commit 0dcf00ff authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Fix race condition in betweenness() with openmp enabled

parent 90b1e76d
...@@ -342,29 +342,32 @@ namespace detail { namespace graph { ...@@ -342,29 +342,32 @@ namespace detail { namespace graph {
shortest_paths(g, s, ordered_vertices, incoming, distance, shortest_paths(g, s, ordered_vertices, incoming, distance,
path_count, vertex_index); path_count, vertex_index);
while (!ordered_vertices.empty()) #pragma omp critical
{ {
vertex_descriptor u = ordered_vertices.top(); while (!ordered_vertices.empty())
ordered_vertices.pop(); {
vertex_descriptor u = ordered_vertices.top();
typedef typename property_traits<IncomingMap>::value_type ordered_vertices.pop();
incoming_type;
typedef typename incoming_type::iterator incoming_iterator; typedef typename property_traits<IncomingMap>::value_type
typedef typename property_traits<DependencyMap>::value_type incoming_type;
dependency_type; typedef typename incoming_type::iterator incoming_iterator;
typedef typename property_traits<DependencyMap>::value_type
for (incoming_iterator vw = incoming[u].begin(); dependency_type;
vw != incoming[u].end(); ++vw) {
vertex_descriptor v = source(*vw, g); for (incoming_iterator vw = incoming[u].begin();
dependency_type factor = dependency_type(get(path_count, v)) vw != incoming[u].end(); ++vw) {
/ dependency_type(get(path_count, u)); vertex_descriptor v = source(*vw, g);
factor *= (dependency_type(1) + get(dependency, u)); dependency_type factor = dependency_type(get(path_count, v))
put(dependency, v, get(dependency, v) + factor); / dependency_type(get(path_count, u));
update_centrality(edge_centrality_map, *vw, factor); factor *= (dependency_type(1) + get(dependency, u));
} put(dependency, v, get(dependency, v) + factor);
update_centrality(edge_centrality_map, *vw, factor);
if (u != s) { }
update_centrality(centrality, u, get(dependency, u));
if (u != s) {
update_centrality(centrality, u, get(dependency, u));
}
} }
} }
......
Markdown is supported
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