igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] edge indexing


From: Tamas Nepusz
Subject: Re: [igraph] edge indexing
Date: Mon, 15 Jun 2015 12:56:52 +0200
User-agent: Mutt/1.5.23 (2014-03-12)

> 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.



reply via email to

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