Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Tiago Peixoto
graph-tool
Commits
52508b9f
Commit
52508b9f
authored
Apr 11, 2011
by
Tiago Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix parallel bug in get_global_clustering()
parent
8af4ae36
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
src/graph/clustering/graph_clustering.hh
src/graph/clustering/graph_clustering.hh
+8
-6
No files found.
src/graph/clustering/graph_clustering.hh
View file @
52508b9f
...
...
@@ -25,6 +25,9 @@
#endif
#include <boost/mpl/if.hpp>
#include <ext/numeric>
using
__gnu_cxx
::
power
;
namespace
graph_tool
{
using
namespace
boost
;
...
...
@@ -98,7 +101,7 @@ struct get_global_clustering
int
i
,
N
=
num_vertices
(
g
);
#pragma omp parallel for default(shared) private(i,temp) \
schedule(dynamic) reduction(+:triangles)
schedule(dynamic) reduction(+:triangles
, n
)
for
(
i
=
0
;
i
<
N
;
++
i
)
{
typename
graph_traits
<
Graph
>::
vertex_descriptor
v
=
vertex
(
i
,
g
);
...
...
@@ -109,13 +112,13 @@ struct get_global_clustering
triangles
+=
temp
.
first
;
n
+=
temp
.
second
;
}
c
=
double
(
triangles
)
/
n
;
c
=
double
(
triangles
)
/
n
;
// "jackknife" variance
c_err
=
0.0
;
#pragma omp parallel for default(shared) private(i,temp) \
schedule(dynamic)
schedule(dynamic)
reduction(+:c_err)
for
(
i
=
0
;
i
<
N
;
++
i
)
{
typename
graph_traits
<
Graph
>::
vertex_descriptor
v
=
vertex
(
i
,
g
);
...
...
@@ -123,10 +126,9 @@ struct get_global_clustering
continue
;
temp
=
get_triangles
(
v
,
g
);
double
cl
=
double
(
triangles
-
temp
.
first
)
/
(
n
-
temp
.
second
);
double
cl
=
double
(
triangles
-
temp
.
first
)
/
(
n
-
temp
.
second
);
#pragma omp atomic
c_err
+=
(
c
-
cl
)
*
(
c
-
cl
);
c_err
+=
power
(
c
-
cl
,
2
);
}
c_err
=
sqrt
(
c_err
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment