view ch5ex6-3.py @ 42:039249efe42f

Chapter 6, exercise 2, #4. Wrote a program to output the center column of a rule 30 CA as a stream of bytes. It is very slow though. It has to run a very long time to produce enough data for dieharder. Committing it now but will have to let it run overnight or something to generate a large file.
author Brian Neal <bgneal@gmail.com>
date Sun, 13 Jan 2013 16:24:00 -0600
parents 305cc03c2750
children
line wrap: on
line source
"""Chapter 5.5, exercise 6 in Allen Downey's Think Complexity book.

3. Use the BA model to generate a graph with about 1000 vertices and compute the
   characteristic length and clustering coefficient as defined in the Watts and
   Strogatz paper. Do scale-free networks have the characteristics of
   a small-world graph?

"""

from ch5ex6 import BAGraph

g = BAGraph(5, 5)

for i in xrange(1000):
    g.step()

g.set_edge_length(1)
print "Clustering coefficient:", g.clustering_coefficient()
print "Characteristic length:", g.big_l3()