igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Keeping track of reassigned IDs in C


From: Tamás Nepusz
Subject: Re: [igraph] Keeping track of reassigned IDs in C
Date: Mon, 30 Jul 2012 21:12:21 +0200

Hi Nils, 

> The Python lib somehow keeps track of those ID changes (see for example
> the mailing list post [1]) and I had a look at the source code for the
> Python bindings but I can't find out how it manages to do so.

The key is in the attribute handler interface of the C core library. Basically, 
igraph supports attaching data to the vertices and the edges (and also to the 
graph as a whole), but it is left up to a separate module which communicates 
with the main library via the attribute handler interface. Whenever a graph 
changes in a way that might affect the attributes, the core notifies the 
attribute handler with appropriate function calls and the handler can then act 
appropriately. The Python interface uses one specific attribute handler which 
stores the attributes in Python-specific data structures; the R interface has a 
different attribute handler that is suitable for R objects, and the C core also 
contains a very basic attribute handler that supports numeric and string 
attributes only. See the following chapters in the manual:

http://igraph.sourceforge.net/doc/html/igraph-Attributes.html
http://igraph.sourceforge.net/doc/html/ch12s01.html

In particular, igraph_subgraph calls the permute_vertices and permute_edges 
functions of the attribute handler interface to inform the attribute handler 
about a mapping between the old vertex IDs and the new ones. The Python 
interface then adjusts its internal attribute storage appropriately. Note that 
there is no way to avoid the change in vertex/edge IDs as igraph requires these 
to be consecutive, starting from zero, but you can at least update your data 
structures in Haskell to follow this.

Best,
Tamas






reply via email to

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