Commit a2a87884 authored by Tiago Peixoto's avatar Tiago Peixoto

Improve parallelism in motifs()

parent a5ef466f
Pipeline #257 failed with stage
in 175 minutes and 39 seconds
...@@ -372,72 +372,76 @@ struct get_all_motifs ...@@ -372,72 +372,76 @@ struct get_all_motifs
typename wrap_undirected::apply<Graph>::type ug(g); typename wrap_undirected::apply<Graph>::type ug(g);
get_subgraphs(ug, v, k, subgraphs, sampler); get_subgraphs(ug, v, k, subgraphs, sampler);
#pragma omp critical (gather) for (size_t j = 0; j < subgraphs.size(); ++j)
{ {
for (size_t j = 0; j < subgraphs.size(); ++j) d_graph_t sub;
{ typename wrap_directed::apply<Graph,d_graph_t>::type
d_graph_t sub; usub(sub);
typename wrap_directed::apply<Graph,d_graph_t>::type make_subgraph(subgraphs[j], g, usub);
usub(sub); get_sig(usub, sig);
make_subgraph(subgraphs[j], g, usub);
get_sig(usub, sig);
#pragma omp critical (gather)
{
bool skip = false;
auto iter = sub_list.find(sig); auto iter = sub_list.find(sig);
if(iter == sub_list.end()) if(iter == sub_list.end())
{ {
if (!fill_list) if (!fill_list)
continue; // avoid inserting an element in sub_list skip = true; // avoid inserting an element in sub_list
sub_list[sig].clear(); sub_list[sig].clear();
} }
bool found = false; if (!skip)
size_t pos;
auto sl = sub_list.find(sig);
if (sl != sub_list.end())
{ {
for (auto& mpos : sl->second) bool found = false;
size_t pos;
auto sl = sub_list.find(sig);
if (sl != sub_list.end())
{ {
d_graph_t& motif = mpos.second; for (auto& mpos : sl->second)
typename wrap_directed::apply<Graph,d_graph_t>::type
umotif(motif);
if (comp_iso)
{
if (isomorphism(umotif, usub,
vertex_index1_map(get(boost::vertex_index, umotif)).
vertex_index2_map(get(boost::vertex_index, usub))))
found = true;
}
else
{ {
if (graph_cmp(umotif, usub)) d_graph_t& motif = mpos.second;
found = true; typename wrap_directed::apply<Graph,d_graph_t>::type
} umotif(motif);
if (found) if (comp_iso)
{ {
pos = mpos.first; if (isomorphism(umotif, usub,
hist[pos]++; vertex_index1_map(get(boost::vertex_index, umotif)).
break; vertex_index2_map(get(boost::vertex_index, usub))))
found = true;
}
else
{
if (graph_cmp(umotif, usub))
found = true;
}
if (found)
{
pos = mpos.first;
hist[pos]++;
break;
}
} }
} }
}
if (found == false && fill_list) if (found == false && fill_list)
{ {
subgraph_list.push_back(sub); subgraph_list.push_back(sub);
sub_list[sig].emplace_back(subgraph_list.size() - 1, sub_list[sig].emplace_back(subgraph_list.size() - 1,
sub); sub);
hist.push_back(1); hist.push_back(1);
pos = hist.size() - 1; pos = hist.size() - 1;
found = true; found = true;
} }
if (found && collect_vmaps) if (found && collect_vmaps)
{ {
if (pos >= vmaps.size()) if (pos >= vmaps.size())
vmaps.resize(pos + 1); vmaps.resize(pos + 1);
vmaps[pos].push_back(VMap(get(boost::vertex_index,sub))); vmaps[pos].push_back(VMap(get(boost::vertex_index,sub)));
for (size_t vi = 0; vi < num_vertices(sub); ++vi) for (size_t vi = 0; vi < num_vertices(sub); ++vi)
vmaps[pos].back()[vertex(vi, sub)] = subgraphs[j][vi]; vmaps[pos].back()[vertex(vi, sub)] = subgraphs[j][vi];
}
} }
} }
} }
......
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