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.

318 CHAPTER 15. BASICS OF NETWORKSJillJessJeffJoshJaneJohnJackFigure 15.8: Visual output <strong>of</strong> Code 15.14 with a corrected CSV data file.If you want <strong>to</strong> import <strong>the</strong> data as a directed graph, you can use <strong>the</strong> create_usingoption in <strong>the</strong> read_adjlist comm<strong>and</strong>, as follows:Code 15.16: read-adjlist-directed.pyfrom pylab import *import networkx as nxg = nx.read_adjlist(’myNetworkData.csv’, delimiter = ’,’,create_using = nx.DiGraph())nx.draw(g, with_labels = True)show()The result is shown in Fig. 15.9, in which arrowheads are indicated by thick line segments.Ano<strong>the</strong>r simple function for data importing is read_edgelist. This function reads anedge list, i.e., a list <strong>of</strong> pairs <strong>of</strong> nodes, formatted as follows:Code 15.17:John JaneJohn JackJess JoshJess JillJack Jane

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

Saved successfully!

Ooh no, something went wrong!