Skip to main content

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.

Release files for bmssp-rs 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bmssp-rs 0.1.0
File Size Uploaded
bmssp_rs-0.1.0.tar.gz 26.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for bmssp-rs 0.1.0
File Interpreter ABI Platform
bmssp_rs-0.1.0-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details
bmssp_rs-0.1.0-cp38-abi3-manylinux_2_34_x86_64.whl CPython 3.8 abi3 Linux glibc 2.34+ x86-64 Details
bmssp_rs-0.1.0-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details

Total release size: 770.4 kB

Release files / bmssp_rs-0.1.0.tar.gz

Download URL bmssp_rs-0.1.0.tar.gz
Size 26.9 kB
Tags Source
SHA-256 checksum
How to use checksums
62b7518c752af25649acbe1abb43ed8e591408ded0947f06e42fda959f71033d
BLAKE2b-256 checksum
How to use checksums
4aa18ae18e70884200e14e45a0a1b0324f3d196b2791d99d3c14652e17534c1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 14, 2026.

Transparency log

Release files / bmssp_rs-0.1.0-cp38-abi3-win_amd64.whl

Download URL bmssp_rs-0.1.0-cp38-abi3-win_amd64.whl
Size 162.9 kB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
2a0145199c14aac878597ef9134f5827442d4c145b970feceecb9d59abe2eb4e
BLAKE2b-256 checksum
How to use checksums
4facbb3b52dc0054501b45c531714b528dc54fc0b4402c2eff5eef0b7b7a671b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 14, 2026.

Transparency log

Release files / bmssp_rs-0.1.0-cp38-abi3-manylinux_2_34_x86_64.whl

Download URL bmssp_rs-0.1.0-cp38-abi3-manylinux_2_34_x86_64.whl
Size 314.7 kB
Tags CPython 3.8 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
9c0e13052e23a7143e0986ea82bd79683f7b584c50e0ef5ef359da75a38a848e
BLAKE2b-256 checksum
How to use checksums
d12e8fcfa37bfc3dbe251ebe352e8f29d3ea65e30d2cc42c656996e25ca5311d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 14, 2026.

Transparency log

Release files / bmssp_rs-0.1.0-cp38-abi3-macosx_11_0_arm64.whl

Download URL bmssp_rs-0.1.0-cp38-abi3-macosx_11_0_arm64.whl
Size 266.0 kB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e190c682196ec528538d16b5837210762c990857f81f9e70f0539c748afffec5
BLAKE2b-256 checksum
How to use checksums
45e572d2c344266ac91770330519d5a46739fce757d6b6b575a5b31891f17ee3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 14, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

4 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page