Network Analysis with Python


>>> g = nx.read_(‘path/to/file.txt’,...options...)



Yüklə 1,5 Mb.
Pdf görüntüsü
səhifə6/12
tarix22.03.2023
ölçüsü1,5 Mb.
#89129
1   2   3   4   5   6   7   8   9   ...   12
l109-tutorial 2015

>>> g = nx.read_(‘path/to/file.txt’,...options...)
>>> nx.write_(g,‘path/to/file.txt’,...options...)
>>> g = nx.read_edgelist(path, comments='#', create_using=None, 
delimiter=' ', nodetype=None, data=True, edgetype=None, 
encoding='utf-8')
>>> nx.write_edgelist(g, path, comments='#', delimiter=' ', 
data=True, encoding='utf-8')
24


Getting started: drawing graphs
• NetworkX is not primarily a graph drawing package but it provides basic drawing 
capabilities by using matplotlib. For more complex visualization techniques it 
provides an interface to use the open source GraphViz software package.
>>> import pylab as plt #import Matplotlib plotting interface
>>> g = nx.watts_strogatz_graph(100, 8, 0.1)
>>> nx.draw(g)
>>> nx.draw_random(g)
>>> nx.draw_circular(g)
>>> nx.draw_spectral(g)
>>> plt.savefig('graph.png')
25



Basic analysis: the Cambridge place network
27
A directed network with integer 
ids as nodes
Two places (nodes) are 
connected if a user transition has 
been observed between them
Visualization thanks to Java unfolding:
http://processing.org/
http://unfoldingmaps.org/


Basic analysis: graph properties
• Find the number of nodes and edges, the average degree and the number of 
connected components
cam_net = nx.read_edgelist('cambridge_net.txt', 
create_using=nx.DiGraph(), nodetype=int)

Yüklə 1,5 Mb.

Dostları ilə paylaş:
1   2   3   4   5   6   7   8   9   ...   12




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin