@xingwangzhe/bfs-rs 0.1.4 → 0.1.5

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.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/index.d.ts CHANGED
@@ -3,6 +3,9 @@
3
3
  /** 从所有节点并行执行 BFS(全量) */
4
4
  export declare function bfsAll(adj: Array<number>, offsets: Array<number>, n: number): BfsBatchResult
5
5
 
6
+ /** 从所有节点并行执行 BFS(全量),仅返回直方图 */
7
+ export declare function bfsAllHistogram(adj: Array<number>, offsets: Array<number>, n: number): BfsHistogramBatchResult
8
+
6
9
  /**
7
10
  * 从多个源节点并行执行 BFS
8
11
  *
@@ -14,6 +17,9 @@ export declare function bfsAll(adj: Array<number>, offsets: Array<number>, n: nu
14
17
  */
15
18
  export declare function bfsBatch(adj: Array<number>, offsets: Array<number>, n: number, sources: Array<number>): BfsBatchResult
16
19
 
20
+ /** 从多个源节点并行执行 BFS,仅返回距离直方图(节省内存) */
21
+ export declare function bfsBatchHistogram(adj: Array<number>, offsets: Array<number>, n: number, sources: Array<number>): BfsHistogramBatchResult
22
+
17
23
  /** 批量 BFS 结果 */
18
24
  export interface BfsBatchResult {
19
25
  /** 每个源节点的 BFS 结果 */
@@ -22,9 +28,28 @@ export interface BfsBatchResult {
22
28
  processed: number
23
29
  }
24
30
 
31
+ /** 批量直方图结果 */
32
+ export interface BfsHistogramBatchResult {
33
+ /** 每个源节点的直方图结果 */
34
+ results: Array<BfsHistogramResult>
35
+ /** 成功处理的源节点数 */
36
+ processed: number
37
+ }
38
+
39
+ /** 仅直方图结果(不含完整距离数组,节省内存) */
40
+ export interface BfsHistogramResult {
41
+ /** 距离直方图:histogram[d] = 距离为 d 的节点数(不含源节点自身) */
42
+ histogram: Array<number>
43
+ /** 最大有限距离 */
44
+ maxDistance: number
45
+ }
46
+
25
47
  /** 从单个源节点执行 BFS,返回距离数组 */
26
48
  export declare function bfsOne(adj: Array<number>, offsets: Array<number>, n: number, source: number): BfsOneResult
27
49
 
50
+ /** 从单个源节点执行 BFS,仅返回距离直方图(节省内存) */
51
+ export declare function bfsOneHistogram(adj: Array<number>, offsets: Array<number>, n: number, source: number): BfsHistogramResult
52
+
28
53
  /** 单源 BFS 结果 */
29
54
  export interface BfsOneResult {
30
55
  /** 源节点到每个节点的最短距离(-1 表示不可达) */
@@ -43,7 +68,6 @@ export interface BfsOneResult {
43
68
  */
44
69
  export declare function bfsPath(adj: Array<number>, offsets: Array<number>, n: number, source: number, target: number): BfsPathResult
45
70
 
46
- /** 最短路径结果 */
47
71
  export interface BfsPathResult {
48
72
  /** 从 source 到 target 的最短路径节点序列(含两端),不可达时为空数组 */
49
73
  path: Array<number>
package/index.js CHANGED
@@ -588,6 +588,9 @@ if (!nativeBinding) {
588
588
 
589
589
  module.exports = nativeBinding
590
590
  module.exports.bfsAll = nativeBinding.bfsAll
591
+ module.exports.bfsAllHistogram = nativeBinding.bfsAllHistogram
591
592
  module.exports.bfsBatch = nativeBinding.bfsBatch
593
+ module.exports.bfsBatchHistogram = nativeBinding.bfsBatchHistogram
592
594
  module.exports.bfsOne = nativeBinding.bfsOne
595
+ module.exports.bfsOneHistogram = nativeBinding.bfsOneHistogram
593
596
  module.exports.bfsPath = nativeBinding.bfsPath
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xingwangzhe/bfs-rs",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Rust BFS on compressed adjacency list with Rayon parallelism",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",