Dear all,
I am using the package igraph and try to use the neighbors() function. I am
a bit confused, see the following :
Given a graph g with 18 vertices. Names of the vertices are indicated by :
> V(irt.graph)$name
[1] "AT2G41240" "AT3G13610" "AT3G02470" "AT3G30775" "AT3G18290"
"AT4G13770" "AT1G01580" "AT4G19690" "AT1G56430" "AT3G56970"
[11] "AT3G02468" "AT2G43590" "AT4G32410" "AT5G25610" "AT5G13750"
"AT5G13740" "AT4G38770" "AT5G02780"
I want to know the neighbors of my vertices.
I have :
> neighbors(g,0)
[1] 4 7 9 17
AND also :
> V(g)$name[0]
character(0)
That 1st confused me, but I thought that indices count from 1 with the V()
function but from 0 in the neighbors() funtion.
But :
For example, to know the neighbors of my first vertex "AT2G41240"
> V(g)$name[1]
[1] "AT2G41240"
> neighbors(g,V(g)$name=="AT2G41240")
[1] 7 9
or I had (just above) :
> neighbors(g,0)
[1] 4 7 9 17
I know that AT2G41240 has 4 neighbors,
thus
> neighbors(g,V(g)$name=="AT2G41240")
[1] 7 9
does not give to me neighbors of AT2G41240 but of another vertex,
and also :
I know the indices of the 4 neighbors of my vertex
are NOT
> V(g)$name[c(4,7,9,17)]
but in reality :
> V(g)$name[c(5,8,10,18)]
My problem is that I really would like to run the neighbors() function with
the name of my vertex and not to have to add or substract 1 to the indice
of my vertex ....
Thanks a lot,
Florence.
> sessionInfo()
R version 2.10.1 (2009-12-14)
i386-apple-darwin8.11.1
other attached packages:
[1] igraph_0.5.4-1
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.