A Quick Introduction to NetworkX
Putra Manggala
Montreal-Python 26
December 19, 2011
NETWORKX.
A Python package to analyze networks and graphs.
Many algorithms implemented (Combinatorics, Network
analysis, Network flows, etc).
Easy visualization via Matplotlib.
NETWORKS/GRAPHS.
Networks/Graphs consist of:
Vertices/Nodes: Singletons in your model.
Edges: Connections between the vertices.
GRAPH EXAMPLE 1.
A toy graph with 5 nodes.
GRAPH EXAMPLE 2.
All the graphs with 6 nodes or less. 1
1
http://networkx.lanl.gov/examples/drawing/atlas.html
GRAPH EXAMPLE 3.
A network of books about US politics published around the
time of the 2004 presidential election and sold by the online
bookseller Amazon.com. 2
Edges between books represent frequent copurchasing of books
by the same buyers.
2
http://www-personal.umich.edu/ mejn/netdata/
GRAPH EXAMPLE 3.
Nodes.
GRAPH EXAMPLE 3.
Edges.
GRAPH EXAMPLE 3.
Visualization of the dataset.
GRAPH EXAMPLE 3 - CLIQUE ANALYSIS.
Clique analysis. 3
3
A clique is a set of nodes in which every node is connected to every other
node.
GRAPH EXAMPLE 3 - CLIQUE ANALYSIS.
Clique analysis. 3
Some simple statistics on the cliques:
3
A clique is a set of nodes in which every node is connected to every other
node.
GRAPH EXAMPLE 3 - CLIQUE ANALYSIS.
Some intuition for the cliques: They are the set of books that are
often bought together by the same buyer (at any one time!)
GRAPH EXAMPLE 3 - CLIQUE ANALYSIS.
Some intuition for the cliques: They are the set of books that are
often bought together by the same buyer (at any one time!)
GRAPH EXAMPLE 3 - CLIQUE ANALYSIS.
Visualization of the ones often bought in bulk.
GRAPH EXAMPLE 3 - CLIQUE ANALYSIS.
Visualization of the ones often bought in bulk.
REFERENCES
https://github.com/drewconway/NetworkX_
Intro_Materials.
http://networkx.lanl.gov/
http:
//github.com/pmangg/NetworkX_MontrealPython
Networks, Crowds, and Markets: Reasoning About a
Highly Connected World (Easley and Kleinberg 2010).

Mp26 : A Quick Introduction to NetworkX