Analyzing the graph structure
Understanding the topology of the network, the role of its nodes, and the presence of communities is a crucial step in the analysis of the social network. It is important to keep in mind that, in this context, nodes are actually users, each with its own interests, habits, and behaviors. Such knowledge will be extremely useful when performing predictions and/or finding insights.
We will be using networkx
to compute a few useful metrics we have seen in Chapter 1, Getting Started with Graphs. We will try to give them an interpretation to collect insight into the graph. Let’s begin as usual, by importing the required libraries and defining some variables that we will use throughout the code:
import os
import math
import numpy as np
import networkx as nx
import matplotlib.pyplot as plt
default_edge_color = 'gray'
default_node_color = '#407cc9'
enhanced_node_color = '#f5b042'
enhanced_edge_color = '#cc2f04&apos...