@@ -4,22 +4,36 @@ class BMSSP {
44 this . graph = [ ] ;
55 // Set to store unique node IDs
66 this . nodeIDs = new Set ( ) ;
7- // Array to store shortest paths
8- this . shortestPaths = [ ] ;
7+ // Map to store shortest paths
8+ this . shortestPaths = new Map ( ) ;
99
1010 for ( let edge of inputGraph ) {
1111 // Create a deep copy of each edge array
1212 this . graph . push ( [ ...edge ] ) ;
13+
1314 // Add node IDs to the set
1415 this . nodeIDs . add ( edge [ 0 ] ) ;
1516 this . nodeIDs . add ( edge [ 1 ] ) ;
1617 }
1718
18- // Initialize shortest paths with Infinity on each nodeID (after all nodes are collected)
19+ // Initialize shortest paths map
20+ this . initializeShortestPaths ( ) ;
21+ }
22+
23+ // Method to initialize the shortest paths map
24+ initializeShortestPaths ( ) {
1925 for ( let nodeId of this . nodeIDs ) {
20- this . shortestPaths . push ( [ nodeId , Infinity ] ) ;
26+ this . shortestPaths . set ( nodeId , Infinity ) ;
2127 }
2228 }
29+
30+ // Method to calculate shortest paths (placeholder implementation)
31+ calculateShortestPaths ( startNode ) {
32+ // Placeholder logic for shortest path calculation
33+ // This should be replaced with an actual implementation of BMSSP algorithm
34+ this . initializeShortestPaths ( ) ;
35+ this . shortestPaths . set ( startNode , 0 ) ;
36+ }
2337}
2438
2539export { BMSSP } ;
0 commit comments