找到具有最高中心性的节点

find the node with highest centrality

我有一个包含许多不同组件的网络。我需要为 Gephi 和 R 中的每个组件找到具有最高介数和紧密度中心性的节点?[​​=10=]

我可以提取全局网络中心度最高的节点,但每个组件都需要它。我该怎么做?

下面是一个例子,它使用 igraph:

为网络的每个连接组件查找具有最高接近度中心性的顶点
library(igraph)
set.seed(1)

# random graph with two connected components
adj <- matrix(rbinom(n=900, size=1, prob=0.5), nrow=30)
adj[1:15,16:30] <- 0
adj[16:30,1:15] <- 0

g <- graph.adjacency(adj)

# assign a "label" property to keep track of original vertex labels after
# decomposing the network
V(g)$label <- labels(V(g))

# iterate over connected components and find vertex with maximum closeness
# centrality
connected_components <- decompose(g)

for (i in seq_along(connected_components)) {
    subnet <- connected_components[[i]]
    # Vertex with the largest centrality
    max_centrality <- V(subnet)[which.max(closeness(subnet))]$label
    print(sprintf("Vertex with max centrality for component %d: %s", i, max_centrality))
}

igraph 还具有计算其他类型中心性的函数,例如betweeness centrality.