[Top][All Lists]

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

Re: [igraph] about vertex id (in R)

From: Tamás Nepusz
Subject: Re: [igraph] about vertex id (in R)
Date: Wed, 18 Dec 2013 00:20:38 +0100

> 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 


reply via email to

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