igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Getting verticies ids' after igraph_delete_vertices()


From: Gábor Csárdi
Subject: Re: [igraph] Getting verticies ids' after igraph_delete_vertices()
Date: Sat, 3 Jan 2009 14:05:51 +0100

On Sat, Jan 3, 2009 at 1:44 PM, Sergey Aleynikov
<address@hidden> wrote:
[...]
> While i just add vertexes, i can easily get their ids' - they're just
> incresaing. So there's no problem maintaining object->vertex correspondence.
> But what to do when any vertex is deleted? How to get new ids? The only
> solution that figures out of released 0.5.1 documentation is store with each
> vertex some attribute (object ref) and then re-scan all vertexes, getting
> attributes and setting obj->vertex correspondence. But that can be really
> heavy on large number of vertexes.

Actually, for the current implementation it is very easy to work out
the new ids, but I would not rely on this in the long run.

> Is there any simplier way to do this? As i hope, Python/Ruby modules have
> some workaround.

I don't really know the Python/Ruby modules, so I don't know what
exactly they have, but this can be done with vertex attributes and no
"rescanning" is needed I guess.

You can write a "handler" function in C (or call back to Perl if you
like, the R interface does this), and this function will be called
whenever vertices are to be deleted from the graph. E.g. in R,
arbitrary R objects can be assigned as attributes; these are stored in
lists and the R attribute handler only does an R indexing operation
when vertices are deleted. (The same for edges.) This is simple enough
in theory and not that difficult to code in practice.

Does this help?

Btw., I'm in the middle if rewriting the internals of the igraph
attribute handling code, so don't be surprised if everything changes
in a couple of months. Sorry about this.

Gabor

[...]

-- 
Gabor Csardi <address@hidden>     UNIL DGM




reply via email to

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