Skip to main content

Fast single-source shortest paths for grid and pipeline networks using BMSSP algorithm

Project description

BMSSP: Fast Single-Source Shortest Paths

Tests License: MIT Python 3.9+

A Python package providing fast single-source shortest path (SSSP) computation using the BMSSP algorithm, with a high-performance Rust backend.

Status

Beta (v0.1.0) - This package is ready for use. The API is stable, but we welcome feedback and contributions.

Features

  • Fast SSSP computation using BMSSP algorithm
  • Optimized for large sparse graphs (hundreds of thousands to millions of edges)
  • Support for dynamic weights and edge outages
  • Clean Python API with NumPy integration
  • Rust backend for maximum performance
  • Support for both f32 and f64 precision
  • Predecessor tracking for path reconstruction

Installation

Note: This package is not yet available on PyPI. For detailed installation instructions, see the Installation Guide.

Quick Installation

# Install Rust toolchain first
brew install rust  # or use rustup

# Clone repository and install
cd bmssp-py/python
maturin develop

Quick Start

import numpy as np
from bmssp import Graph, sssp

# Create a graph from edges
n = 4
edges = np.array([[0, 1], [1, 2], [0, 2], [2, 3]], dtype=np.int64)
weights = np.array([1.0, 2.0, 1.5, 1.0], dtype=np.float32)

graph, _ = Graph.from_edges(n, edges, weights=weights)

# Compute shortest paths from vertex 0
result = sssp(graph, weights, source=0)
print(result.dist)  # Distances from source to each vertex

# With path reconstruction
result = sssp(graph, weights, source=0, return_predecessors=True)
from bmssp import reconstruct_path
path = reconstruct_path(result.pred, target=3)
print(f"Path: {path}")

Performance Highlights

  • Optimized for large sparse graphs: Handles hundreds of thousands to millions of edges efficiently
  • Fast repeated computations: Ideal for scenario analysis with many SSSP calls
  • Dynamic weight updates: Update weights without rebuilding graph topology
  • Rust backend: High-performance implementation with minimal Python overhead

For detailed performance information, see the Performance Guide.

Example: Grid Network Optimization

See python/examples/grid_pipeline.py for a complete example demonstrating:

  • Building grid networks
  • Applying load flows and congestion models
  • Handling outages
  • Recomputing paths

Documentation

Development

For development setup, install the Rust toolchain and use maturin develop from the python/ directory.

Citation

If you use this implementation in your research, please cite the original paper:

Ran Duan, Jiayi Mao, Xiao Mao, Xinkai Shu, Longhui Yin. "Breaking the Sorting Barrier for Directed Single-Source Shortest Paths." arXiv preprint arXiv:2504.17033 (2025).
https://arxiv.org/abs/2504.17033

License

Licensed under the MIT License. See LICENSE for details.

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

bmssp_rs-0.1.0.tar.gz (26.9 kB view details)

Uploaded Source

Built Distributions

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

bmssp_rs-0.1.0-cp38-abi3-win_amd64.whl (162.9 kB view details)

Uploaded CPython 3.8+Windows x86-64

bmssp_rs-0.1.0-cp38-abi3-manylinux_2_34_x86_64.whl (314.7 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.34+ x86-64

bmssp_rs-0.1.0-cp38-abi3-macosx_11_0_arm64.whl (266.0 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

File details

Details for the file bmssp_rs-0.1.0.tar.gz.

File metadata

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

File hashes

Hashes for bmssp_rs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 62b7518c752af25649acbe1abb43ed8e591408ded0947f06e42fda959f71033d
MD5 391deb7d8535d024612c44256a06045a
BLAKE2b-256 4aa18ae18e70884200e14e45a0a1b0324f3d196b2791d99d3c14652e17534c1d

See more details on using hashes here.

Provenance

The following attestation bundles were made for bmssp_rs-0.1.0.tar.gz:

Publisher: release.yml on tripp-smith/bmssp-py

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

File details

Details for the file bmssp_rs-0.1.0-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: bmssp_rs-0.1.0-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 162.9 kB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bmssp_rs-0.1.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 2a0145199c14aac878597ef9134f5827442d4c145b970feceecb9d59abe2eb4e
MD5 280304c48b81d71c3f08f2212fcc75af
BLAKE2b-256 4facbb3b52dc0054501b45c531714b528dc54fc0b4402c2eff5eef0b7b7a671b

See more details on using hashes here.

Provenance

The following attestation bundles were made for bmssp_rs-0.1.0-cp38-abi3-win_amd64.whl:

Publisher: release.yml on tripp-smith/bmssp-py

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

File details

Details for the file bmssp_rs-0.1.0-cp38-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for bmssp_rs-0.1.0-cp38-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 9c0e13052e23a7143e0986ea82bd79683f7b584c50e0ef5ef359da75a38a848e
MD5 52f12fb281fdc52bfeb520ae2d78a79c
BLAKE2b-256 d12e8fcfa37bfc3dbe251ebe352e8f29d3ea65e30d2cc42c656996e25ca5311d

See more details on using hashes here.

Provenance

The following attestation bundles were made for bmssp_rs-0.1.0-cp38-abi3-manylinux_2_34_x86_64.whl:

Publisher: release.yml on tripp-smith/bmssp-py

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

File details

Details for the file bmssp_rs-0.1.0-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for bmssp_rs-0.1.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e190c682196ec528538d16b5837210762c990857f81f9e70f0539c748afffec5
MD5 e98a3f17a668bec27d530a79de2fd87c
BLAKE2b-256 45e572d2c344266ac91770330519d5a46739fce757d6b6b575a5b31891f17ee3

See more details on using hashes here.

Provenance

The following attestation bundles were made for bmssp_rs-0.1.0-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on tripp-smith/bmssp-py

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