igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Simple syntax questions


From: Tamas Nepusz
Subject: Re: [igraph] Simple syntax questions
Date: Tue, 14 Apr 2009 11:08:46 +0100

I got it to work by doing "len(names_to_idxs._ids)". Not sure if that is the correct way to do it though.
Yeah; another way is to add the following to the class definition (I intended to do that originally, but it seems it was forgotten somehow):

    def __len__(self):
        return len(self._ids)

From then on, you can call len(...) directly on the names_to_idxs map.

A good addtion to this code would be to allow it to be flipped around, so you could call all those items by using the id. Then you could loop back through it and add each as a vertices name attribute. :-)
You just guessed what I did last evening. The updated snippet is here:

http://snipplr.com/view/13190/unique-id-sequence-class/

(see the new reverse_dict() and values() methods).

--
T.





reply via email to

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