bmssp 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -9
- package/index.mjs +1 -1
- package/package.json +1 -1
- package/src/bmssp.mjs +9 -7
package/README.md
CHANGED
|
@@ -1,19 +1,62 @@
|
|
|
1
|
-
#
|
|
1
|
+
# BMSSP: Bounded Multi-Source Shortest Paths
|
|
2
|
+
[](https://codecov.io/gh/sirivasv/bmssp-js)
|
|
3
|
+
[](https://www.npmjs.com/package/bmssp)
|
|
4
|
+
[](https://hub.docker.com/r/sirivasv/bmssp-js)
|
|
5
|
+
[](https://github.com/sirivasv/bmssp-js/stargazers)
|
|
2
6
|
|
|
3
|
-
This
|
|
4
|
-
"Breaking the Sorting Barrier for Directed Single-Source Shortest Paths".
|
|
7
|
+
This repository provides a community-driven JavaScript implementation of the Tsinghua Single Source Shortest Paths algorithm, based on the paper ["Breaking the Sorting Barrier for Directed Single-Source Shortest Paths"](https://dl.acm.org/doi/10.1145/3717823.3718179) by Duan Ran et al. from Tsinghua University.
|
|
5
8
|
|
|
6
|
-
|
|
9
|
+
BMSSP stands for Bounded Multi-Source Shortest Paths.
|
|
7
10
|
|
|
8
|
-
|
|
11
|
+
## Project Overview
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
- **Language:** JavaScript (ES Modules)
|
|
14
|
+
- **Goal:** Provide an easy-to-use, modern implementation of the algorithm, published to [npmjs.com](https://www.npmjs.com/).
|
|
15
|
+
- **Reference:** For more on ES modules, see the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules).
|
|
11
16
|
|
|
12
|
-
We give a deterministic O(mlog2/3n)-time algorithm for single-source shortest paths (SSSP) on directed graphs with real non-negative edge weights in the comparison-addition model. This is the first result to break the O(m+nlogn) time bound of Dijkstra’s algorithm on sparse graphs, showing that Dijkstra’s algorithm is not optimal for SSSP.
|
|
13
17
|
|
|
14
|
-
##
|
|
18
|
+
## Installation
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
To install this package, you can use npm:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install bmssp
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
To use this package, you can import it in your JavaScript code as follows:
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
// This is a WIP example
|
|
32
|
+
import { BMSSP } from "bmssp";
|
|
33
|
+
|
|
34
|
+
const myBMSSP = new BMSSP([
|
|
35
|
+
[0, 1, 50],
|
|
36
|
+
[1, 2, 75],
|
|
37
|
+
[0, 2, 25],
|
|
38
|
+
]);
|
|
39
|
+
|
|
40
|
+
console.log(myBMSSP.graph);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The file must use ECMAScript modules (ESM) syntax and have the `.mjs` file extension. Go to the `examples` directory for more usage examples.
|
|
44
|
+
|
|
45
|
+
### Using the docker image
|
|
46
|
+
|
|
47
|
+
You can also use the published docker image and run the example:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
docker run -it sirivasv/bmssp-js:latest
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Or your tests in a pre-configured environment (replace `folder-mytest/` with your tests folder and `index.mjs` with your test file):
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
docker run -it -v ./folder-mytest/:/bmssp-js/folder-mytest/ sirivasv/bmssp-js:latest node /bmssp-js/folder-mytest/index.mjs
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Other versions of the docker image can be found on [Docker Hub](https://hub.docker.com/r/sirivasv/bmssp-js/tags).
|
|
17
60
|
|
|
18
61
|
### Other Implementations in GitHub
|
|
19
62
|
|
package/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { BMSSP } from "./src/bmssp.mjs";
|
package/package.json
CHANGED
package/src/bmssp.mjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
class BMSSP {
|
|
2
|
+
constructor(inputGraph) {
|
|
3
|
+
this.graph = [];
|
|
4
|
+
for (let edge of inputGraph) {
|
|
5
|
+
// Create a deep copy of each edge array
|
|
6
|
+
this.graph.push([...edge]);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
3
9
|
}
|
|
4
10
|
|
|
5
|
-
|
|
6
|
-
return `Processed: ${message}`;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export { printMessage, processMessage };
|
|
11
|
+
export { BMSSP };
|