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.1.1.tar.gz (11.8 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.1.1-cp313-cp313-win_amd64.whl (155.9 kB view details)

Uploaded CPython 3.13Windows x86-64

netsmith-0.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (260.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

netsmith-0.1.1-cp313-cp313-macosx_11_0_arm64.whl (225.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

netsmith-0.1.1-cp312-cp312-win_amd64.whl (155.9 kB view details)

Uploaded CPython 3.12Windows x86-64

netsmith-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (260.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

netsmith-0.1.1-cp312-cp312-macosx_11_0_arm64.whl (225.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for netsmith-0.1.1.tar.gz
Algorithm Hash digest
SHA256 06d984346b677277e09d9981b35c302a51794c21eb9305f11d3bd819c651d1fd
MD5 8d01f8fab390f428a278509f714e7a71
BLAKE2b-256 8f57041de5ca3c1e66578d9a4576935eb20271a9d987c623d6a73ac45582bf1e

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for netsmith-0.1.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 55eb7467ebe81697a3a858aeaf7958eedf28fa9aa0f76515826a596f1265f620
MD5 b01c9b28adf46f5ca731738eee7ca798
BLAKE2b-256 f03256283d39afa9bd8dddb33f138036652c3fc7a3fd0f5a2fdac047dd28c635

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for netsmith-0.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ef67fc6ac4bc6c3ddf84595b9394da5527f4223ed3af06460a90ff4e1bf6a6cb
MD5 25741ca35d5c0d900a0d214ceffb58e4
BLAKE2b-256 145c4ea63b1d52c9720e6efea1d89229cc2fa70db275c82b385084ef644014ba

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for netsmith-0.1.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 abec15a16bae8fad0b9b51ea2fee665e3878676433cd6ad22b68d9c6c738c456
MD5 a7736d81b11931cacfbddd358e58f23e
BLAKE2b-256 1b54679ff30c6e3fc854c16983b250655b4b995f9f865fad6c9faeefb20dbac6

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for netsmith-0.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4f993d2c5e60d8d6fb0dfe40068c275a8d8202290f47cec437d1b857adfeb5d9
MD5 d318ff1dbf00cd16e2fe59528f092b61
BLAKE2b-256 4c265cfc9e476bd85aa173159b3e60b1c3b9d5aa2d8c48e4b804b9eac3360746

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for netsmith-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0a26f0a08bcc89ddae4e18b1de466b7920291ecdc2f647902cf1bfca0175fead
MD5 9694c4031973f5d31f7e604980905578
BLAKE2b-256 ab5bf567fb27e6bbe96c3f200543fdb19538f27b2421a2f90aed8b7976adeb8d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for netsmith-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 580b6bc172eb3efbef3428ce565a9f6c0e2b8e843230b8c2bdd2ea381dccb8ac
MD5 c30e7bd880413087314c991d99af8864
BLAKE2b-256 32c27ad25a249e2b233df9b43a5bfe795a00d0da99faeac566f0a7e16d5ebc53

See more details on using hashes here.

Provenance

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