igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] edge indexing


From: Gábor Csárdi
Subject: Re: [igraph] edge indexing
Date: Mon, 15 Jun 2015 09:20:06 -0400

Hi,

I understand that reassigning ids is very difficult to work with, it
was a decision long time ago, and unfortunately we have to live with
it now, and for the foreseeable future.

A useful way of thinking about this, especially in R, is that igraph
_never_ modifies a graph. It always creates new graphs. So when you
say delete.edges(), the old graph is not modified, and a new graph is
created based on it.

In general, you cannot assume anything about the relationship between
the internal ids of the old graph and the new graph.

I hope this helps,
Gabor

On Mon, Jun 15, 2015 at 7:02 AM, Elena Tea Russo
<address@hidden> wrote:
>
> Thank you very much!
>
> Then I will use, as you suggest, attributes.
>
>
> Et Russo
>
> Il giorno 15/giu/2015, alle ore 12:56, Tamas Nepusz <address@hidden> ha 
> scritto:
>
>>> In particular, I can't understand what happens to edges' id when I 
>>> add/remove
>>> egdes and when I transform an undirected graph to a directed (MUTUAL) one.
>> igraph does not _guarantee_ anything -- if you need to keep track of edges'
>> identities after a destructive graph operation, you have to add a unique
>> attribute to the edges and look edges up based on these unique attributes, 
>> or,
>> alternatively, search for edges based on the endpoints instead of relying on
>> edge IDs.
>>
>>> In the first case, I suppose that, if you have a graph with N edges indexed
>>> from 0 to N-1 and you add the (N+1)th edge, it will be indexed as N. Am
>>> I right or am I not?
>> Yes, this is correct, although the official documentation does not claim that
>> it will always stay this way. (I see no reason to change it in the future,
>> though).
>>
>>> Then, what happens when I remove an edge? there will be a gap or a 
>>> re-indexing?
>> igraph will reindex some of the edges to close the gap. The actual mechanism
>> for reindexing is up to igraph to decide and we make no guarantees that it 
>> will
>> not change in the future.
>>
>>> And, in particular: let us suppose i have an undirected graph with N edges,
>>> indexed from 0 to N-1. I want to transform the graph into a directed one 
>>> with
>>> mutual edges, i.e. the number of edges will be doubled. What happens to the
>>> ids? Let us suppose I consider the edge indexed as j; the mutual edge will 
>>> be
>>> j+1 (and thus, the old edges will be re-indexed) or N+j? Or something else?
>> The _current_ implementation seems to make the "original edges" keep their 
>> IDs
>> between 0 and N-1, and uses the range N to 2*N-1 to store the "reversed 
>> edges".
>> However, I have to stress that it is not guaranteed and we are free to change
>> it in some future version. A more reliable way is to use igraph_get_eid() (or
>> get_eid() from R or Python) to look up an edge based on its endpoints.
>>
>> T.
>>
>> _______________________________________________
>> igraph-help mailing list
>> address@hidden
>> https://lists.nongnu.org/mailman/listinfo/igraph-help
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help



reply via email to

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