如何在igraph中获得具有更大度中心性的顶点

时间:2016-03-18 14:53:34

标签: r igraph

我希望使用igraph R获得具有最高度中心度的顶点,我尝试使用:

V(g)[degree(g,V(g)$id) == which.max(degree(g))]

但它不起作用。

1 个答案:

答案 0 :(得分:0)

尝试

library(igraph)
set.seed(5)
g <- ba.game(100)
V(g)$id <- paste0("id", 1:100)
(idx <- which(degree(g)==max(degree(g))) )
V(g)$id[idx]
# [1] "id1" "id2"

# optional plot
cols <- rep("blue", vcount(g)); cols[idx] <- "red"; plot(g, vertex.shape="none", vertex.label.color=cols, edge.arrow.size=.5)