简体   繁体   English

R中igraph包的紧密中心性

[英]Closeness centrality with igraph package in R

I wanted to measure closeness centrality, specifically incloseness and outcloseness, with the igraph package in R version 3. I used the dataset "flo" in the package "network" to do the analysis. 我想使用R版本3中的igraph包来测量紧密度中心度,尤其是紧密度和紧密度。我使用数据包“网络”中的数据集“ flo”进行分析。 the density (graph.density) and centralization (centralization.degree) functions of igraph package worked fine. igraph软件包的密度(graph.density)和集中化(centralization.degree)功能运行良好。 but the closeness function showed errors. 但是贴近度函数显示错误。 The code and the errors are posted below: 代码和错误如下:

code: 码:

library(network)
library(igraph)
data(flo)
gr <- graph.adjacency(flo, mode="undirected")
closeness(gr)

error: 错误:

Error in FUN(X[[1L]], ...) : 
as.edgelist.sna input must be an adjacency matrix/array, edgelist matrix, network, or sparse matrix, or list thereof.

I am new to network analysis and the R packages for the analysis. 我是网络分析和R软件包分析的新手。 Can someone please show me what went wrong and how to do it? 有人可以告诉我哪里出了问题以及如何解决吗?

Why don't you give this a try and see if it works for you: 您为什么不尝试一下,看看它是否对您有用:

centralization.closeness(gnr)

For some reason some of the commands in igraph only work with "centralization." 由于某种原因,igraph中的某些命令仅适用于“集中化”。 appended to them. 附加到他们。 I'm in the process of figuring this out myself. 我正在自己弄清楚这一点。

Hope this helps. 希望这可以帮助。

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

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