Network Diameter and Clustering Coefficient Analysis

In this exercise, we will further explore the characteristics of social networks by examining the diameter and clustering coefficient of a network using the Moreno dataset.

Network Diameter

The network diameter is a measure of the “longest shortest path” between any two nodes in the network. It provides an understanding of the network’s compactness. If the network has more than one component, we choose the largest component for this calculation.

In R, we can calculate the diameter of a network using the following code:

largest_component <- component.largest(Moreno, result="graph")
geodesic_distances <- geodist(largest_component)
max(geodesic_distances$gdist)
[1] 11

In the igraph package, the diameter() function can be applied directly.

Clustering Coefficient

The clustering coefficient, or transitivity, represents the percentage of closed triangles over all open and closed triangles in the network. It provides an understanding of the network’s tendency to form clusters.

In R, we can calculate the clustering coefficient of a network using following code:

gtrans(Moreno, mode="graph")
[1] 0.2857143

In the igraph package, this can easily be calculated with the transitivity() function.

Exercise

Calculate the diameter and clustering coefficient of the Facebook data set using the igraph functions and store it in fb_diameter and fb_cluster_coef, respectively. Note that you will have to use the facebook object that has not been converted to a network object. You can load the fresh dataset without alterations by calling data(Facebook) again.

To download the facebook dataset click: here1


Assume that: