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.

15.4. VISUALIZING NETWORKS WITH NETWORKX 311Figure 15.3: Visual output <strong>of</strong> Code 15.11. Zachary’s Karate Club graph is visualized.Your result may not look like this because <strong>the</strong> spring layout algorithm uses r<strong>and</strong>ominitial positions by default.There are several o<strong>the</strong>r layout algorithms, as shown in Code 15.12 <strong>and</strong> Fig. 15.4. Also,<strong>the</strong>re are many options you can use <strong>to</strong> cus<strong>to</strong>mize visualization results (see Code 15.13<strong>and</strong> Fig. 15.5 ). Check out NetworkX’s online documentation <strong>to</strong> learn more about whatyou can do.Code 15.12: network-layouts.pyfrom pylab import *import networkx as nxg = nx.karate_club_graph()subplot(2, 2, 1)nx.draw_r<strong>and</strong>om(g)title(’r<strong>and</strong>om layout’)subplot(2, 2, 2)nx.draw_circular(g)title(’circular layout’)

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

Saved successfully!

Ooh no, something went wrong!