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.0.tar.gz (12.1 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.0-cp313-cp313-win_amd64.whl (161.2 kB view details)

Uploaded CPython 3.13Windows x86-64

netsmith-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (262.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

netsmith-0.2.0-cp313-cp313-macosx_11_0_arm64.whl (230.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

netsmith-0.2.0-cp312-cp312-win_amd64.whl (161.2 kB view details)

Uploaded CPython 3.12Windows x86-64

netsmith-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (262.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

netsmith-0.2.0-cp312-cp312-macosx_11_0_arm64.whl (230.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: netsmith-0.2.0.tar.gz
  • Upload date:
  • Size: 12.1 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.0.tar.gz
Algorithm Hash digest
SHA256 7ba51802c03dc5c677c231e45027b414b0355f3e8b2a640024d18a373c6febc5
MD5 f627964ca74ace15a17cef40472a7952
BLAKE2b-256 16632373671a7180ba5d3f45a7dcaa0ce59b1ed7504de552bdfe446d0243f944

See more details on using hashes here.

Provenance

The following attestation bundles were made for netsmith-0.2.0.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.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: netsmith-0.2.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 161.2 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.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 61ca1640f2ab1fb236ef93eafa47d25c0e5b81a77256bc5aec751f0a52a4ac6f
MD5 74a418a3cdaa93f018a2c8a70a564fdc
BLAKE2b-256 c5bb7bbc3c60ba795f9024e6e601695bca5eb282cec45b8a3b481a95f463f0f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for netsmith-0.2.0-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.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for netsmith-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 02c19335a90f73c4dc5081ae9544b36a0f974dacbc47c8abb58f2aada88694bf
MD5 c58fbb9d660829176018dc906944bf60
BLAKE2b-256 6c77da20194e72dbdaca94e5aa4827a5948467634677f78f81c843e79d3f5fc1

See more details on using hashes here.

Provenance

The following attestation bundles were made for netsmith-0.2.0-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.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for netsmith-0.2.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0ec1a6857a9e8837e7b0a28e425db048f71af98e7a67c72708ea6ff94012491f
MD5 5553fee83f15b809e0abb127d700e5b1
BLAKE2b-256 94133aa9b493d6e4c850c2b549ac3259c39253d384b388008a4aebe92ca4e428

See more details on using hashes here.

Provenance

The following attestation bundles were made for netsmith-0.2.0-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.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: netsmith-0.2.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 161.2 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.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 165b1fe716921e6b507c8805cb40b263c415f549b175d3088557eeedb221f6b7
MD5 51a6aaf9d816f507902d75d12acd2f92
BLAKE2b-256 1eadb754c9f71baa5917dc480d025a4ad6efe3e847003de9150b32db416fff82

See more details on using hashes here.

Provenance

The following attestation bundles were made for netsmith-0.2.0-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.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for netsmith-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b27244640008bf42a1b7b39a2fa535281e89d2d757b03cc9157ed316bac78874
MD5 e870ef7164b325323b87bd41afc62b0c
BLAKE2b-256 187e0a71c45ca363453e1501d9edf01309cfe1c162cc0665eb921434be5746bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for netsmith-0.2.0-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.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for netsmith-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7eb8c6d86ff114a3ed537b514765d35fbf9116f6d7e3b0694789393313368cc9
MD5 8a1382963d5d55b6341278a7a1368bce
BLAKE2b-256 ac02d3779446924699eebb1edd483125e9915b507d61ff6fd38fac8d3ec7baec

See more details on using hashes here.

Provenance

The following attestation bundles were made for netsmith-0.2.0-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