[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] Fast sum of nodes attributes
From: |
Tamas Nepusz |
Subject: |
Re: [igraph] Fast sum of nodes attributes |
Date: |
Mon, 24 Nov 2014 20:11:55 +0100 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
> I would like to know if there is any fastest way to sum the attribute
> "MyAttribute" of all nodes, other than that:
>
> double sum = 0.0;
> for (node = igraph_vcount(&Graph); node--;) {
> sum += VAN(&Graph,"MyAttribute",node);
> }
If your compiler supports OpenMP and you have multiple CPU cores, you can try
this:
double sum = 0.0;
#pragma omp for reduction(+:sum) nowait
for (node = igraph_vcount(&graph); node--; ) {
sum += VAN(&graph, "MyAttribute", node);
}
--
T.