Centrality measures are crucial in network analysis as they provide insights
into the individual characteristics of nodes (vertices) within a network.
In this exercise, we will explore three key centrality measures: degree, closeness, and betweenness.
We will use the network
package from the statnet
suite to create and analyze a network.
First, let’s create a network. We will use an adjacency matrix to represent the connections between nodes. Each row and column represent a node, and a value of 1 indicates a connection between the corresponding nodes.
netmat <- rbind(c(0,1,1,0,0,0,0,0,0,0),
c(1,0,1,0,0,0,0,0,0,0),
c(1,1,0,1,1,0,1,0,0,0),
c(0,0,1,0,1,0,0,0,0,0),
c(0,0,1,1,0,1,0,0,0,0),
c(0,0,0,0,1,0,1,0,0,0),
c(0,0,1,0,0,1,0,1,0,0),
c(0,0,0,0,0,0,1,0,1,1),
c(0,0,0,0,0,0,0,1,0,0),
c(0,0,0,0,0,0,0,1,0,0))
rownames(netmat) <- c("A","B","C","D","E","F","G","H","I","J")
colnames(netmat) <- c("A","B","C","D","E","F","G","H","I","J")
net <- network(netmat)
Degree centrality refers to the number of edges that are adjacent to a certain vertex. In other words, it measures the number of direct connections a node has.
degree(net, gmode="graph")
The output is as follows:
2 2 5 2 3 2 3 3 1 1
Closeness centrality measures the average length of the shortest paths from a node to all other nodes in the network. It indicates how close a node is to all other nodes in the network.
closeness(net, gmode = "graph")
The output is shown below:
0.4090909 0.4090909 0.6000000 0.4285714 0.4500000 0.4500000 0.6000000 0.4736842 0.3333333 0.3333333
Betweenness centrality quantifies the number of times a node acts as a bridge along the shortest path between two other nodes. It measures the influence of a node over the flow of information in the network.
betweenness(net, gmode="graph")
0.0 0.0 20.0 0.0 2.5 2.0 19.5 15.0 0.0 0.0
What is the maximum possible degree of a vertex in a network?