[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[igraph] R igraph 1.0 and return.vs.es
From: |
Dr Gregory Jefferis |
Subject: |
[igraph] R igraph 1.0 and return.vs.es |
Date: |
Fri, 26 Jun 2015 21:05:43 +0100 |
Hello,
I have recently upgraded to v1.0.1 of the R igraph package. Thanks for
all your hard work on this. A lot has happened since 0.7.1!
One thing I have noticed is that some of my functions (in CRAN package
nat) now run ~50x slower. I've traced this to a change in behaviour,
where functions like graph.dfs return vertex sequences rather than plain
(integer) vertex ids. subsetting those vertex sequences can be very
slow. This can be changed by the igraph_option return.vs.es=F (which
incidentally does not seem to be documented)
Here is a (stupid) toy example:
g3=graph.tree(500) %du% graph.tree(500)
system.time({d=graph.dfs(g3, root=1, neimode = 'all', father = T);
for(i in 1:length(d$order)) d$order[i] })
user system elapsed
0.713 0.007 0.719
igraph_options(return.vs.es=F)
system.time({d=graph.dfs(g3, root=1, neimode = 'all', father = T);
for(i in 1:length(d$order)) d$order[i] })
user system elapsed
0.001 0.000 0.001
Obviously in this case one can do this:
igraph_options(return.vs.es=T)
system.time({d=graph.dfs(g3, root=1, neimode = 'all', father = T);
do=as.integer(d$order) ; for(i in 1:length(do)) do[i] })
user system elapsed
0.003 0.000 0.002
But this means changing quite a bit of code and there are places where
similar issues cannot be so easily side-stepped.
Two questions:
1. Is this slow down expected?
2. As a package developer, is there any way to ensure I have the
behaviour of igraph_options(return.vs.es=F) when I import the igraph
package (while still giving other users the chance to set
igraph_options(return.vs.es=T) if that is what they want) ?
As a comment, my feeling is that this behaviour should probably be
controlled both at a per function as well as a package option level.
Many thanks for your help,
Greg.
--
Gregory Jefferis, PhD
Division of Neurobiology
MRC Laboratory of Molecular Biology
Francis Crick Avenue
Cambridge Biomedical Campus
Cambridge, CB2 OQH, UK
http://www2.mrc-lmb.cam.ac.uk/group-leaders/h-to-m/g-jefferis
http://jefferislab.org
http://flybrain.stanford.edu
- [igraph] R igraph 1.0 and return.vs.es,
Dr Gregory Jefferis <=