igraph-help
[Top][All Lists]
Advanced

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

[igraph] V(g) slow in a loop


From: Tony Larson
Subject: [igraph] V(g) slow in a loop
Date: Mon, 15 Feb 2016 18:28:14 +0000


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

   


reply via email to

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