A brief tutorial of NetworkX

Made for the network science course @ DCC/FCUP

Importing the library into Python

After starting Python, import the networkx module with (the recommended way):

Creating a graph

Here is a simple initial example:

Graphs can be of different types:

Nodes and edges can have attributes:

NetworkX graph objects can be created in one of three ways:

Manipulating a graph

Graphs are essentially a "dictionary of dictionaries"

We can also use graph operations to obtain new graphs:

Graph Analysis

There are many algorithms you can choose to analyzing a graph (see Algorithms):