[英]r - How to find name of Max vlaue in Closeness Centrality igraph output
I use of igraph package in R for work on graph. 我在R中使用igraph包进行图形处理。 I get Closeness Centrality with igraph method, and I want to find maximum value in Closeness with name.
我使用igraph方法获得了“ 紧密度中心性” ,我想用名称在“紧密度”中找到最大值。
library(igraph)
# Create of Graph Matrix for Test Closeness Centrality
g <- read.table(text="A B
1 2
2 3
3 4
4 5", header=TRUE)
gadj <- get.adjacency(graph.edgelist(as.matrix(g), directed=FALSE))
igObject <- graph.adjacency(gadj) # convert adjacency matrix to igraph object
gCloseness <- closeness(igObject) # Assign Closeness to Variable for print
When I use of max()
I get maximum value of Closeness and when use of names()
back NULL. 当我使用
max()
我会获得最大的接近度,而当使用names()
返回NULL。
> max(gCloseness)
[1] 0.1666667
other: 其他:
> names(max(gCloseness))
NULL
试试V(igObject)[which.max(gCloseness)]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.