@xingwangzhe/bfs-rs 0.2.2 → 0.3.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 CHANGED
@@ -24,7 +24,7 @@ offsets = [0, 2, 4, 7, 8] // node offset range (length = n + 1)
24
24
  ```
25
25
 
26
26
  | Node | Neighbors |
27
- |------|-----------------------|
27
+ | ---- | --------------------- |
28
28
  | 0 | adj[0..2] = [1, 2] |
29
29
  | 1 | adj[2..4] = [0, 2] |
30
30
  | 2 | adj[4..7] = [0, 1, 3] |
@@ -39,7 +39,7 @@ offsets = [0, 2, 4, 7, 8] // node offset range (length = n + 1)
39
39
  Single-source BFS, returns distances array.
40
40
 
41
41
  ```ts
42
- import { bfsOne } from '@xingwangzhe/bfs-rs';
42
+ import { bfsOne } from "@xingwangzhe/bfs-rs";
43
43
  const r = bfsOne(adj, offsets, n, 0);
44
44
  // r.distances → [0, 1, 1, 2]
45
45
  // r.maxDistance → 2
@@ -51,7 +51,7 @@ const r = bfsOne(adj, offsets, n, 0);
51
51
  Parallel BFS from multiple sources.
52
52
 
53
53
  ```ts
54
- import { bfsBatch } from '@xingwangzhe/bfs-rs';
54
+ import { bfsBatch } from "@xingwangzhe/bfs-rs";
55
55
  const r = bfsBatch(adj, offsets, n, [0, 3]);
56
56
  // r.processed → 2, r.results → [BfsOneResult, BfsOneResult]
57
57
  ```
@@ -61,7 +61,7 @@ const r = bfsBatch(adj, offsets, n, [0, 3]);
61
61
  All-pairs BFS (every node as source).
62
62
 
63
63
  ```ts
64
- import { bfsAll } from '@xingwangzhe/bfs-rs';
64
+ import { bfsAll } from "@xingwangzhe/bfs-rs";
65
65
  const r = bfsAll(adj, offsets, n);
66
66
  // r.results.length === n
67
67
  ```
@@ -71,7 +71,7 @@ const r = bfsAll(adj, offsets, n);
71
71
  Shortest path between two nodes. Stops early at target.
72
72
 
73
73
  ```ts
74
- import { bfsPath } from '@xingwangzhe/bfs-rs';
74
+ import { bfsPath } from "@xingwangzhe/bfs-rs";
75
75
  const r = bfsPath(adj, offsets, n, 0, 3);
76
76
  // r.path → [0, 2, 3], r.distance → 2
77
77
  ```
@@ -85,7 +85,7 @@ These return **only the distance histogram** per source (no full `distances` arr
85
85
  Same usage as above, but result type is `BfsHistogramResult`:
86
86
 
87
87
  ```ts
88
- import { bfsAllHistogram } from '@xingwangzhe/bfs-rs';
88
+ import { bfsAllHistogram } from "@xingwangzhe/bfs-rs";
89
89
  const r = bfsAllHistogram(adj, offsets, n);
90
90
  // r.results[i].histogram → [count_at_dist_1, count_at_dist_2, ...]
91
91
  // r.results[i].maxDistance → number
@@ -98,7 +98,7 @@ Memory per source: ~(diameter × 4) bytes instead of ~(n × 4) bytes.
98
98
  For repeated queries on the same graph, build the transpose and reusable traversal buffers once:
99
99
 
100
100
  ```ts
101
- import { createBfsGraph } from '@xingwangzhe/bfs-rs';
101
+ import { createBfsGraph } from "@xingwangzhe/bfs-rs";
102
102
 
103
103
  const graph = createBfsGraph(new Uint32Array(adj), new Uint32Array(offsets), n);
104
104
  const one = graph.one(0);
@@ -110,22 +110,31 @@ The prepared API keeps every result exact. Existing array-based functions remain
110
110
 
111
111
  ## Performance
112
112
 
113
- | Platform | 57K nodes × 179K edges | Notes |
114
- |------------|----------------------|---------------------------|
115
- | 16-core | **~3s** | Rayon `par_iter` across 16 threads |
116
- | 1-core | ~70s | auto-fallback to `iter` |
113
+ Single-source traversal switches between top-down push and bottom-up pull when
114
+ the frontier becomes broad. Visitation stamps avoid clearing an `n`-element
115
+ distance array for histogram-only calls; sparse levels do not build bitmaps.
117
116
 
118
- The traversal switches between top-down push and bottom-up pull when the frontier becomes broad. Visitation stamps avoid clearing an `n`-element distance array for histogram-only calls, and merged histograms use worker-local counters before reduction.
117
+ Merged histograms share adjacency visits across 64 exact source traversals and
118
+ parallelize independent batches with Rayon. Verified undirected graphs can also
119
+ collapse equal neighbor sets into weighted vertices while preserving all ordered
120
+ pair counts. Small graphs and graphs with maximum outgoing degree at most two
121
+ use independent BFSs. The merged histogram retains at least 128 bins and grows
122
+ when a shortest path exceeds 128 edges.
123
+
124
+ Runtime depends on graph structure and CPU topology. See
125
+ [performance methodology and reproducible consumer-fixture benchmarks](scripts/PERFORMANCE.md)
126
+ for algorithm details, fallbacks, source references, memory measurement, and PGO
127
+ selection. No host-specific CPU instruction flags are needed.
119
128
 
120
129
  ## Full Example
121
130
 
122
131
  ```ts
123
- import { bfsOne, bfsBatch, bfsAll, bfsPath, bfsAllHistogram } from '@xingwangzhe/bfs-rs';
132
+ import { bfsOne, bfsBatch, bfsAll, bfsPath, bfsAllHistogram } from "@xingwangzhe/bfs-rs";
124
133
 
125
134
  // Graph: 0--1--2, 0--3--4--2
126
- const adj = [1, 3, 0, 2, 1, 4, 0, 4, 2, 3];
135
+ const adj = [1, 3, 0, 2, 1, 4, 0, 4, 2, 3];
127
136
  const offsets = [0, 2, 4, 6, 8, 10];
128
- const n = 5;
137
+ const n = 5;
129
138
 
130
139
  // Full distances
131
140
  const r1 = bfsOne(adj, offsets, n, 0);
@@ -150,3 +159,7 @@ for (const h of r3.results) {
150
159
  ## License
151
160
 
152
161
  MIT
162
+
163
+ ## Runtime-focused release builds
164
+
165
+ Native CI artifacts use full LTO, one code-generation unit, and O3, while preserving the existing CPU instruction baseline. CI trains a profile-guided optimization (PGO) candidate using representative graph workloads and publishes it only when the runtime comparison passes; otherwise it publishes the unprofiled release. `bun run build:pgo` produces the optimized addon; `bun run benchmark:pgo` compares it with an unprofiled release. Install `llvm-tools-preview` with the same Rust toolchain first. Details and measurement limits: [scripts/PERFORMANCE.md](scripts/PERFORMANCE.md).
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/index.js CHANGED
@@ -89,8 +89,8 @@ function requireNative() {
89
89
  try {
90
90
  const binding = require('@xingwangzhe/bfs-rs-android-arm64')
91
91
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-android-arm64/package.json').version
92
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
93
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
92
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
93
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
94
94
  }
95
95
  return binding
96
96
  } catch (e) {
@@ -105,8 +105,8 @@ function requireNative() {
105
105
  try {
106
106
  const binding = require('@xingwangzhe/bfs-rs-android-arm-eabi')
107
107
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-android-arm-eabi/package.json').version
108
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
109
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
108
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
109
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
110
110
  }
111
111
  return binding
112
112
  } catch (e) {
@@ -126,8 +126,8 @@ function requireNative() {
126
126
  try {
127
127
  const binding = require('@xingwangzhe/bfs-rs-win32-x64-gnu')
128
128
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-win32-x64-gnu/package.json').version
129
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
130
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
129
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
130
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
131
131
  }
132
132
  return binding
133
133
  } catch (e) {
@@ -142,8 +142,8 @@ function requireNative() {
142
142
  try {
143
143
  const binding = require('@xingwangzhe/bfs-rs-win32-x64-msvc')
144
144
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-win32-x64-msvc/package.json').version
145
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
146
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
145
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
146
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
147
147
  }
148
148
  return binding
149
149
  } catch (e) {
@@ -159,8 +159,8 @@ function requireNative() {
159
159
  try {
160
160
  const binding = require('@xingwangzhe/bfs-rs-win32-ia32-msvc')
161
161
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-win32-ia32-msvc/package.json').version
162
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
163
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
162
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
163
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
164
164
  }
165
165
  return binding
166
166
  } catch (e) {
@@ -175,8 +175,8 @@ function requireNative() {
175
175
  try {
176
176
  const binding = require('@xingwangzhe/bfs-rs-win32-arm64-msvc')
177
177
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-win32-arm64-msvc/package.json').version
178
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
179
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
178
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
179
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
180
180
  }
181
181
  return binding
182
182
  } catch (e) {
@@ -194,8 +194,8 @@ function requireNative() {
194
194
  try {
195
195
  const binding = require('@xingwangzhe/bfs-rs-darwin-universal')
196
196
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-darwin-universal/package.json').version
197
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
198
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
197
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
198
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
199
199
  }
200
200
  return binding
201
201
  } catch (e) {
@@ -210,8 +210,8 @@ function requireNative() {
210
210
  try {
211
211
  const binding = require('@xingwangzhe/bfs-rs-darwin-x64')
212
212
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-darwin-x64/package.json').version
213
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
214
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
213
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
214
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
215
215
  }
216
216
  return binding
217
217
  } catch (e) {
@@ -226,8 +226,8 @@ function requireNative() {
226
226
  try {
227
227
  const binding = require('@xingwangzhe/bfs-rs-darwin-arm64')
228
228
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-darwin-arm64/package.json').version
229
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
230
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
229
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
230
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
231
231
  }
232
232
  return binding
233
233
  } catch (e) {
@@ -246,8 +246,8 @@ function requireNative() {
246
246
  try {
247
247
  const binding = require('@xingwangzhe/bfs-rs-freebsd-x64')
248
248
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-freebsd-x64/package.json').version
249
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
250
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
249
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
250
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
251
251
  }
252
252
  return binding
253
253
  } catch (e) {
@@ -262,8 +262,8 @@ function requireNative() {
262
262
  try {
263
263
  const binding = require('@xingwangzhe/bfs-rs-freebsd-arm64')
264
264
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-freebsd-arm64/package.json').version
265
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
266
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
265
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
266
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
267
267
  }
268
268
  return binding
269
269
  } catch (e) {
@@ -283,8 +283,8 @@ function requireNative() {
283
283
  try {
284
284
  const binding = require('@xingwangzhe/bfs-rs-linux-x64-musl')
285
285
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-linux-x64-musl/package.json').version
286
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
287
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
286
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
287
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
288
288
  }
289
289
  return binding
290
290
  } catch (e) {
@@ -299,8 +299,8 @@ function requireNative() {
299
299
  try {
300
300
  const binding = require('@xingwangzhe/bfs-rs-linux-x64-gnu')
301
301
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-linux-x64-gnu/package.json').version
302
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
303
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
302
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
303
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
304
304
  }
305
305
  return binding
306
306
  } catch (e) {
@@ -317,8 +317,8 @@ function requireNative() {
317
317
  try {
318
318
  const binding = require('@xingwangzhe/bfs-rs-linux-arm64-musl')
319
319
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-linux-arm64-musl/package.json').version
320
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
321
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
320
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
321
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
322
322
  }
323
323
  return binding
324
324
  } catch (e) {
@@ -333,8 +333,8 @@ function requireNative() {
333
333
  try {
334
334
  const binding = require('@xingwangzhe/bfs-rs-linux-arm64-gnu')
335
335
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-linux-arm64-gnu/package.json').version
336
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
337
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
336
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
337
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
338
338
  }
339
339
  return binding
340
340
  } catch (e) {
@@ -351,8 +351,8 @@ function requireNative() {
351
351
  try {
352
352
  const binding = require('@xingwangzhe/bfs-rs-linux-arm-musleabihf')
353
353
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-linux-arm-musleabihf/package.json').version
354
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
355
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
354
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
355
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
356
356
  }
357
357
  return binding
358
358
  } catch (e) {
@@ -367,8 +367,8 @@ function requireNative() {
367
367
  try {
368
368
  const binding = require('@xingwangzhe/bfs-rs-linux-arm-gnueabihf')
369
369
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-linux-arm-gnueabihf/package.json').version
370
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
371
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
370
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
371
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
372
372
  }
373
373
  return binding
374
374
  } catch (e) {
@@ -385,8 +385,8 @@ function requireNative() {
385
385
  try {
386
386
  const binding = require('@xingwangzhe/bfs-rs-linux-loong64-musl')
387
387
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-linux-loong64-musl/package.json').version
388
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
389
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
388
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
389
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
390
390
  }
391
391
  return binding
392
392
  } catch (e) {
@@ -401,8 +401,8 @@ function requireNative() {
401
401
  try {
402
402
  const binding = require('@xingwangzhe/bfs-rs-linux-loong64-gnu')
403
403
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-linux-loong64-gnu/package.json').version
404
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
405
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
404
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
405
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
406
406
  }
407
407
  return binding
408
408
  } catch (e) {
@@ -419,8 +419,8 @@ function requireNative() {
419
419
  try {
420
420
  const binding = require('@xingwangzhe/bfs-rs-linux-riscv64-musl')
421
421
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-linux-riscv64-musl/package.json').version
422
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
423
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
422
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
423
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
424
424
  }
425
425
  return binding
426
426
  } catch (e) {
@@ -435,8 +435,8 @@ function requireNative() {
435
435
  try {
436
436
  const binding = require('@xingwangzhe/bfs-rs-linux-riscv64-gnu')
437
437
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-linux-riscv64-gnu/package.json').version
438
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
439
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
438
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
439
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
440
440
  }
441
441
  return binding
442
442
  } catch (e) {
@@ -452,8 +452,8 @@ function requireNative() {
452
452
  try {
453
453
  const binding = require('@xingwangzhe/bfs-rs-linux-ppc64-gnu')
454
454
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-linux-ppc64-gnu/package.json').version
455
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
456
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
455
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
456
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
457
457
  }
458
458
  return binding
459
459
  } catch (e) {
@@ -468,8 +468,8 @@ function requireNative() {
468
468
  try {
469
469
  const binding = require('@xingwangzhe/bfs-rs-linux-s390x-gnu')
470
470
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-linux-s390x-gnu/package.json').version
471
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
472
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
471
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
472
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
473
473
  }
474
474
  return binding
475
475
  } catch (e) {
@@ -488,8 +488,8 @@ function requireNative() {
488
488
  try {
489
489
  const binding = require('@xingwangzhe/bfs-rs-openharmony-arm64')
490
490
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-openharmony-arm64/package.json').version
491
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
492
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
491
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
492
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
493
493
  }
494
494
  return binding
495
495
  } catch (e) {
@@ -504,8 +504,8 @@ function requireNative() {
504
504
  try {
505
505
  const binding = require('@xingwangzhe/bfs-rs-openharmony-x64')
506
506
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-openharmony-x64/package.json').version
507
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
508
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
507
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
508
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
509
509
  }
510
510
  return binding
511
511
  } catch (e) {
@@ -520,8 +520,8 @@ function requireNative() {
520
520
  try {
521
521
  const binding = require('@xingwangzhe/bfs-rs-openharmony-arm')
522
522
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-openharmony-arm/package.json').version
523
- if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
524
- throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
523
+ if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
524
+ throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
525
525
  }
526
526
  return binding
527
527
  } catch (e) {
@@ -661,8 +661,8 @@ if (!nativeBinding || forceWasi) {
661
661
  if (!candidateFailed) {
662
662
  if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
663
663
  const bindingPackageVersion = require('@xingwangzhe/bfs-rs-wasm32-wasi/package.json').version
664
- if (bindingPackageVersion !== '0.2.2') {
665
- throw new Error(`WASI binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
664
+ if (bindingPackageVersion !== '0.3.0') {
665
+ throw new Error(`WASI binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
666
666
  }
667
667
  }
668
668
  wasiBinding = require('@xingwangzhe/bfs-rs-wasm32-wasi')
package/package.json CHANGED
@@ -1,27 +1,47 @@
1
1
  {
2
2
  "name": "@xingwangzhe/bfs-rs",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "Rust BFS on compressed adjacency list with Rayon parallelism",
5
- "main": "index.js",
6
- "types": "index.d.ts",
7
- "license": "MIT",
8
- "author": "xingwangzhe",
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/xingwangzhe/bfs-rs.git"
12
- },
13
5
  "keywords": [
14
6
  "bfs",
15
7
  "graph",
16
- "rayon",
17
8
  "napi-rs",
9
+ "rayon",
18
10
  "rust"
19
11
  ],
12
+ "license": "MIT",
13
+ "author": "xingwangzhe",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/xingwangzhe/bfs-rs.git"
17
+ },
20
18
  "files": [
21
19
  "index.d.ts",
22
20
  "index.js",
23
21
  "bfs-rs.*.node"
24
22
  ],
23
+ "main": "index.js",
24
+ "types": "index.d.ts",
25
+ "scripts": {
26
+ "build": "napi build --platform --release",
27
+ "test": "node --test bfs.test.mjs",
28
+ "benchmark": "node benchmark.mjs",
29
+ "lint": "oxlint",
30
+ "artifacts": "napi artifacts",
31
+ "build:pgo": "node scripts/build-pgo.mjs",
32
+ "benchmark:pgo": "node scripts/build-pgo.mjs --compare"
33
+ },
34
+ "devDependencies": {
35
+ "@napi-rs/cli": "^3.10.8",
36
+ "@oxc-node/core": "^0.1.7",
37
+ "ava": "^8.0.2",
38
+ "oxlint": "^1.88.0",
39
+ "typescript": "~6.0.3"
40
+ },
41
+ "overrides": {
42
+ "brace-expansion": "^5.0.9",
43
+ "tar": "^7.5.22"
44
+ },
25
45
  "napi": {
26
46
  "binaryName": "bfs-rs",
27
47
  "targets": [
@@ -35,23 +55,5 @@
35
55
  },
36
56
  "engines": {
37
57
  "node": ">= 18"
38
- },
39
- "scripts": {
40
- "build": "napi build --platform --release",
41
- "test": "node --test bfs.test.mjs",
42
- "benchmark": "node benchmark.mjs",
43
- "lint": "oxlint",
44
- "artifacts": "napi artifacts"
45
- },
46
- "devDependencies": {
47
- "@napi-rs/cli": "^3.10.5",
48
- "@oxc-node/core": "^0.1.3",
49
- "ava": "^8.0.1",
50
- "oxlint": "^1.85.0",
51
- "typescript": "^7.0.2"
52
- },
53
- "overrides": {
54
- "brace-expansion": "^5.0.9",
55
- "tar": "^7.5.22"
56
58
  }
57
59
  }