Bishwarup Paul
Bishwarup Paul

Reputation: 361

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. the density (graph.density) and centralization (centralization.degree) functions of igraph package worked fine. 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. Can someone please show me what went wrong and how to do it?

Upvotes: 1

Views: 2612

Answers (1)

mberrett
mberrett

Reputation: 92

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." appended to them. I'm in the process of figuring this out myself.

Upvotes: 3

Related Questions