[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] node names after decomposition
From: |
Tamás Nepusz |
Subject: |
Re: [igraph] node names after decomposition |
Date: |
Tue, 3 Jan 2012 12:15:56 +0100 |
Dear Abel,
> 1. )
> is it possible to keep the node names after graph decomposition? See below:
> (in R)
I think it is possible using vertex attributes; e.g., assign an attribute
called "name" to the vertices and invoke decompose.graph afterwards. The "name"
attributes in the decomposed subgraphs will contain the original names. The
reason it works this way is because what you are seeing originally are not the
names of the nodes, they are just internal identifiers. igraph guarantees that
the identifiers are continuous between zero and |V|-1, therefore it has to
assign new identifiers when a graph is decomposed. (And, in case you are
wondering why there is a need for internal IDs: igraph's core is implemented in
C where it is much easier to work with a continuous range of integers than with
arbitrary identifiers).
So, anyway, try doing this:
n <- vcount(g4)
V(g4)$name <- 1:n
decompose.graph(g4, mode="weak")
> 2.)
> Direction 1->0 in the first component and 0->1 in the second are named simply
> after the bigger/smaller original values (346>110 but 162<343)
It could be the case in the current implementation, but I wouldn't rely on that.
Cheers,
Tamas