[Top][All Lists]

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

Re: [igraph] selecting vertices by name

From: Tamas Nepusz
Subject: Re: [igraph] selecting vertices by name
Date: Thu, 21 Apr 2011 12:35:57 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20110223 Lightning/1.0b2 Thunderbird/3.1.8

Hi Bernie,

> However, I want to be able to interact with a node, doing things like
> assigning attributes to it by querying it. For example
> G.vs["node1"].index  rather than keep a parallel list. The problem with the
> parallel list is that it has to be updated any time I add or delete a node,
> and so I feel it is not as robust. 
> Has that subsequently been implemented? (I'm using a custom compiled 0.6 on
> Python 2.6). 
Yes, now the 0.6 version has something like this:


This returns a Vertex object just like the ones you get when indexing g.vs.
In the long run, g.vs.find will be similar to g.vs.select, but while
g.vs.select gives you a vertex sequence with the vertices matching a query,
g.vs.find will give you the _first_ vertex in the vertex sequence that
matches a query.

(In case you wonder why g.vs["node1"] would not work: indexing g.vs with
strings is already used for attribute retrieval).

If you can hold on till tomorrow, I can add keyword argument handling to
g.vs.find (which I've been wanting to do for a long time, I just needed a
small incentive), making it a fully functional counterpart for g.vs.select.
(E.g., you could do g.vs.find(_degree=0) to find an arbitrary isolated node,
or g.vs.find(country_code="GB") to find the first node with a "country_code"
attribute equal to "GB" and so on.


reply via email to

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