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.

314 CHAPTER 15. BASICS OF NETWORKSnode_color = [’yellow’ if i < 17 else ’green’ for i in g.nodes()])title(’coloring nodes <strong>and</strong> edges’)subplot(3, 2, 5)nx.draw_networkx_nodes(g, positions)title(’nodes only’)subplot(3, 2, 6)nx.draw_networkx_edges(g, positions)title(’edges only’)show()Exercise 15.10 Visualize <strong>the</strong> following graphs. Look <strong>the</strong>m up in NetworkX’s onlinedocumentation <strong>to</strong> learn how <strong>to</strong> generate <strong>the</strong>m.• A “hypercube graph” <strong>of</strong> four dimensions.• A “ladder graph” <strong>of</strong> length 5.• A “barbell graph” made <strong>of</strong> two 20-node complete graphs that are connectedby a single edge.• A “wheel graph” made <strong>of</strong> 100 nodes.Exercise 15.11 Visualize <strong>the</strong> social network you created in Exercise 15.7. Tryseveral options <strong>to</strong> cus<strong>to</strong>mize <strong>the</strong> result <strong>to</strong> your preference.15.5 Importing/Exporting Network DataIn most network studies, researchers need <strong>to</strong> model <strong>and</strong> analyze networks that exist in<strong>the</strong> real world. To do so, we need <strong>to</strong> learn how <strong>to</strong> import (<strong>and</strong> export) network data fromoutside Python/NetworkX. Fortunately, NetworkX can read <strong>and</strong> write network data from/<strong>to</strong>files in a number <strong>of</strong> formats 2 .html.2 For more details, see https://networkx.github.io/documentation/latest/reference/readwrite.

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

Saved successfully!

Ooh no, something went wrong!