vik-y
1/31/2016 - 7:27 PM

Getting started with python networkx

Getting started with python networkx

These are some resources collected/generated by me while beginning with networkx 

Install using: 
sudo pip install networkx  

Examples given here
https://networkx.github.io/examples.html
>>> import networkx as nx
>>> G=nx.Graph()
>>> G.add_node("spam")
>>> G.add_edge(1,2)
>>> print(G.nodes())
[1, 2, 'spam']
>>> print(G.edges())
[(1, 2)]

Example works properly but it doesn't draw the graph. Turns out to draw the graph we have to download matplotlib
Install using:
sudo pip install matplotlib

After that this worked: 
>>> import matplotlib.pyplot as plt



Dependency summary
-------
sudo pip install networkx
sudo pip install matplotlib