Skip to main content

NetSmith: Fast Network Analysis Library

NetSmith computes the standard network measures — community detection, centrality, shortest paths, clustering, k-core and null models — on graphs large enough that the usual Python tools become the bottleneck. The algorithms are Rust kernels that release the GIL and parallelize across cores; every one has a pure-Python fallback, so the library works whether or not the compiled extension is present.

It needs only NumPy. NetworkX is optional, and only for converting a graph to one (Graph.as_networkx()) — no computation reaches for it.

import netsmith
from netsmith.core.graph import Graph
from netsmith.core.community import louvain_hooks
from netsmith.api import betweenness

graph = Graph(edges=[(0, 1), (1, 2), (0, 2), (3, 4), (4, 5), (3, 5), (2, 3)], n_nodes=6)

louvain_hooks(graph, seed=42)["n_communities"]   # 2
betweenness(graph)                               # brokerage per node

Measured against NetworkX on this machine: betweenness on 5,000 nodes takes 0.34s against 29.7s (87x), and five degree-preserving null models of a 25,000-edge graph take 0.11s against 9.4s (86x).

Architecture

NetSmith follows a four-layer architecture:

Layer 1: Core

Pure math, no I/O, no global state. Located in src/netsmith/core/:

  • graph.py: Core graph types (Graph, GraphView)
  • metrics.py: Degree, centrality (degree, betweenness), assortativity, clustering, k-core, components
  • paths.py: Shortest paths, reachability, walk metrics
  • community.py: Modularity, Louvain and label propagation (all built-in kernels)
  • nulls.py: Null models and permutation tests
  • stats.py: Distributions, confidence intervals, bootstrap

Layer 2: Engine

Performance and execution. Located in src/netsmith/engine/:

  • python/: Reference Python implementations
  • rust/: Rust-accelerated kernels (to be implemented)
  • dispatch.py: Backend selection (auto, python, rust)
  • contracts.py: Data contracts (EdgeList, GraphData)

Layer 3: API

Public surface. Located in src/netsmith/api/:

  • load.py: Load edges from pandas, polars, parquet, csv
  • graph.py: Public Graph API
  • compute.py: Stable compute functions (degree, pagerank, communities)
  • validate.py: Input validation

Layer 4: Apps

Opinionated use cases. Located in src/netsmith/apps/:

  • cli/: Command-line interface
  • reports/: HTML/markdown report generation
  • datasets/: Sample graphs and download helpers

Data Contracts

Canonical edge representation:

EdgeList(
    u: NDArray[np.int64],      # Source nodes (length m)
    v: NDArray[np.int64],      # Destination nodes (length m)
    w: Optional[NDArray[np.float64]],  # Edge weights (optional)
    directed: bool,
    n_nodes: Optional[int]     # Preferred but inferred if not provided
)

Usage Examples

Basic Usage

import netsmith
import numpy as np

# Create edge list
u = np.array([0, 1, 2], dtype=np.int64)
v = np.array([1, 2, 0], dtype=np.int64)
edges = netsmith.api.load.EdgeList(u=u, v=v, directed=False, n_nodes=3)

# Compute degree
degrees = netsmith.degree(edges, backend="auto")
print(degrees)  # [2, 2, 2]

# Compute PageRank
pr = netsmith.pagerank(edges, alpha=0.85, backend="auto")
print(pr)

# Compute communities
communities = netsmith.communities(edges, method="louvain", backend="auto")
print(communities)

Loading from Files

# Load from parquet
edges = netsmith.load_edges("edges.parquet", u_col="source", v_col="target")

# Load from CSV
edges = netsmith.load_edges("edges.csv", u_col="u", v_col="v", w_col="weight")

CLI Usage

# Compute degree
netsmith compute degree --input edges.parquet --out degree.parquet

# Compute PageRank
netsmith compute pagerank --input edges.parquet --out pr.parquet --alpha 0.85

# Compute communities
netsmith compute communities --input edges.parquet --out communities.parquet

Installation

Minimal installation (numpy only - ~10MB):

pip install netsmith

With optional dependencies:

pip install netsmith[scipy]      # For sparse matrices (adjacency_matrix format='sparse'/'coo')
pip install netsmith[cli]        # For the `netsmith` command-line tool
pip install netsmith[networkx]   # Interop only: Graph.as_networkx()
pip install netsmith[pandas]     # For pandas data loading
pip install netsmith[polars]     # For polars data loading

# Or install all optional dependencies:
pip install netsmith[scipy,networkx,pandas,polars]

# Development
pip install netsmith[dev]

Note: Every algorithm works with just numpy — community detection, k-core, null models, centrality and paths included. scipy is only needed for sparse matrix formats, and networkx only for Graph.as_networkx() interop; no computation reaches for it.

Rust Backend

The Rust backend will be automatically used if available. To build:

# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Build and install
maturin develop --release

Status

✅ Completed:

  • Core layer structure (graph types, metrics, paths, community, nulls, stats)
  • Engine layer structure (Python backend, dispatch system, contracts)
  • API layer (load, graph, compute, validate)
  • Apps layer (CLI skeleton)
  • pyproject.toml configuration

🚧 In Progress:

  • Rust backend implementation (degree, clustering, paths, components, Louvain done)
  • Full metric implementations
  • Test suite

📋 Planned:

  • Rust acceleration for Phase 1 kernels (degree, strength, components, BFS, k-core)
  • Comprehensive test coverage
  • Documentation
  • Performance benchmarks

Design Philosophy

NetSmith focuses on pure network analysis. For time series to network conversion, use downstream libraries that build on NetSmith.

License

MIT

Metadata

Release files for netsmith 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for netsmith 0.3.0
File Size Uploaded Provenance Actions
netsmith-0.3.0.tar.gz 73.3 kB With provenance Details for netsmith-0.3.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for netsmith 0.3.0
File Actions
netsmith-0.3.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for netsmith-0.3.0-cp313-cp313-win_amd64.whl
netsmith-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64 Details for netsmith-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
netsmith-0.3.0-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for netsmith-0.3.0-cp313-cp313-macosx_11_0_arm64.whl
netsmith-0.3.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for netsmith-0.3.0-cp312-cp312-win_amd64.whl
netsmith-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details for netsmith-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
netsmith-0.3.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for netsmith-0.3.0-cp312-cp312-macosx_11_0_arm64.whl

Total release size: 2.2 MB

Release files / netsmith-0.3.0.tar.gz

Download URL netsmith-0.3.0.tar.gz
Size 73.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e661e8dad26fe6adc726110ecb2ba903196f6611edb0400cf17f581079892462
BLAKE2b-256 checksum
How to use checksums
1a231ce1a4df584286901c71b1f6885fcd61b06696febf7ce86d5cecf740d931
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 6, 2026.

Transparency log

Release files / netsmith-0.3.0-cp313-cp313-win_amd64.whl

Download URL netsmith-0.3.0-cp313-cp313-win_amd64.whl
Size 307.7 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
990a7b4d645708759a520d3b97c5fb4d4728bb9273bf7f25bcffa9e21a79f31e
BLAKE2b-256 checksum
How to use checksums
487a4c4cb2b112f2e200ce695a04b0ef0e8fa85d159b664606fc03fe484a0bb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 6, 2026.

Transparency log

Release files / netsmith-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL netsmith-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 394.2 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
1953db67f5158ac5d2c88e28ecaa3c039040e613e9f310b7e618a255ee04393b
BLAKE2b-256 checksum
How to use checksums
3e2a030eac8c73ad6992c0e84f2df11235b25a39eaf198f8d0594ad482929334
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 6, 2026.

Transparency log

Release files / netsmith-0.3.0-cp313-cp313-macosx_11_0_arm64.whl

Download URL netsmith-0.3.0-cp313-cp313-macosx_11_0_arm64.whl
Size 355.7 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7c067a46d891d7b5beb7d1dd8125b98cd384f4168f38ff289c88e69fb114acb0
BLAKE2b-256 checksum
How to use checksums
acc83a8c38b36f7019a38b8aca7b92258aaeb777d699aad7e8229eecb77ae221
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 6, 2026.

Transparency log

Release files / netsmith-0.3.0-cp312-cp312-win_amd64.whl

Download URL netsmith-0.3.0-cp312-cp312-win_amd64.whl
Size 307.7 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
28d12725b08458e6c0dbdfda345802089c2a6473effe0547db76de3fb61e625c
BLAKE2b-256 checksum
How to use checksums
78454e6723a5238ed9c876192417ec84508a5f140009ab5b27d0e60d6d5c90ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 6, 2026.

Transparency log

Release files / netsmith-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL netsmith-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 394.2 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
3a171c686a7a36462311e239e14049445ffcdd6d4b99257f13293e3de6fccd86
BLAKE2b-256 checksum
How to use checksums
ed54459c32b8f22469b31ba85733ef121d88133807b5dd82ae8efa1940a2ce64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 6, 2026.

Transparency log

Release files / netsmith-0.3.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL netsmith-0.3.0-cp312-cp312-macosx_11_0_arm64.whl
Size 355.7 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9bcfd86389e8c10277c678f8cec55a99361b3aea58ecc1af3b640156e760d16c
BLAKE2b-256 checksum
How to use checksums
67ae70b1d37cca774b6ff9dcb9f1a69c29238f5d39dc28a18acd9b43bbeedfd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 6, 2026.

Transparency log

Security for netsmith 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 7 files in this release have been uploaded with provenance metadata.

Select from 7 files

Attestation for netsmith-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 6, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page