Mercurial > public > think_complexity
comparison ch5ex6-3.py @ 36:305cc03c2750
Chapter 5.5, exercise 6, #3: compute WS clustering coefficient
and characteristic length on a BA model graph.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Thu, 10 Jan 2013 19:24:02 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
35:10db8c3a6b83 | 36:305cc03c2750 |
---|---|
1 """Chapter 5.5, exercise 6 in Allen Downey's Think Complexity book. | |
2 | |
3 3. Use the BA model to generate a graph with about 1000 vertices and compute the | |
4 characteristic length and clustering coefficient as defined in the Watts and | |
5 Strogatz paper. Do scale-free networks have the characteristics of | |
6 a small-world graph? | |
7 | |
8 """ | |
9 | |
10 from ch5ex6 import BAGraph | |
11 | |
12 g = BAGraph(5, 5) | |
13 | |
14 for i in xrange(1000): | |
15 g.step() | |
16 | |
17 g.set_edge_length(1) | |
18 print "Clustering coefficient:", g.clustering_coefficient() | |
19 print "Characteristic length:", g.big_l3() |