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.2.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.2-cp313-cp313-win_amd64.whl (197.3 kB view details)

Uploaded CPython 3.13Windows x86-64

netsmith-0.2.2-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.2-cp313-cp313-macosx_11_0_arm64.whl (266.8 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

netsmith-0.2.2-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.2-cp312-cp312-macosx_11_0_arm64.whl (266.8 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: netsmith-0.2.2.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.2.tar.gz
Algorithm Hash digest
SHA256 7759979aa23ef52cccd62af9b5413add76ee82867d238675aa5db6b89d9bf248
MD5 dd4de80531223d6eadedc134001a1c9d
BLAKE2b-256 caaf68a38e2b3fc357fb1f3bf831cf3b831239946bdbff4cdc73b65e9f3a1855

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: netsmith-0.2.2-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.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 28f0a25f7523407d69c2cd840aaf29c787f6094c0ec9527571e885cb5e8b1fb4
MD5 ab6ebe58c60161bbd2e2658e70deb13f
BLAKE2b-256 0471dda89d91894cf74fc1befc72eb6203f38da327bfeb34bad89ccdfcadef5e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for netsmith-0.2.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 46ac4dabc5103693d797d0b104f6fc316c37442d285f8a2a8f96b412bf8f29bb
MD5 63ba3f372f0f9745fd6a0be843b092e6
BLAKE2b-256 4ac23314a5c8c9120e0af3e9fc92e4a1240119f75ccf9ea24a467820449789aa

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for netsmith-0.2.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0f225ace5853649c733583753c4a38048cbb31d71258825c249824d8e75b7441
MD5 297d7f5291575397178c448937d63f5c
BLAKE2b-256 dbc6c83cb4f85920ae78812d381f972d6f5584555f0b36c127c6bc4bcc6ab44e

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: netsmith-0.2.2-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.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 42dcbb4af3b747efc5e9b2f6ec0d18f5ccf743b943b97d728e0ec70a9c98c5e4
MD5 6a124edeca34a3a1964194b8ea26e197
BLAKE2b-256 715c6881513c04a726cf95ad810f69a868b7472a70b447dbee6c1219a7d3b678

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for netsmith-0.2.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1430cd517d345ea1221a092953b158c8948a4785cbd90120b20732a4da80aeb4
MD5 28e077a37d00e2610152717076753223
BLAKE2b-256 5c95531c54d2a31de1e82b18b496e3b1a0ebedd0f040d5dde13555c1accc0f9f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for netsmith-0.2.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 29ab8d1280b404d49e2b2a2439189ac021b943ccb49ce5859ce043612b27d523
MD5 784603ae7b6eda895c9958e2277e4842
BLAKE2b-256 e82e78c1de52f15c3fb18cbc8b06b6a175fe2a130e50d7f655ec6407a641c37e

See more details on using hashes here.

Provenance

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