NetworkX
NetworkX is a Python package for creating and manipulating graphs and networks. The current version is 3.6.1, released on 2025-12-15, with a release cadence of approximately every 6 months.
Warnings
- breaking The 'release' module has been removed in NetworkX 3.0. Direct import of 'release' will result in an ImportError.
- deprecated The 'add_path' function is now a method of the Graph class and should be called on a Graph instance.
- gotcha Ensure that all optional dependencies (numpy, scipy, matplotlib, pandas) are installed for full functionality, especially for graph visualization and advanced computations.
Install
-
pip install networkx
Imports
- Graph
from networkx import Graph
- add_path
G.add_path([0, 1, 2, 3])
Quickstart
import networkx as nx # Create an empty graph G = nx.Graph() # Add nodes and edges G.add_nodes_from([1, 2, 3]) G.add_edges_from([(1, 2), (2, 3)]) # Draw the graph import matplotlib.pyplot as plt nx.draw(G, with_labels=True) plt.show()