我试图计算两个顶点之间共有的邻居数。
测试文件包含
1 2
1 4
1 5
2 3
2 4
2 5
3 4
y<-read.table("test.txt")
require(igraph)
g<-graph.data.frame(y, directed=F, vertices=NULL)
for(i in 1:5)
{
for(j in 1:5)
{
c[i,j]<-cocitation(g,i)[j]
}}
y$neigC<-c[y$V1,y$V2]
但是,当我尝试将其添加到数据框中时,它无法给我正确的答案。