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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

16.3. SIMULATING DYNAMICS OF NETWORKS 357With this preferential node selection function, <strong>the</strong> completed simulation code looks likethis:Code 16.12: barabasi-albert.pyimport matplotlibmatplotlib.use(’TkAgg’)from pylab import *import networkx as nxm0 = 5 # number <strong>of</strong> nodes in initial conditionm = 2 # number <strong>of</strong> edges per new nodedef initialize():global gg = nx.complete_graph(m0)g.pos = nx.spring_layout(g)g.count = 0def observe():global gcla()nx.draw(g, pos = g.pos)def pref_select(nds):global gr = uniform(0, sum(g.degree(i) for i in nds))x = 0for i in nds:x += g.degree(i)if r

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

Saved successfully!

Ooh no, something went wrong!