NetworkX

3.6.1 · active · verified Sat Mar 28

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

Install

Imports

Quickstart

A simple example to create a graph, add nodes and edges, and visualize it using matplotlib.

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()

view raw JSON →