igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] working with graphs without reindexing them


From: Tamas Nepusz
Subject: Re: [igraph] working with graphs without reindexing them
Date: Tue, 7 Sep 2010 16:55:30 +0100
User-agent: Mutt/1.5.20 (2009-06-14)

Hi Sergiu,

> What is the best way to load a subgraph without reindexing the node labels?
Assuming that your graph is stored in a flat file with two numbers per
line (vertex1 and vertex2), load them using the NCOL loader
(igraph_read_graph_ncol). The numeric vertex IDs will be set up by
igraph arbitrarily, but the NCOL loader will set up a vertex attribute
named "name" that contains the *original* vertex IDs in the file (as
strings, since the NCOL format may contain string vertex IDs as well).
After that, you can set up a quick indexing array that tells you the
igraph vertex ID based on your original vertex ID and use that when
calling igraph functions (but of course you have to update the indexing
when you delete vertices orr add new ones).

In order to use this functionality of the NCOL reader, you must attach
the C attribute handler first, see more details here:

http://igraph.sourceforge.net/doc/html/ch09s02.html

> Also, what happens if a node gets removed? The whole set of nodes gets
> reindexed?
Yes, they do, but the assigned vertex attributes are kept, so you can
still track your vertices using the vertex attributes.

> as I understood node labeling is not well supported in igraph, am I
> right?
Well, there is the above mentioned attribute handler in the C layer. It
is branded as "experimental" in the manual, but if you are working with
a recent igraph version (0.5.3) or the development branch (0.6), the
attribute handler should be pretty stable -- I'm using it myself without
problems.

-- 
Tamas



reply via email to

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