igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] V(g) slow in a loop


From: Gábor Csárdi
Subject: Re: [igraph] V(g) slow in a loop
Date: Mon, 15 Feb 2016 19:34:34 +0000

Hi, can you send a reproducible example? See
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

Gabor

On Mon, Feb 15, 2016 at 6:28 PM, Tony Larson <address@hidden> wrote:
>
> Hi,
> I'm accessing a vertex attribute in R using V(g)$x,  where x is a named
> numeric attribute. If I do this for the whole graph (about 10e5 vertices),
> it takes a few ms to get a vector of x values,
>
> vx <- V(g)$x
>
> If I then use vx as a target vector  in an R loop to search through about
> 10e3 candidate y values for x, it takes maybe 100 ms,
>
> for(i in 1:length(y))
> {
> z <- which(vx > y[i])
> }
> However,  if I substitute V(g)$x for vx INSIDE the loop,  it takes about 5s
> - more than 50x slower. Why is this?
>
> Thanks
> Tony
>
> Dr. Tony R. Larson
> CNAP
> Department of Biology, Area 7
> University of York
> Wentworth Way
> Heslington
> York YO10 5DD
> UK
>
> Tel: +44(0)1904 328 826 (office)
> Tel: +44(0)7833 471 685 (mobile)
>
> address@hidden
>
> http://scholar.google.com/citations?user=9hLFka4AAAAJ
>
>
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]