igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] selecting vertices by name


From: Bernie Hogan
Subject: Re: [igraph] selecting vertices by name
Date: Thu, 21 Apr 2011 12:14:49 +0100

Hey! That's a really nice solution. Is it linear time search? 

Take care,
BERNiE 

Dr Bernie Hogan
Research Fellow, Oxford Internet Institute
University of Oxford

http://www.oii.ox.ac.uk/people/?id=140



On Thu, Apr 21, 2011 at 11:35 AM, Tamas Nepusz <address@hidden> wrote:
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:

g.vs.find("node1")

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.

--
T.

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


reply via email to

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