Commit 0d8112a0 authored by Tiago Peixoto's avatar Tiago Peixoto

Fix a race condition in label_parallel_edges()

This fixes a race condition when undirected graphs are used, and when
OpenMP is enabled.
parent 736d6910
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#define GRAPH_PARALLEL_HH #define GRAPH_PARALLEL_HH
#include <tr1/unordered_set> #include <tr1/unordered_set>
#include "graph_util.hh"
namespace graph_tool namespace graph_tool
{ {
...@@ -49,6 +50,12 @@ struct label_parallel_edges ...@@ -49,6 +50,12 @@ struct label_parallel_edges
{ {
if (p_edges.find(*e1) != p_edges.end()) if (p_edges.find(*e1) != p_edges.end())
continue; continue;
// do not visit edges twice in undirected graphs
if (!is_directed::apply<Graph>::type::value &&
target(*e1, g) < v)
continue;
size_t n = 0; size_t n = 0;
put(parallel, *e1, n); put(parallel, *e1, n);
for (tie(e2, e_end2) = out_edges(v, g); e2 != e_end2; ++e2) for (tie(e2, e_end2) = out_edges(v, g); e2 != e_end2; ++e2)
......
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