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.
pip install networkxVerified import paths — ran on the pinned version, not inferred.
A simple example to create a graph, add nodes and edges, and visualize it using matplotlib.
Remove the import statement 'from networkx import release' from your code.
Replace 'networkx.add_path(G, [0, 1, 2, 3])' with 'G.add_path([0, 1, 2, 3])'.
Install optional dependencies using 'pip install networkx[default]'.
Run `pip install networkx` in your terminal or command prompt. If using Anaconda, use `conda install networkx` instead.
Access graph properties directly (e.g., `G.number_of_nodes()`, `G.number_of_edges()`) or print the graph object `print(G)` for a basic summary. If a detailed summary is needed for compatibility with older code, consider `nx.graph_info(G)` if available, or update the code to use newer API features.
Upgrade NetworkX to version 2.0 or newer by running `pip install --upgrade networkx` in your terminal or command prompt.
Ensure the input to `add_edges_from` is a list or iterable of tuples, where each tuple strictly contains two (source, target) or three elements (source, target, edge_attributes), e.g., `G.add_edges_from([(1, 2), (2, 3, {'weight': 0.5})])`.Exit the Python interpreter (by typing `exit()` and pressing Enter) and then run `pip install networkx` directly in your operating system's command prompt (Windows) or terminal (macOS/Linux).