On Wed, Sep 8, 2010 at 3:41 PM, Tamas Nepusz
<address@hidden> wrote:
> To all this I see one problem though: in igraph I found no function that
> returns the node id that has a certain label. Of course I could write my own
> function for that as well, that loops through all nodes and returns the node
> id that has a certain label. But I am afraid it is not very optimized.
If you worry about performance, you can use a red-black tree (or a hash
table, or whichever you prefer) to look up IDs based on names; a C
implementation of red-black trees is here:
http://web.mit.edu/~emin/www/source_code/red_black_tree/index.html
igraph also contains a trie data structure that you might find useful if
your IDs are strings. This is undocumented, but the function headers are
in types.h, and you can also browse the source code for the trie data
structure here:
http://bazaar.launchpad.net/~igraph/igraph/0.5-main/annotate/head%3A/src/igraph_trie.c
--