Skip to main content

Fast network analysis library with Rust acceleration

Project description

NetSmith: Fast Network Analysis Library

NetSmith is a high-performance network analysis library with Rust acceleration, focused on pure network analysis without time series dependencies.

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, assortativity, clustering, k-core, components
  • paths.py: Shortest paths, reachability, walk metrics
  • community.py: Modularity, Louvain hooks, label propagation hooks
  • 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[networkx]   # For community detection, null models, k-core decomposition
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: Core functionality (degree, paths, components, clustering) works with just numpy. scipy is only needed for sparse matrix formats, and networkx is only needed for advanced community detection and null models.

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
  • Full metric implementations
  • Community detection algorithms
  • 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

netsmith-0.2.1.tar.gz (34.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

netsmith-0.2.1-cp313-cp313-win_amd64.whl (197.3 kB view details)

Uploaded CPython 3.13Windows x86-64

netsmith-0.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (298.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

netsmith-0.2.1-cp313-cp313-macosx_11_0_arm64.whl (266.7 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

netsmith-0.2.1-cp312-cp312-win_amd64.whl (197.3 kB view details)

Uploaded CPython 3.12Windows x86-64

netsmith-0.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (298.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

netsmith-0.2.1-cp312-cp312-macosx_11_0_arm64.whl (266.7 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

Details for the file netsmith-0.2.1.tar.gz.

File metadata

  • Download URL: netsmith-0.2.1.tar.gz
  • Upload date:
  • Size: 34.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for netsmith-0.2.1.tar.gz
Algorithm Hash digest
SHA256 815779e5d14434bc4214a0b5a962b97e93c77b67ed721a52293ebbf1800cf3a7
MD5 885497792944d5243406742a8269e4c6
BLAKE2b-256 6d47c89146f4365db922fc208e37948e9f2ba5e37521a7eb73dc4469e72a0230

See more details on using hashes here.

Provenance

The following attestation bundles were made for netsmith-0.2.1.tar.gz:

Publisher: release.yml on kylejones200/netsmith

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file netsmith-0.2.1-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: netsmith-0.2.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 197.3 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for netsmith-0.2.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 4abc6809a19a19ec4e45783c5139a09e0e880f7726cd68e84b2342a4869fa783
MD5 635ff1fc50d8eb85461e7d28b476de63
BLAKE2b-256 1385b7e6a8571f678c036fbc87fe6877142a7195c3d7138550eb3de8d98e6367

See more details on using hashes here.

Provenance

The following attestation bundles were made for netsmith-0.2.1-cp313-cp313-win_amd64.whl:

Publisher: release.yml on kylejones200/netsmith

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file netsmith-0.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for netsmith-0.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9230ed8270fd84cbb138ae9abd12c887143695f802381dd0c658f975d8071b35
MD5 ec6b010a9065c71e58a54b21a5cd4f52
BLAKE2b-256 084c9442b1fc3b6b14c68ea1c06ce447d0018a48616e67f2efb601551a31cbaa

See more details on using hashes here.

Provenance

The following attestation bundles were made for netsmith-0.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on kylejones200/netsmith

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file netsmith-0.2.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for netsmith-0.2.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2813b7ee1233839cb60055a2e34f4ac455562a2b69715e3e235565b86b7e0dca
MD5 b2060ade6ad716566983b9b3e091e63c
BLAKE2b-256 faf4811d04bf83d22fbf211140bc2643f7c0659f4236be13f83bc798f5532024

See more details on using hashes here.

Provenance

The following attestation bundles were made for netsmith-0.2.1-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release.yml on kylejones200/netsmith

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file netsmith-0.2.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: netsmith-0.2.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 197.3 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for netsmith-0.2.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b21ccdfc98eaa7c211e7d03d6a0535d4d14853c960137fdafb329beda6d855f3
MD5 919acef1ec86a2b50b90b8835a5c3862
BLAKE2b-256 e8ab99f595fc4a8be3aca4d62c1c13f08b1e338d4fbe2bcd662f7fb81c646c6f

See more details on using hashes here.

Provenance

The following attestation bundles were made for netsmith-0.2.1-cp312-cp312-win_amd64.whl:

Publisher: release.yml on kylejones200/netsmith

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file netsmith-0.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for netsmith-0.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7c34e8d379f4e14de5549fe5a4f57330c71d552a017b98b0c5a07b9c22dbaf50
MD5 9bea69d412bfadc1a672cc84b3a6defc
BLAKE2b-256 3ab9720dec5349eeac23f8880836ba2acf6aac7fd6e2dbc09031e74e8044d734

See more details on using hashes here.

Provenance

The following attestation bundles were made for netsmith-0.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on kylejones200/netsmith

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file netsmith-0.2.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for netsmith-0.2.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0b25aa2183f9f8993e776c3ad56fc9f2f7b19b5b2a210d751215e70b950d632b
MD5 01ff5cf9085e7d58e5b2a0654236a2bd
BLAKE2b-256 a70050d3ff46a65fb4f14dbfc9c62d889747a9033a4340d703ba9b4584131598

See more details on using hashes here.

Provenance

The following attestation bundles were made for netsmith-0.2.1-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on kylejones200/netsmith

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page