Reputation: 447
I am trying to get the neighbors of a specific node in my graph. Graph looks like this
print g
IGRAPH UN-- 6 3 --
+ attr: name (v), position (v)
+ edges (vertex names):
40--115, 116--98, 44--98
g.vs['name]
[116, 40, 44, 115, 98, 116]
I have tried to use the following to get the neighbors of 40
g.neighbors(g.vs['name'][1])
but I get the following error:
InternalError: Error at type_indexededgelist.c:750: cannot get neighbors, Invalid vertex id
I have also tried this, but get a different error
g.neighbors('40')
ValueError: no such vertex: '40'
any ideas?
Upvotes: 2
Views: 1450
Reputation: 36
You are passing the function neighbors a string, but it expects an integer or Vertex object. try:
g.neighbors(g.vs[1])
or
g.neighbors(1)
Upvotes: 1