igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Possible bug in python "find()" command?


From: Tamas Nepusz
Subject: Re: [igraph] Possible bug in python "find()" command?
Date: Tue, 23 Dec 2014 10:41:15 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

Hello Nick,

This is a bug -- or well, not exactly a bug since I was aware of it but did not
have the time to implement it properly yet. The find() method of VertexSeq and
EdgeSeq objects are a bit convoluted; basically, the handling of positional
arguments for find() and select() are implemented in C, but the handling of
keyword arguments would have been too complex to do in C so those are
implemented in Python. Therefore, g.vs.find(i) goes down to the C layer,
figures out that you have passed a single string so it does a dictionary lookup
and returns the vertex that it has found. In contrast, g.vs.find(name=i) just
translates the call to g.vs.select(name=i)[0], and select() does *not* do
a dictionary lookup (because theoretically there could be more than one vertex
with the same name.

The obvious workaround would be to make "name" and "name_eq" a special case in
find() so these calls do not get forwarded to select(). If you feel like
submitting a quick patch for it, let me know -- otherwise I'll try to find some
time to implement this during the holidays.

All the best,
T.

On 12/23, Nick Eubank wrote:
> Hi All,
> 
> I've been working with a relatively large graph, and have been having some
> trouble with the find() command. In particular, I'm finding the following
> two commands run at very, very different speeds (on a toy graph with
> 100,000 users and 1,000,000 nodes -- my actual graph has same problem, but
> is 100x larger).
> 
> Blazing fast:
> 
>     for i in g.vs['name']:
> 
>         g.vs.find(i)
> 
> Very, very slow :
> 
>     for i in g.vs['name']:
> 
>         g.vs.find(name = i)
> 
> And yes, all names are strings, so this isn't the case one is querying by
> index and the other by names.
> 
> Is there a reason why? My understanding was taht these were supposed to be
> equivalent (as suggested in the tutorial -
> http://igraph.org/python/doc/tutorial/tutorial.html ). I can work around,
> but wasn't sure if this was a bug or not, so thought I'd bring it up!
> 
> Thanks!
> 
> Nick

> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help


-- 
T.



reply via email to

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