April 2019
Beginner
190 pages
4h 54m
English
Let's see how the preceding results compare to a real social network (McAuley & Leskovec, 2012). The following code loads the network and calculates the mean shortest path and mean clustering:
# Load data file into networkfrom pathlib import Pathdata_dir = Path('.') / 'data'G_social = nx.read_edgelist( data_dir / 'mcauley2012' / 'facebook_combined.txt')nx.average_shortest_path_length(G_social)3.6925068496963913nx.average_clustering(G_social)0.6055467186200876
The clustering is very similar to the ring network model, but the mean shortest path is much smaller. There appears to be a paradox: we expect long path lengths in highly clustered networks, but highly clustered social networks seem to have very small path lengths. ...
Read now
Unlock full access