I created a weighted network using both igraph and statnet in R. I am now studying centrality measures of my weighted network using statnet, but the centrality measures I obtain are as if statnet did not take into account the values of my edges. Here is a small example to illustrate my problem, using the degree centrality measure.
I created my network using igraph:
nodes <- data.frame(id=c(1,2,3,4,5))
edges <- data.frame(source=c(1,1,2,2,3),
target=c(2,3,3,5,4),
weight=c(1,2,1,2,1))
library(igraph)
network <- graph_from_data_frame(d=edges, vertices=nodes, directed=FALSE)
Then I needed to use the statnet package so I transformed it the following way
network_statnet <- asNetwork(network)
detach("package:igraph", unload=TRUE)
library(statnet)
Then I wanted to compute the degree centrality, first without taking the edges values into account (degree_unweighted
), and then taking the edges values into account (degree_weighted
)
degree_unweighted<-degree(network_statnet, gmode="graph", ignore.eval=TRUE)
degree_weighted<-degree(network_statnet, gmode="graph", ignore.eval=FALSE)
But I end up with exaclty the same centrality measures. I do not know why statnet does not take into account the values of my edges when I specify ignore.eval=FALSE
. I have the same problem with other centrality measures (betweenness, closeness, eigenvector).