networkx
Python library for creating, manipulating, and analyzing complex networks and graphs.
Repository Health
Technical Analysis
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 12 apps in this directory
Elementary
Data Engineering · Monitoring · Analytics
The dbt-native data observability CLI that turns your existing dbt tests and metadata into anomaly detection, lineage graphs, and Slack/Teams alerts — no separate platform required.
Flowsint
Automation · Developer Tools
A privacy-first, graph-based OSINT investigation platform with 30+ automated enrichers for mapping relationships between domains, IPs, people, and organizations.
Graphify
AI Agents
A YC-backed, open-source knowledge graph skill for AI coding assistants — type /graphify and it maps your entire project (code, docs, PDFs, images, videos) into a queryable graph instead of grepping through files.
Helicone
Monitoring · AI Development · Analytics
An open-source AI gateway and LLM observability platform that routes requests to 100+ models while logging cost, latency, and full traces for every call.
knowhere
AI Development · Developer Tools
Transform messy, unstructured documents into persistent, navigable memory that AI agents can actually use.
Langflow
AI Agents · AI Development
Build, test, and deploy AI agents and RAG workflows visually with native API and MCP server export.
marimo
Developer Tools · Data Engineering
A reactive Python notebook that eliminates hidden state, runs reproducibly, and deploys as a web app or script — stored as pure Python, built for the AI era.
Memgraph
Databases · AI Development
High-performance in-memory graph database for AI context and real-time analytics
Rasa Open Source
AI Assistants · AI Development
Rasa Open Source is a Python machine learning framework for building contextual, multi-turn chatbots and voice assistants that understand natural language and maintain conversation state.