networkx

Python library for creating, manipulating, and analyzing complex networks and graphs.

Library
PyPI
v3.7
17,357 stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
92 /100 Excellent
Development Activity 96
Maintenance 84
Community 88
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
88 /100 Excellent
Architecture 88
Code Quality 90
Innovation 85
Learning Curve 88

NetworkX is a pure-Python library for creating, manipulating, and studying the structure, dynamics, and functions of graphs and complex networks. It ships Graph, DiGraph, MultiGraph, and MultiDiGraph classes that accept any hashable object as a node, plus over a hundred modules of built-in algorithms covering shortest paths, centrality, flow, community detection, isomorphism, and approximation.

Beyond the core data structures and algorithms, NetworkX interoperates with the wider scientific Python stack through conversions to and from NumPy arrays, SciPy sparse matrices, and pandas DataFrames, and it can read and write common graph formats like GEXF, GraphML, and JSON. A pluggable backend-dispatch system also lets GPU- or Rust-accelerated packages transparently replace its default pure-Python execution for the same function calls.

What You Get

  • Graph, DiGraph, MultiGraph, and MultiDiGraph classes with a consistent adjacency-view API and support for any hashable node type
  • 100+ modules of built-in graph algorithms spanning shortest paths, centrality, flow, community detection, isomorphism, coloring, and approximation
  • Read/write support for common graph file formats including GEXF, GraphML, JSON, and adjacency/edge lists
  • Direct conversion to and from NumPy arrays, SciPy sparse matrices, and pandas DataFrames
  • A pluggable backend-dispatch system (nx-cugraph, nx-parallel, graphblas-algorithms) for GPU- or Rust-accelerated execution without changing calling code

Common Use Cases

  • Analyzing social networks and community structure
  • Modeling and optimizing transportation, logistics, and infrastructure networks
  • Representing biological networks such as protein interactions or gene regulation for structural analysis
  • Teaching and prototyping graph theory and network science concepts

Under The Hood

Architecture

NetworkX centers its data model on the Graph/DiGraph/MultiGraph/MultiDiGraph classes in networkx/classes/, each built on adjacency dictionaries (_adj, _node) wrapped by cached-property “views” (AdjacencyView, NodeView, EdgeView, DegreeView in reportviews.py/coreviews.py) that provide read-only, memoized access invalidated by custom descriptor classes whenever the underlying dict is reassigned. Algorithms live in a large networkx/algorithms/ package (100+ modules and subpackages: centrality, community, connectivity, flow, isomorphism, shortest_paths, tree, approximation) that operate on the graph classes purely through their public view API, cleanly separating data structure from algorithm code. A notable architectural layer, networkx/utils/backends.py, implements a dispatch mechanism registered via a networkx.backends entry-point group that lets external packages (nx-cugraph, graphblas-algorithms, nx-parallel) transparently swap in GPU- or Rust-accelerated implementations for the same function signatures — this backend-dispatch layer is also the biggest surface of architectural risk, since changing the core view-API contracts would ripple into every registered backend.

Tech Stack

NetworkX is pure Python (100% of the codebase), targeting Python >=3.12 with a setuptools build backend and zero required runtime dependencies — optional extras add numpy, scipy, matplotlib, and pandas under a default extra for array conversion, sparse-matrix support, and plotting. There’s no server or ORM layer since it’s a standalone data-structure/algorithms library. Testing runs on pytest with pytest-cov and pytest-xdist plus doctest-modules integration; Ruff handles linting/formatting and mypy handles type-checking. The project dual-manages environments with plain pip/venv and Pixi, which defines per-Python-version test/lint/doc/benchmark environments. CI spans GitHub Actions (test, lint, mypy, benchmark workflows) and CircleCI for documentation builds, with releases packaged via build/twine.

Code Quality

Every algorithms subpackage carries a co-located tests/ directory, and pytest is configured with filterwarnings = ["error"], turning any unexpected warning into a test failure. Docstrings follow numpydoc conventions and are exercised directly as doctests, so documentation examples are continuously verified against the real API. Mypy runs project-wide in CI, though a couple of view modules are explicitly excluded from strict checking, reflecting some dynamic, metaprogramming-heavy code that resists static typing. Ruff enforces import sorting, comprehension style, and numpy-specific lint rules, and pre-commit hooks gate contributions. Overall this reads as a mature, well-tested, typed-where-practical codebase with strong CI enforcement.

API Design The public API centers on a small, consistent surface — Graph, DiGraph, and their multi-edge variants — with algorithms exposed as plain functions taking a graph as their first argument, keeping the learning curve shallow for anyone familiar with basic graph theory. Nodes and edges accept arbitrary hashable objects and attribute dictionaries without any schema, which lowers boilerplate for quick prototyping but pushes some type-safety responsibility onto the caller. Extensive numpydoc docstrings, doctest-verified examples, and a large example gallery make the API self-documenting, and the backend-dispatch design keeps the same function signatures usable whether the caller has installed acceleration packages or not.

Used by 14 apps in this directory

Python
64%
AGPL 3.0

Shadowbroker

Analytics · Monitoring · Security

11,358

Self-hosted OSINT dashboard that fuses 60+ live intelligence feeds — flight tracking, ship AIS, satellites, CCTV, seismic and radio networks — into one real-time map, with an agent-ready command channel for AI co-analysts.

View details
85
Repo Health
83
Technical
71
Dependency
Built with
Python 64%
TypeScript 32%
Updated 1 weeks ago
Python
94%
Apache 2.0

SWIRL

Data Engineering · Databases · Search

3,046

Federated AI search and RAG across 100+ enterprise sources—no data extraction, no vector database required.

View details
61
Repo Health
83
Technical
65
Dependency
Built with
Python 94%
Updated 1 weeks ago
Python
97%
MPL 2.0

Taiga Back

Developer Tools · Project Management

859

Self-hosted agile project management backend with Scrum, Kanban, issue tracking, and a full REST API — built on Django and PostgreSQL.

View details
72
Repo Health
74
Technical
64
Dependency
Built with
Python 97%
Updated 1 months ago
C
74%
AGPL 3.0

TDengine

Databases

25,168

A high-performance, open-source time-series database built in C for IoT, connected vehicles, and industrial monitoring workloads, with built-in stream processing, caching, and data subscription.

View details
97
Repo Health
71
Technical
65
Dependency
Built with
C 74%
C++ 19%
Updated 1 weeks ago
Python
50%
AGPL 3.0

VoiceStudio

Mcp · Music Audio · Voice AI

83,641

Open-source, fully local ElevenLabs alternative for voice cloning, voice design, video dubbing, dictation, transcription and audiobooks, with a local API and MCP server for agents.

View details
86
Repo Health
83
Technical
70
Dependency
Built with
Python 50%
JavaScript 22%
TypeScript 21%
Updated 6 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers