{"_id":"@ruvnet/bmssp","_rev":"2-7ac8367b966d127912a18709a54d7892","name":"@ruvnet/bmssp","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@ruvnet/bmssp","version":"1.0.0","keywords":["graph","pathfinding","shortest-path","algorithm","wasm","webassembly","bmssp","routing","network","optimization","dijkstra","bidirectional","multi-source","performance","typescript"],"author":{"name":"BMSSP Team"},"license":"MIT","_id":"@ruvnet/bmssp@1.0.0","maintainers":[{"name":"ruvnet","email":"ruv@ruv.net"}],"homepage":"https://github.com/ruvnet/bmssp#readme","bugs":{"url":"https://github.com/ruvnet/bmssp/issues"},"dist":{"shasum":"6fdb8507dfc2424aae0459a8e57deec1ba06fb1a","tarball":"https://registry.npmjs.org/@ruvnet/bmssp/-/bmssp-1.0.0.tgz","fileCount":5,"integrity":"sha512-u3BqKqPS9q8LBU2u7hefWH5v2d1h2Cfm27Xk+25hD+4azeC9/zQfVxp4yLZTGEZLJ3lgzFSH9mbBIkP278jX3Q==","signatures":[{"sig":"MEQCIErakKWDDcHGj+/tjVrYEggP3dk4up8ZanaKDKo6f++EAiB3pDlWhcEh6xtMtg/zjKTIauzPE84okzwP+RO2Q+1gOA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":52011},"main":"bmssp_rust.js","type":"module","types":"bmssp_rust.d.ts","engines":{"node":">=14.0.0"},"exports":{".":{"types":"./bmssp_rust.d.ts","import":"./bmssp_rust.js"}},"gitHead":"042c463c03e0c4d3b8fd943c97846ec884c85656","_npmUser":{"name":"ruvnet","email":"ruv@ruv.net"},"repository":{"url":"git+https://github.com/ruvnet/bmssp.git","type":"git"},"_npmVersion":"9.8.1","description":"Blazing fast graph pathfinding SDK powered by WebAssembly. 10-15x faster than JavaScript implementations.","directories":{},"sideEffects":false,"_nodeVersion":"22.17.0","collaborators":["BMSSP Development Team"],"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/bmssp_1.0.0_1756481036119_0.6668941452801436","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"_id":"@ruvnet/bmssp@1.0.1","bugs":{"url":"https://github.com/ruvnet/bmssp/issues"},"dist":{"shasum":"471cd43c37193639401e3edf705fdb674d3997ee","tarball":"https://registry.npmjs.org/@ruvnet/bmssp/-/bmssp-1.0.1.tgz","fileCount":7,"integrity":"sha512-T1TG6qxcohD2TPTrJLIvdRTMUIfmQPwtM8FhSqf+6gtcdRJCPcNmVbGXOZklj5d6YbyTZN4O1L3oMwKeRQVFPw==","signatures":[{"sig":"MEQCIHlmeBKfx+yYpRpfUboc0put87adFj1za0U4gETi/ZzpAiBo2BB3ClXVLmigsYvvhB6EU0a04WmIi6qO7WK6fs/uAw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCGLWRnnIWNnPd5xZtYTbB6SCqELco6DhyY976lqVjxagIgPz3AQN/sNhLitmXOxIoHNjtvCG5804ZVzKRZoLpT+14="}],"unpackedSize":47346},"main":"./node.js","name":"@ruvnet/bmssp","type":"module","_from":"file:ruvnet-bmssp-1.0.1.tgz","types":"./bmssp_rust.d.ts","author":{"name":"ruvnet","email":"ruv@ruv.net"},"engines":{"node":">=18"},"exports":{".":{"node":"./node.js","types":"./bmssp_rust.d.ts","default":"./bmssp_rust.js"},"./package.json":"./package.json","./bmssp_rust_bg.wasm":"./bmssp_rust_bg.wasm"},"license":"MIT","scripts":{"test":"node examples/check.mjs"},"version":"1.0.1","_npmUser":{"name":"ruvnet","email":"ruv@ruv.net"},"homepage":"https://ruv.io","keywords":["graph","shortest-path","sssp","pathfinding","bellman-ford","bmssp","wasm","webassembly","rust","routing","embeddings","typescript"],"_resolved":"/home/ruvultra/.cache/weaver-lanes/tmp.aQRxF0LlJT/bmssp/npm/ruvnet-bmssp-1.0.1.tgz","_integrity":"sha512-T1TG6qxcohD2TPTrJLIvdRTMUIfmQPwtM8FhSqf+6gtcdRJCPcNmVbGXOZklj5d6YbyTZN4O1L3oMwKeRQVFPw==","repository":{"url":"git+https://github.com/ruvnet/bmssp.git","type":"git","directory":"npm"},"_npmVersion":"10.9.8","description":"Single-source shortest paths in Rust compiled to WebAssembly for Node.js and browsers. WasmGraph for weighted graphs, WasmNeuralBMSSP for embedding-weighted paths.","directories":{},"maintainers":[{"name":"ruvnet","email":"ruv@ruv.net"}],"sideEffects":false,"_nodeVersion":"22.23.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/bmssp_1.0.1_1794370009223_0.960008826978139"}}},"time":{"created":"2025-08-29T15:23:56.024Z","modified":"2026-11-11T04:06:49.473Z","1.0.0":"2025-08-29T15:23:56.309Z","1.0.1":"2026-11-11T04:06:49.320Z"},"bugs":{"url":"https://github.com/ruvnet/bmssp/issues"},"author":{"name":"ruvnet","email":"ruv@ruv.net"},"license":"MIT","homepage":"https://ruv.io","keywords":["graph","shortest-path","sssp","pathfinding","bellman-ford","bmssp","wasm","webassembly","rust","routing","embeddings","typescript"],"repository":{"url":"git+https://github.com/ruvnet/bmssp.git","type":"git","directory":"npm"},"description":"Single-source shortest paths in Rust compiled to WebAssembly for Node.js and browsers. WasmGraph for weighted graphs, WasmNeuralBMSSP for embedding-weighted paths.","maintainers":[{"name":"ruvnet","email":"ruv@ruv.net"}],"readme":"# @ruvnet/bmssp\n\n[![npm version](https://img.shields.io/npm/v/@ruvnet/bmssp.svg)](https://www.npmjs.com/package/@ruvnet/bmssp)\n[![CI](https://github.com/ruvnet/bmssp/actions/workflows/ci.yml/badge.svg)](https://github.com/ruvnet/bmssp/actions/workflows/ci.yml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n\nSingle-source shortest paths, written in Rust and compiled to WebAssembly. It runs in Node.js 18+ and in browsers, and ships TypeScript types.\n\n![Shortest distances from vertex 0 spreading through a weighted graph](https://raw.githubusercontent.com/ruvnet/bmssp/main/assets/bmssp-paths.svg)\n\n## Which package to use\n\nUse **`@ruvnet/bmssp`**. It is the canonical package.\n\n`bmssp-wasm` is a duplicate. Version 1.0.0 of both packages was published from the same build, with the same wasm binary. `bmssp-wasm` gets no further releases and is being deprecated in favor of `@ruvnet/bmssp`.\n\n## Install\n\n```bash\nnpm install @ruvnet/bmssp\n```\n\n## Quickstart\n\n```js\nimport init, { WasmGraph } from '@ruvnet/bmssp';\n\nawait init();\n\n// 4 vertices, directed edges with weights\nconst graph = new WasmGraph(4, true);\ngraph.add_edge(0, 1, 1.0);\ngraph.add_edge(1, 2, 2.5);\ngraph.add_edge(0, 2, 5.0);\ngraph.add_edge(2, 3, 1.0);\n\nconst distances = graph.compute_shortest_paths(0); // Float64Array\nconsole.log(Array.from(distances)); // [ 0, 1, 3.5, 4.5 ]\nconsole.log(graph.vertex_count, graph.edge_count); // 4 4\n\ngraph.free();\n```\n\nSave it as `quickstart.mjs` and run `node quickstart.mjs`. The same file is in [`npm/examples/quickstart.mjs`](npm/examples/quickstart.mjs), and CI runs it against a fresh install of the packed tarball.\n\n`init()` loads the wasm module. You must call it once before you construct a graph. Further calls do nothing.\n- In Node, `init()` with no argument reads `bmssp_rust_bg.wasm` from the package directory.\n- In a browser or bundler, it fetches the file next to `bmssp_rust.js`. To load the module from somewhere else, pass `{ module_or_path }` (a URL, a `Response`, bytes, or a `WebAssembly.Module`).\n- `initSync({ module })` takes bytes or a compiled module and initializes synchronously.\n\n## API\n\n### `WasmGraph`\n\n| Member | Description |\n|---|---|\n| `new WasmGraph(vertices: number, directed: boolean)` | Creates an empty graph with vertices `0 .. vertices-1`. |\n| `add_edge(from, to, weight): boolean` | Adds a weighted edge. Returns `false` if a vertex index is out of range. In an undirected graph, this adds both directions. |\n| `compute_shortest_paths(source): Float64Array` | Returns the distance from `source` to every vertex, computed with Bellman-Ford (early exit when no distance improves). A vertex that cannot be reached gets `Infinity`. Negative weights are allowed. If the source is out of range or the graph has a negative cycle, every entry is `Infinity`. |\n| `vertex_count` / `edge_count` | Read-only counts. In an undirected graph, `edge_count` counts each edge twice, once per direction. |\n| `free()` | Releases the wasm memory. |\n\n### `WasmNeuralBMSSP`\n\nThis variant combines edge weights with distances between node embeddings.\n\n| Member | Description |\n|---|---|\n| `new WasmNeuralBMSSP(vertices, embedding_dim)` | Creates a graph whose nodes all start with zero embeddings. |\n| `set_embedding(node, embedding: Float64Array): boolean` | Sets one node's embedding. |\n| `add_semantic_edge(from, to, alpha)` | Adds an edge whose weight is `alpha` times the Euclidean distance between the two endpoints' embeddings, measured when the edge is added. |\n| `compute_neural_paths(source): Float64Array` | Returns distances from `source` over the semantic edges. |\n| `semantic_distance(a, b): number` | Returns the Euclidean distance between two nodes' embeddings. |\n| `update_embeddings(gradients_flat, learning_rate, embedding_dim): boolean` | Applies a gradient step to every embedding. |\n| `free()` | Releases the wasm memory. |\n\n## Changes in 1.0.1\n\n- The README in 1.0.0 documented an API that did not exist (`BmsSpGraph`, `shortest_path`, `dist/bmssp.js`). This README documents the real exports.\n- In 1.0.0, calling `init()` with no argument failed under Node with `fetch failed`. Node now gets its own entry point, which reads the wasm from disk.\n- The `exports` map now exposes `./bmssp_rust_bg.wasm` and `./package.json`.\n- The wasm is rebuilt from the Rust source in this repository (wasm-bindgen 0.2.100, same TypeScript surface as 1.0.0). Unmaintained optional dependencies (`wee_alloc`, `pprof`) were removed, and `cargo audit` is clean.\n- Requires Node 18 or later.\n\n## Build from source\n\nThe Rust crate in this repository is the source of the npm package.\n\n```bash\ncargo test\n./scripts/build-npm.sh          # wasm-pack build --target web, stages files into npm/\ncd npm && npm pack\n```\n\n## License\n\nMIT. See [LICENSE](LICENSE).\n\nLinks: [ruv.io](https://ruv.io) · [Issues](https://github.com/ruvnet/bmssp/issues)\n","readmeFilename":"README.md"}