繁体   English   中英

如何获取igraph中度数中心性最高的顶点

[英]How to get the vertex with the highest degree centrality in igraph

我想使用igraph获得具有最高度数中心性的顶点。

我尝试了以下代码,但它没有返回我所期望的:

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

尝试

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)
V(g)$degree <- degree(g)

which.max(V(g)$degree)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM