bmssp 0.12.0 → 0.13.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/bmssp.mjs +35 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bmssp",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Javascript package implementation of the bmssp algorithm.",
5
5
  "main": "index.mjs",
6
6
  "keywords": [
package/src/bmssp.mjs CHANGED
@@ -1,11 +1,46 @@
1
1
  class BMSSP {
2
2
  constructor(inputGraph) {
3
+ // Main graph represented as an array of edges
3
4
  this.graph = [];
5
+ // Set to store unique node IDs
6
+ this.nodeIDs = new Set();
7
+ // Map to store shortest paths
8
+ this.shortestPaths = new Map();
9
+
4
10
  for (let edge of inputGraph) {
5
11
  // Create a deep copy of each edge array
6
12
  this.graph.push([...edge]);
13
+
14
+ // Add node IDs to the set
15
+ this.nodeIDs.add(edge[0]);
16
+ this.nodeIDs.add(edge[1]);
17
+ }
18
+
19
+ // Initialize shortest paths map
20
+ this.initializeShortestPaths();
21
+ }
22
+
23
+ // Method to initialize the shortest paths map
24
+ initializeShortestPaths() {
25
+ for (let nodeId of this.nodeIDs) {
26
+ this.shortestPaths.set(nodeId, Infinity);
7
27
  }
8
28
  }
29
+
30
+ // Method to calculate shortest paths (placeholder implementation)
31
+ calculateShortestPaths(startNode) {
32
+ // To clean the state before calculation
33
+ this.initializeShortestPaths();
34
+
35
+ // validate startNode
36
+ if (!this.nodeIDs.has(startNode)) {
37
+ throw new Error("Start node not found in the graph");
38
+ }
39
+
40
+ // Placeholder logic for shortest path calculation
41
+ // This should be replaced with an actual implementation of BMSSP algorithm
42
+ this.shortestPaths.set(startNode, 0);
43
+ }
9
44
  }
10
45
 
11
46
  export { BMSSP };