Skip to content

Commit ab01e81

Browse files
SirivasvCopilot
andauthored
Update src/bmssp.mjs
Co-authored-by: Copilot <[email protected]>
1 parent 665559b commit ab01e81

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/bmssp.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ class BMSSP {
1313
// Add node IDs to the set
1414
this.nodeIDs.add(edge[0]);
1515
this.nodeIDs.add(edge[1]);
16+
}
1617

17-
// Initialize shortest paths with Infinity on each nodeID
18-
for (let nodeId of this.nodeIDs) {
19-
this.shortestPaths.push([nodeId, Infinity]);
20-
}
18+
// Initialize shortest paths with Infinity on each nodeID (after all nodes are collected)
19+
for (let nodeId of this.nodeIDs) {
20+
this.shortestPaths.push([nodeId, Infinity]);
2121
}
2222
}
2323
}

0 commit comments

Comments
 (0)