Commit 531add6b authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Fix bug in similarity()

parent e8fa7fbd
......@@ -128,7 +128,8 @@ struct get_similarity_fast
s = 0;
int i, N = lmap1.size();
#pragma omp parallel for default(shared) private(i) schedule(runtime) if (N > 100)
#pragma omp parallel for default(shared) private(i) schedule(runtime) \
reduction(+:s) if (N > 100)
for (i = 0; i < N; ++i)
{
auto v1 = lmap1[i];
......
......@@ -141,19 +141,13 @@ def similarity(g1, g2, label1=None, label2=None, norm=True):
label2 = label2.copy(label1.value_type())
except ValueError:
label1 = label1.copy(label2.value_type())
try:
_check_prop_scalar(label1, floating=False)
_check_prop_scalar(label2, floating=False)
if label1.fa is not None and label1.fa.max() >= g1.num_vertices():
raise ValueError()
if label2.fa is not None and label2.fa.max() >= g2.num_vertices():
raise ValueError()
if label1.is_writable() or label2.is_writable():
s = libgraph_tool_topology.\
similarity_fast(g1._Graph__graph, g2._Graph__graph,
similarity(g1._Graph__graph, g2._Graph__graph,
_prop("v", g1, label1), _prop("v", g2, label2))
except ValueError:
else:
s = libgraph_tool_topology.\
similarity(g1._Graph__graph, g2._Graph__graph,
similarity_fast(g1._Graph__graph, g2._Graph__graph,
_prop("v", g1, label1), _prop("v", g2, label2))
if not g1.is_directed() or not g2.is_directed():
s /= 2
......
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