I'm using the igraph
package in R
to analyze network data. I'm currently trying to calculate some centrality measures for the vertices of my graph and the corresponding centralization scores. My network is both directed and weighted.
require(igraph)
set.seed(12152)
m <- expand.grid(from = 1:4, to = 1:4)
m <- m[m$from != m$to, ]
m$weight <- sample(1:7, 12, replace = T)
g <- graph.data.frame(m)
I have no trouble using the closeness
function to obtain the closeness centrality for each vertex:
closeness(g, mode = "in")
closeness(g, mode = "out")
closeness(g, mode = "total")
However, it appears that the centralization.closeness
function from igraph
does not work for directed graphs. igraph
does include a way to calculate a custom centralization from the individual centrality scores in a graph (the centralize.scores
function), but that function requires the user to specify the theoretical maximum of the centrality measure, and it's not obvious to me what that would be in this weighted example (I believe the built-in centralization.closeness.tmax
function in igraph
assumes an unweighted graph).
Does anyone know how to calculate a centralization score in a weighted graph? Is there a good way to accomplish this in R with igraph
or some other package?