First of all I want to say that I already read answers for the question: "issues with R “igraph” package neighbor function" and I tried to solve my problem but I couldn't. I tried to ask my question as follow up comment but because of low level of reputation I couldn't, therefore I open this new question. Now here is my question: I have the same problem with neighbors function as it has been explained in: "igraph” package neighbor function but when I try the solution which is given by Gabor Csardi I just received null as result. I attached that part of my code here as well. I would be really thankful for any help and answer. my table:
edgelist <- read.table(text = "
1 2
2 3
3 4
4 5
3 6
6 7")
library(igraph)
graph <- graph.data.frame(edgelist)
str(graph)
## IGRAPH DN-- 7 6 --
## + attr: name (v/c)
## + edges (vertex names):
## [1] 1->2 2->3 3->4 4->5 3->6 6->7
now if I want the neighbors of the node 3 it should be
2, 4, 6
but the result I got is:
2, 4, 5
I noticed it changed the order of my nodes. As I explained before I try the solution that I found in stack overflow but I got null as result:
graph$name[neighbors(graph, 3)]
NULL
I don't know what else I can do, I would appreciate any help.