计算 R igraph 网络中连接最多的节点

Count the nodes with most connection in a network in R igraph

我想统计单向网络中接收到的连接数较多的节点数。

例如在这样的网络中:

g <- graph( c('A',1,'A',2,'A',3,'B',4,'B',5,'B',6,'C',7,'C',8,'D',7,'D',8))

我们会有 3 个独立的组件

加载文件中的数据(测试),我可以上传并表示如下:

plot(g)

如何获取连接数较多的目的节点?在这种情况下将是节点 7 和 8。

在另一个问题 () 之后,我尝试了以下方法:

lengths(as_adj_list(g))

A 1 2 3 B 4 5 6 C 7 8 D 
3 1 1 1 3 1 1 1 2 2 2 2 

结果是计算所有节点的长度,但我只查看目标节点。

我也试过:

 sort(g, decreasing = TRUE)

 Error in intI(i, n = x@Dim[1], dn[[1]], give.dn = FALSE) : index larger than maximal 12

如您所见,我收到一条错误消息

以下评论:通过以下我获得了目标节点的计数,但是我如何获得具有最大计数的节点?[​​=17=]

degree(g4, mode = "in")

有什么想法吗?

谢谢

你可以

library(igraph)
g <- graph( c('A',1,'A',2,'A',3,'B',4,'B',5,'B',6,'C',7,'C',8,'D',7,'D',8))
V(g)$indeg <- degree(g, mode = "in")
V(g)[V(g)$indeg == max(V(g)$indeg)]
#  2/12 vertices, named:
# [1] 7 8