For each edge in a graph I would like to add an numeric attribute (weight) that is the product of an attribute (probability) of the incident vertices. I can do it by looping over the edges; that is:
for (i in E(G)) {
ind <- V(G)[inc(i)]
p <- get.vertex.attribute(G, name = "prob", index=ind)
E(G)[i]$weight <- prod(p)
}
However, this is qute slow for my graph (|V| ~= 20,000 and |E| ~= 200,000). Is there a faster way to do this operation?