[.igraph.vs slow if lot of objects exist

Bug #528963 reported by Iakov Davydov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
igraph
Fix Released
High
Unassigned

Bug Description

[.igraph.vs uses the folowing code:
i <- eval(i, c(graph[[9]][[3]], adj=adj, nei=nei, from=from, to=to,
                   as.list(parent.frame())))

in case of huge environment this operations takes a lot of time. I am not R expert, but I suppose this is better:

i <- eval(i, c(graph[[9]][[3]], adj=adj, nei=nei, from=from, to=to,
                   envir=parent.frame()))

Revision history for this message
Gábor Csárdi (gabor.csardi) wrote :

Thanks, indeed! Fixed in revision #1590 (0.5-main) and #1785 (0.6-main).

Changed in igraph:
importance: Undecided → High
status: New → Fix Released
Revision history for this message
Gábor Csárdi (gabor.csardi) wrote :

Oooops, this is not a good fix, I reopened the bug....

Changed in igraph:
status: Fix Released → Confirmed
Revision history for this message
Iakov Davydov (iakov-davydov) wrote :

As I said before, I am not R expert… And now I see my error; it's obvious, sorry.
But eval seems to have two arguments: envir and enclos. And "envir is a (pair)list or a data frame. Specifies the enclosure, i.e., where R looks for objects not found in 'envir'"

So it seems that i <- eval(i, envir=c(graph[[9]][[3]], adj=adj, nei=nei, from=from, to=to), enclos=parent.frame()) should work.

I am sorry, can't test that right now. Could you please?

(The easy way is to test speed create some big array like a=rep(0, 100000000))

Revision history for this message
Iakov Davydov (iakov-davydov) wrote :

And by the way it seems that by default enclos is set to parent.frame().

> a=1
> e1=list(b=2)
> (function() {eval(expression(a+b))})()
Error in eval(expr, envir, enclos) : object 'b' not found
> (function() {eval(expression(a+b), e1)})()
[1] 3
> (function() {eval(expression(a+b), e1, NULL)})()
Error in eval(expr, envir, enclos) : object 'a' not found

So maybe we don't need parent.frame here at all?

Revision history for this message
Gábor Csárdi (gabor.csardi) wrote :

You're totally right, of course. I've fixed this, it works as it should have always. Thanks!

Fixed in revisions #1592 (0.5-main) and #1792 (0.6-main).

Changed in igraph:
status: Confirmed → Fix Released
Revision history for this message
Gábor Csárdi (gabor.csardi) wrote : Continue on github

The development of igraph has moved to github, so please do not comment on this bug here. You are of course welcome to comment on github, here:
https://github.com/igraph/igraph/issues/60

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.