1
votes

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?

1
It works fine for me. Can you add your session info please? (sessionInfo())? Maybe you should just update your R/packages version.agstudy
@agstudy It also works for me, on OS X, R v3.1.0, igraph v0.7.0, network v1.9.0.Anders Ellern Bilgrau
Maybe you are not showing the full code you were running and you also loaded the sna package and that has a closeness function, too? Or you are using a very old version of R perhaps?Gabor Csardi
I don't know what the error was the last time I was running, but the next time I started R and ran the code again, it was working fine. Maybe Gabor Csardi is right and I also loaded the sna package the last time. But anyway, there doesn't seem to be a problem right now!Bishwarup Paul

1 Answers

3
votes

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.

Hope this helps.