[R] [igraph] per-vertex statistics of edge weights

Gábor Csárdi csardi at rmki.kfki.hu
Thu Aug 16 03:04:47 CEST 2012


On Wed, Aug 15, 2012 at 4:10 PM, Sam Steingold <sds at gnu.org> wrote:
[...]
> Also, this takes forever and consumes almost all 8GB RAM.
> It has been running on
>
> --8<---------------cut here---------------start------------->8---
> IGRAPH DNW- 18590 6734992 --
> + attr: name (v/c), count (v/n), weight (e/n)
> --8<---------------cut here---------------end--------------->8---
>
> for an hour and a half now.
[...]

g <- erdos.renyi.game(18590, 6734992, type="gnm")
E(g)$weight <- runif(ecount(g))

and then

al <- get.adjedgelist(g)
w <- E(g)$weight
tmp <- sapply(al, function(e) mean(w[e]))

is fairly quick:

> system.time(tmp <- sapply(al, function(e) mean(w[e])))
   user  system elapsed
  1.353   0.069   1.458

Gabor

-- 
Gabor Csardi <csardi at rmki.kfki.hu>     MTA KFKI RMKI



More information about the R-help mailing list