>  
> gene pair. So I firstly mapped the genes into ids (from 1 to n, where n is 
> the gene number) and then describe the network by ids. Finally I used 
> "read.graph(file="biggestComponent_id.txt",format="edge list") to input the 
> network. But I found the ids seems different from the input ids (likely added 
> by "1").
Most of igraph is written in C, which uses zero-based indices by default (so 
edge and vertex IDs start from zero). However, R is using 1-based indices 
everywhere so the R interface of igraph also provides 1-based indexing almost 
everywhere; the only exception is the edgelist file format. This is because 
edge list files may be saved and loaded from the C core of igraph or from the 
Python interface of igraph as well, so there would be quite a bit of confusion 
if edge lists saved from R used 1-based indices while edge lists saved from C 
or Python used 0-based indices. Therefore, whenever you load an edge list into 
igraph’s R interface, igraph assumes that the vertex indices in the file are 
0-based and adds 1 to them automatically to obtain the vertex IDs that R will 
use. Similarly, whenever you save an edge list from igraph’s R interface into a 
file, igraph will subtract 1 from the vertex IDs used in R to obtain a 0-based 
indexing.

Best,
T.



_______________________________________________
igraph-help mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/igraph-help

Reply via email to