1

Can anyone help me to find the number of common neighbors of two vertices using igraph R.

I tried to get this with following command but it returned with list().

intersect(neighborhood(graph=TD1,order=1,nodes=714),neighborhood(graph=TD1,order=1,nodes=4211))

>>>> list()

Thanks

Anna

peter_the_oak
  • 3,353
  • 2
  • 20
  • 35
Anna
  • 83
  • 9
  • Please include a minimal reproducible example. http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Gabor Csardi Mar 10 '15 at 00:32

1 Answers1

1

neighborhood() returns a list of integer vectors, one for each source node you passed in. Since you only have a single source node, you have to extract the first element of the list that neighborhood() returns before passing them to intersect():

intersect(
    neighborhood(graph=TD1, order=1, nodes=714)[[1]],
    neighborhood(graph=TD1, order=1, nodes=4211)[[1]]
)
Tamás
  • 45,942
  • 11
  • 97
  • 122