15.08.2015 Views

Introduction to the Modeling and Analysis of Complex Systems

introduction-to-the-modeling-and-analysis-of-complex-systems-sayama-pdf

introduction-to-the-modeling-and-analysis-of-complex-systems-sayama-pdf

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

17.4. CLUSTERING 387while <strong>the</strong> numera<strong>to</strong>r is <strong>the</strong> number <strong>of</strong> such triplets where j is also connected<strong>to</strong> k. This essentially captures <strong>the</strong> same aspect <strong>of</strong> <strong>the</strong> network as <strong>the</strong> averageclustering coefficient, i.e., how locally clustered <strong>the</strong> network is, but <strong>the</strong> transitivitycan be calculated on directed networks <strong>to</strong>o. It also treats each triangle moreevenly, unlike <strong>the</strong> average clustering coefficient that tends <strong>to</strong> underestimate <strong>the</strong>contribution <strong>of</strong> triplets that involve highly connected nodes.Again, calculating <strong>the</strong>se clustering metrics is very easy in NetworkX:Code 17.11:>>> import networkx as nx>>> g = nx.karate_club_graph()>>> nx.clustering(g){0: 0.15, 1: 0.3333333333333333, 2: 0.24444444444444444, 3:0.6666666666666666, 4: 0.6666666666666666, 5: 0.5, 6: 0.5, 7: 1.0,8: 0.5, 9: 0.0, 10: 0.6666666666666666, 11: 0.0, 12: 1.0, 13: 0.6,14: 1.0, 15: 1.0, 16: 1.0, 17: 1.0, 18: 1.0, 19: 0.3333333333333333,20: 1.0, 21: 1.0, 22: 1.0, 23: 0.4, 24: 0.3333333333333333, 25:0.3333333333333333, 26: 1.0, 27: 0.16666666666666666, 28:0.3333333333333333, 29: 0.6666666666666666, 30: 0.5, 31: 0.2, 32:0.19696969696969696, 33: 0.11029411764705882}>>> nx.average_clustering(g)0.5706384782076823>>> nx.transitivity(g)0.2556818181818182Exercise 17.9 Generate (1) an Erdős-Rényi r<strong>and</strong>om network, (2) a Watts-Strogatz small-world network, <strong>and</strong> (3) a Barabási-Albert scale-free network <strong>of</strong> comparablesize <strong>and</strong> density, <strong>and</strong> compare <strong>the</strong>m with regard <strong>to</strong> how locally clustered<strong>the</strong>y are.The clustering coefficient was first introduced by Watts <strong>and</strong> Strogatz [56], where <strong>the</strong>yshowed that <strong>the</strong>ir small-world networks tend <strong>to</strong> have very high clustering compared <strong>to</strong><strong>the</strong>ir r<strong>and</strong>om counterparts. The following code replicates <strong>the</strong>ir computational experiment,varying <strong>the</strong> rewiring probability p:Code 17.12: small-world-experiment.py

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!