In 2025, Ran Duan et al. published Breaking the Sorting Barrier for Directed Single-Source Shortest Paths. The paper proposes BMSSP – a deterministic
This repository contains C++ implementations of both Dijkstra's and BMSSP algorithms, and the infrastructure to benchmark them.
BMSSP stands for Bounded Multi-Source Shortest Path. The algorithm is tasked with solving the SSSP from a set of sources
Each call of a recursion layer aggregates data in the Prepender data structure, pulling it in batches and delegating to lower recursion levels, with the base case being a mini Dijkstra's algorithm. If a particular recursion level is experiencing too big of a workload, the execution is stopped prematurely, and returns a bound
If BMSSP had to be summed up in one sentence, it would most likely be: "Dijkstra's algorithm with batch processing, and means to ensure that the workload is spread evenly".
The BMSSP C++ implementation includes a few tweaks. Most notably, it includes non-deterministic elements, such as Hoare's selection algorithm, hashmaps, and hashsets. These are optimizations only, which intend to reduce the constant while staying true to the main idea and the
It is much expected that the algorithm is slower, due to a bigger constant in many cases, as it is relatively more complicated than Dijkstra. However, the results below show that in some non-negligible cases it may be faster. While this doesn't formally prove anything, and is influenced strongly by the chosen implementation, it demonstrates that the algorithm isn't purely theoretical and could perhaps be beneficial in some use cases.
Both algorithms' runtimes were compared on a sample of
- The log parameter doesn't seem to affect the results much
- The bigger the degree, the "better" (for BMSSP) the ratio
- The ratio has a slow increasing tendency across all degrees
Remark: The results of this run can be recreated by executing ./speedrun.sh.
After scheduling a bigger run for 64-degree graphs, the observations are even more interesting:
- BMSSP has a smaller runtime, even for graphs with
$n = 2^{16} = 65536$ vertices - BMSSP's advantage appears to fade linearly(?) at the end of the measured range
This makes sense, as the runtime of BMSSP heavily depends on 
Before running any of the commands below, ensure that you have Bazel installed.
To quickly benchmark the BMSSP implementation on a selected range of constant degree graphs, simply run:
./speedrun.shThis will generate num_samples random graphs for each combination of log_n and degree_list, running Dijkstra's algorithm and BMSSP side by side. The results will be logged in logs/speedrun_log_{timestamp}.csv.
To run the BMSSP algorithm on your custom graph, run:
bazel run //bmssp/cc/bmssp_main < path/to/your/graph.in > path/to/result.outTo compare BMSSP with Dijkstra on your custom graph run:
bazel run //validation/cc/compare < path/to/your/graph.inThis implementation accepts graphs in the following format (with 0-indexed vertices):
n_vertices m_edges
u_1 v_1 weight_1
u_2 v_2 weight_2
...
u_m v_m weight_m
All algorithms in this repository output the distances (-1 if unreachable) from vertex 0 to all other vertices, separated by spaces.
If you find this repository helpful in your research cite simply as:
@misc{SSSP-Code,
author = {Jan Kwiecinski},
title = {Breaking the Sorting Barrier in Code},
year = {2026},
publisher = {GitHub},
url = {https://github.com/Jankwi/SSSP-Code}
}MIT
