bgneal@36: """Chapter 5.5, exercise 6 in Allen Downey's Think Complexity book. bgneal@36: bgneal@36: 3. Use the BA model to generate a graph with about 1000 vertices and compute the bgneal@36: characteristic length and clustering coefficient as defined in the Watts and bgneal@36: Strogatz paper. Do scale-free networks have the characteristics of bgneal@36: a small-world graph? bgneal@36: bgneal@36: """ bgneal@36: bgneal@36: from ch5ex6 import BAGraph bgneal@36: bgneal@36: g = BAGraph(5, 5) bgneal@36: bgneal@36: for i in xrange(1000): bgneal@36: g.step() bgneal@36: bgneal@36: g.set_edge_length(1) bgneal@36: print "Clustering coefficient:", g.clustering_coefficient() bgneal@36: print "Characteristic length:", g.big_l3()