challenge_4
Centrality of a Network
Author

Ben Ramsey

Published

March 6, 2023

Challenge Overview

Describe the many measures of centrality of at least one network of your choice.

Describe the Network Data

If you have not done it before, always start by evaluating the basic structure of the network (number of edges and vertices, dyad and triad census, etc.). Create a data frame nodes with the corresponding local attributes such as degree or local transitivity.

Code
climate <- read.csv("_data/climate0205-allop.csv", sep =  ";") %>% subset(select = -c(X))
climate.ig <- graph_from_adjacency_matrix(as.matrix(climate), weighted = TRUE, mode = "directed", add.rownames = TRUE)
climate.net <- as.network(as.matrix(climate), directed = TRUE, weighted = TRUE)
print(climate.net)
 Network attributes:
  vertices = 34 
  directed = TRUE 
  hyper = FALSE 
  loops = FALSE 
  multiple = FALSE 
  bipartite = FALSE 
  total edges= 291 
    missing edges= 0 
    non-missing edges= 291 

 Vertex attribute names: 
    vertex.names 

No edge attributes
Code
dyad.census(climate.net)
     Mut Asym Null
[1,]  65  161  335
Code
triad.census(climate.net, mode = "graph")
        0    1   2   3
[1,] 3023 2016 787 158
Code
climate.nodes = data.frame(name = climate.net %v% "vertex.names", degree = degree(climate.net), indegree = degree(climate.net, cmode = "indegree"), outdegree = degree(climate.net, cmode = "outdegree"))

Centrality

Compute at least one measure of centrality for each node, adding them as attributes to nodes in the form of extra columns: eigencentrality, betweenness, closeness, etc. Compute the distribution of at least one of those measures. What do we learn from comparing these measures of centrality with an equivalent random network (i.e. with the same number of edges and vertices)?

Code
climate.nodes$bonpow <- bonpow(climate.net)
summary(climate.nodes$bonpow)
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
-2.97105 -0.93405 -0.05148 -0.29414  0.25824  1.45209 
Code
set.seed(1)
random.ig <- sample_gnm(34, 291, directed = TRUE)
random.nodes <- data.frame(bonpow = power_centrality(random.ig))
summary(random.nodes$bonpow)
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
-2.01161 -0.78127 -0.10930 -0.07121  0.57926  2.01038 

The Bonacich power centrality scores also emphasize the fact that there is long right tail when it comes to degree distribution. The random graph has a much more symmetric distribution.