@graphty/algorithms 1.2.0 → 1.4.2
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 +375 -276
- package/dist/algorithms.d.ts +42 -2
- package/dist/algorithms.js +11402 -2
- package/dist/algorithms.js.map +1 -1
- package/dist/src/algorithms/centrality/betweenness.d.ts +14 -0
- package/dist/src/algorithms/centrality/betweenness.d.ts.map +1 -1
- package/dist/src/algorithms/centrality/betweenness.js +144 -169
- package/dist/src/algorithms/centrality/betweenness.js.map +1 -1
- package/dist/src/algorithms/centrality/closeness.d.ts +35 -1
- package/dist/src/algorithms/centrality/closeness.d.ts.map +1 -1
- package/dist/src/algorithms/centrality/closeness.js +70 -149
- package/dist/src/algorithms/centrality/closeness.js.map +1 -1
- package/dist/src/algorithms/centrality/degree.d.ts +7 -0
- package/dist/src/algorithms/centrality/degree.d.ts.map +1 -1
- package/dist/src/algorithms/centrality/degree.js +12 -9
- package/dist/src/algorithms/centrality/degree.js.map +1 -1
- package/dist/src/algorithms/centrality/delta-pagerank-simple.d.ts +57 -0
- package/dist/src/algorithms/centrality/delta-pagerank-simple.d.ts.map +1 -0
- package/dist/src/algorithms/centrality/delta-pagerank-simple.js +304 -0
- package/dist/src/algorithms/centrality/delta-pagerank-simple.js.map +1 -0
- package/dist/src/algorithms/centrality/delta-pagerank.d.ts +106 -0
- package/dist/src/algorithms/centrality/delta-pagerank.d.ts.map +1 -0
- package/dist/src/algorithms/centrality/delta-pagerank.js +320 -0
- package/dist/src/algorithms/centrality/delta-pagerank.js.map +1 -0
- package/dist/src/algorithms/centrality/eigenvector.d.ts +10 -3
- package/dist/src/algorithms/centrality/eigenvector.d.ts.map +1 -1
- package/dist/src/algorithms/centrality/eigenvector.js +11 -4
- package/dist/src/algorithms/centrality/eigenvector.js.map +1 -1
- package/dist/src/algorithms/centrality/hits.d.ts +10 -3
- package/dist/src/algorithms/centrality/hits.d.ts.map +1 -1
- package/dist/src/algorithms/centrality/hits.js +11 -4
- package/dist/src/algorithms/centrality/hits.js.map +1 -1
- package/dist/src/algorithms/centrality/index.d.ts +3 -1
- package/dist/src/algorithms/centrality/index.d.ts.map +1 -1
- package/dist/src/algorithms/centrality/index.js +2 -1
- package/dist/src/algorithms/centrality/index.js.map +1 -1
- package/dist/src/algorithms/centrality/katz.d.ts +10 -3
- package/dist/src/algorithms/centrality/katz.d.ts.map +1 -1
- package/dist/src/algorithms/centrality/katz.js +13 -8
- package/dist/src/algorithms/centrality/katz.js.map +1 -1
- package/dist/src/algorithms/centrality/pagerank.d.ts +31 -0
- package/dist/src/algorithms/centrality/pagerank.d.ts.map +1 -1
- package/dist/src/algorithms/centrality/pagerank.js +61 -1
- package/dist/src/algorithms/centrality/pagerank.js.map +1 -1
- package/dist/src/algorithms/community/girvan-newman.d.ts +2 -3
- package/dist/src/algorithms/community/girvan-newman.d.ts.map +1 -1
- package/dist/src/algorithms/community/girvan-newman.js +67 -57
- package/dist/src/algorithms/community/girvan-newman.js.map +1 -1
- package/dist/src/algorithms/community/index.d.ts +2 -0
- package/dist/src/algorithms/community/index.d.ts.map +1 -1
- package/dist/src/algorithms/community/index.js.map +1 -1
- package/dist/src/algorithms/community/label-propagation.d.ts +11 -4
- package/dist/src/algorithms/community/label-propagation.d.ts.map +1 -1
- package/dist/src/algorithms/community/label-propagation.js +60 -38
- package/dist/src/algorithms/community/label-propagation.js.map +1 -1
- package/dist/src/algorithms/community/leiden.d.ts +3 -3
- package/dist/src/algorithms/community/leiden.d.ts.map +1 -1
- package/dist/src/algorithms/community/leiden.js +70 -44
- package/dist/src/algorithms/community/leiden.js.map +1 -1
- package/dist/src/algorithms/community/louvain-optimized.d.ts +149 -0
- package/dist/src/algorithms/community/louvain-optimized.d.ts.map +1 -0
- package/dist/src/algorithms/community/louvain-optimized.js +338 -0
- package/dist/src/algorithms/community/louvain-optimized.js.map +1 -0
- package/dist/src/algorithms/community/louvain.d.ts +2 -3
- package/dist/src/algorithms/community/louvain.d.ts.map +1 -1
- package/dist/src/algorithms/community/louvain.js +35 -81
- package/dist/src/algorithms/community/louvain.js.map +1 -1
- package/dist/src/algorithms/community/modularity-utils.d.ts +55 -0
- package/dist/src/algorithms/community/modularity-utils.d.ts.map +1 -0
- package/dist/src/algorithms/community/modularity-utils.js +108 -0
- package/dist/src/algorithms/community/modularity-utils.js.map +1 -0
- package/dist/src/algorithms/components/connected.d.ts +23 -0
- package/dist/src/algorithms/components/connected.d.ts.map +1 -1
- package/dist/src/algorithms/components/connected.js +29 -3
- package/dist/src/algorithms/components/connected.js.map +1 -1
- package/dist/src/algorithms/matching/bipartite.d.ts +10 -0
- package/dist/src/algorithms/matching/bipartite.d.ts.map +1 -1
- package/dist/src/algorithms/matching/bipartite.js +18 -40
- package/dist/src/algorithms/matching/bipartite.js.map +1 -1
- package/dist/src/algorithms/matching/index.d.ts.map +1 -1
- package/dist/src/algorithms/matching/index.js.map +1 -1
- package/dist/src/algorithms/matching/isomorphism.d.ts +8 -0
- package/dist/src/algorithms/matching/isomorphism.d.ts.map +1 -1
- package/dist/src/algorithms/matching/isomorphism.js +36 -2
- package/dist/src/algorithms/matching/isomorphism.js.map +1 -1
- package/dist/src/algorithms/mst/index.d.ts.map +1 -1
- package/dist/src/algorithms/mst/index.js.map +1 -1
- package/dist/src/algorithms/mst/kruskal.d.ts +14 -0
- package/dist/src/algorithms/mst/kruskal.d.ts.map +1 -1
- package/dist/src/algorithms/mst/kruskal.js +17 -3
- package/dist/src/algorithms/mst/kruskal.js.map +1 -1
- package/dist/src/algorithms/mst/prim.d.ts +9 -0
- package/dist/src/algorithms/mst/prim.d.ts.map +1 -1
- package/dist/src/algorithms/mst/prim.js +9 -0
- package/dist/src/algorithms/mst/prim.js.map +1 -1
- package/dist/src/algorithms/shortest-path/bellman-ford.d.ts +10 -0
- package/dist/src/algorithms/shortest-path/bellman-ford.d.ts.map +1 -1
- package/dist/src/algorithms/shortest-path/bellman-ford.js +11 -12
- package/dist/src/algorithms/shortest-path/bellman-ford.js.map +1 -1
- package/dist/src/algorithms/shortest-path/bidirectional-dijkstra.d.ts +44 -0
- package/dist/src/algorithms/shortest-path/bidirectional-dijkstra.d.ts.map +1 -0
- package/dist/src/algorithms/shortest-path/bidirectional-dijkstra.js +195 -0
- package/dist/src/algorithms/shortest-path/bidirectional-dijkstra.js.map +1 -0
- package/dist/src/algorithms/shortest-path/dijkstra.d.ts +20 -2
- package/dist/src/algorithms/shortest-path/dijkstra.d.ts.map +1 -1
- package/dist/src/algorithms/shortest-path/dijkstra.js +30 -14
- package/dist/src/algorithms/shortest-path/dijkstra.js.map +1 -1
- package/dist/src/algorithms/shortest-path/floyd-warshall.d.ts +17 -0
- package/dist/src/algorithms/shortest-path/floyd-warshall.d.ts.map +1 -1
- package/dist/src/algorithms/shortest-path/floyd-warshall.js +17 -0
- package/dist/src/algorithms/shortest-path/floyd-warshall.js.map +1 -1
- package/dist/src/algorithms/shortest-path/index.d.ts.map +1 -1
- package/dist/src/algorithms/shortest-path/index.js.map +1 -1
- package/dist/src/algorithms/traversal/bfs-unified.d.ts +42 -0
- package/dist/src/algorithms/traversal/bfs-unified.d.ts.map +1 -0
- package/dist/src/algorithms/traversal/bfs-unified.js +370 -0
- package/dist/src/algorithms/traversal/bfs-unified.js.map +1 -0
- package/dist/src/algorithms/traversal/bfs-variants.d.ts +77 -0
- package/dist/src/algorithms/traversal/bfs-variants.d.ts.map +1 -0
- package/dist/src/algorithms/traversal/bfs-variants.js +402 -0
- package/dist/src/algorithms/traversal/bfs-variants.js.map +1 -0
- package/dist/src/algorithms/traversal/bfs.d.ts +4 -18
- package/dist/src/algorithms/traversal/bfs.d.ts.map +1 -1
- package/dist/src/algorithms/traversal/bfs.js +5 -182
- package/dist/src/algorithms/traversal/bfs.js.map +1 -1
- package/dist/src/algorithms/traversal/dfs.d.ts +10 -0
- package/dist/src/algorithms/traversal/dfs.d.ts.map +1 -1
- package/dist/src/algorithms/traversal/dfs.js +48 -0
- package/dist/src/algorithms/traversal/dfs.js.map +1 -1
- package/dist/src/algorithms/traversal/index.d.ts.map +1 -1
- package/dist/src/algorithms/traversal/index.js.map +1 -1
- package/dist/src/benchmark-all-algorithms.d.ts +25 -0
- package/dist/src/benchmark-all-algorithms.d.ts.map +1 -0
- package/dist/src/benchmark-all-algorithms.js +491 -0
- package/dist/src/benchmark-all-algorithms.js.map +1 -0
- package/dist/src/clustering/hierarchical.d.ts +23 -15
- package/dist/src/clustering/hierarchical.d.ts.map +1 -1
- package/dist/src/clustering/hierarchical.js +226 -224
- package/dist/src/clustering/hierarchical.js.map +1 -1
- package/dist/src/clustering/index.d.ts +4 -2
- package/dist/src/clustering/index.d.ts.map +1 -1
- package/dist/src/clustering/index.js +2 -2
- package/dist/src/clustering/index.js.map +1 -1
- package/dist/src/clustering/k-core.d.ts +17 -19
- package/dist/src/clustering/k-core.d.ts.map +1 -1
- package/dist/src/clustering/k-core.js +68 -30
- package/dist/src/clustering/k-core.js.map +1 -1
- package/dist/src/clustering/mcl.d.ts +6 -0
- package/dist/src/clustering/mcl.d.ts.map +1 -1
- package/dist/src/clustering/mcl.js +34 -3
- package/dist/src/clustering/mcl.js.map +1 -1
- package/dist/src/clustering/spectral.d.ts +11 -0
- package/dist/src/clustering/spectral.d.ts.map +1 -1
- package/dist/src/clustering/spectral.js +99 -47
- package/dist/src/clustering/spectral.js.map +1 -1
- package/dist/src/core/graph.d.ts +45 -0
- package/dist/src/core/graph.d.ts.map +1 -1
- package/dist/src/core/graph.js +49 -5
- package/dist/src/core/graph.js.map +1 -1
- package/dist/src/data-structures/index.d.ts.map +1 -1
- package/dist/src/data-structures/index.js.map +1 -1
- package/dist/src/data-structures/priority-queue.d.ts +18 -1
- package/dist/src/data-structures/priority-queue.d.ts.map +1 -1
- package/dist/src/data-structures/priority-queue.js +26 -5
- package/dist/src/data-structures/priority-queue.js.map +1 -1
- package/dist/src/data-structures/union-find.d.ts +21 -0
- package/dist/src/data-structures/union-find.d.ts.map +1 -1
- package/dist/src/data-structures/union-find.js +21 -0
- package/dist/src/data-structures/union-find.js.map +1 -1
- package/dist/src/flow/ford-fulkerson.d.ts +20 -12
- package/dist/src/flow/ford-fulkerson.d.ts.map +1 -1
- package/dist/src/flow/ford-fulkerson.js +170 -217
- package/dist/src/flow/ford-fulkerson.js.map +1 -1
- package/dist/src/flow/min-cut.d.ts +6 -8
- package/dist/src/flow/min-cut.d.ts.map +1 -1
- package/dist/src/flow/min-cut.js +34 -12
- package/dist/src/flow/min-cut.js.map +1 -1
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +6 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/link-prediction/adamic-adar.d.ts +26 -0
- package/dist/src/link-prediction/adamic-adar.d.ts.map +1 -1
- package/dist/src/link-prediction/adamic-adar.js +47 -30
- package/dist/src/link-prediction/adamic-adar.js.map +1 -1
- package/dist/src/link-prediction/common-neighbors.d.ts +21 -0
- package/dist/src/link-prediction/common-neighbors.d.ts.map +1 -1
- package/dist/src/link-prediction/common-neighbors.js +31 -14
- package/dist/src/link-prediction/common-neighbors.js.map +1 -1
- package/dist/src/link-prediction/index.d.ts.map +1 -1
- package/dist/src/optimized/bit-packed.d.ts +193 -0
- package/dist/src/optimized/bit-packed.d.ts.map +1 -0
- package/dist/src/optimized/bit-packed.js +342 -0
- package/dist/src/optimized/bit-packed.js.map +1 -0
- package/dist/src/optimized/csr-graph.d.ts +149 -0
- package/dist/src/optimized/csr-graph.d.ts.map +1 -0
- package/dist/src/optimized/csr-graph.js +404 -0
- package/dist/src/optimized/csr-graph.js.map +1 -0
- package/dist/src/optimized/direction-optimized-bfs.d.ts +95 -0
- package/dist/src/optimized/direction-optimized-bfs.d.ts.map +1 -0
- package/dist/src/optimized/direction-optimized-bfs.js +242 -0
- package/dist/src/optimized/direction-optimized-bfs.js.map +1 -0
- package/dist/src/optimized/graph-adapter.d.ts +111 -0
- package/dist/src/optimized/graph-adapter.d.ts.map +1 -0
- package/dist/src/optimized/graph-adapter.js +194 -0
- package/dist/src/optimized/graph-adapter.js.map +1 -0
- package/dist/src/optimized/index.d.ts +14 -0
- package/dist/src/optimized/index.d.ts.map +1 -0
- package/dist/src/optimized/index.js +30 -0
- package/dist/src/optimized/index.js.map +1 -0
- package/dist/src/pathfinding/astar.d.ts +25 -9
- package/dist/src/pathfinding/astar.d.ts.map +1 -1
- package/dist/src/pathfinding/astar.js +25 -10
- package/dist/src/pathfinding/astar.js.map +1 -1
- package/dist/src/pathfinding/utils.d.ts +15 -6
- package/dist/src/pathfinding/utils.d.ts.map +1 -1
- package/dist/src/pathfinding/utils.js +19 -7
- package/dist/src/pathfinding/utils.js.map +1 -1
- package/dist/src/research/grsbm.d.ts +0 -1
- package/dist/src/research/grsbm.d.ts.map +1 -1
- package/dist/src/research/grsbm.js +28 -23
- package/dist/src/research/grsbm.js.map +1 -1
- package/dist/src/research/index.d.ts.map +1 -1
- package/dist/src/research/index.js.map +1 -1
- package/dist/src/research/sync.d.ts +0 -1
- package/dist/src/research/sync.d.ts.map +1 -1
- package/dist/src/research/sync.js +31 -36
- package/dist/src/research/sync.js.map +1 -1
- package/dist/src/research/terahac.d.ts +2 -1
- package/dist/src/research/terahac.d.ts.map +1 -1
- package/dist/src/research/terahac.js +39 -7
- package/dist/src/research/terahac.js.map +1 -1
- package/dist/src/types/index.d.ts +8 -0
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/utils/algorithm-utilities.d.ts +2 -0
- package/dist/src/utils/algorithm-utilities.d.ts.map +1 -0
- package/dist/src/utils/algorithm-utilities.js +2 -0
- package/dist/src/utils/algorithm-utilities.js.map +1 -0
- package/dist/src/utils/graph-converters.d.ts +110 -0
- package/dist/src/utils/graph-converters.d.ts.map +1 -0
- package/dist/src/utils/graph-converters.js +227 -0
- package/dist/src/utils/graph-converters.js.map +1 -0
- package/dist/src/utils/graph-utilities.d.ts +62 -0
- package/dist/src/utils/graph-utilities.d.ts.map +1 -0
- package/dist/src/utils/graph-utilities.js +148 -0
- package/dist/src/utils/graph-utilities.js.map +1 -0
- package/dist/src/utils/index.d.ts +5 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/utils/index.js +5 -0
- package/dist/src/utils/index.js.map +1 -0
- package/dist/src/utils/math-utilities.d.ts +63 -0
- package/dist/src/utils/math-utilities.d.ts.map +1 -0
- package/dist/src/utils/math-utilities.js +132 -0
- package/dist/src/utils/math-utilities.js.map +1 -0
- package/dist/src/utils/matrix-utilities.d.ts +2 -0
- package/dist/src/utils/matrix-utilities.d.ts.map +1 -0
- package/dist/src/utils/matrix-utilities.js +2 -0
- package/dist/src/utils/matrix-utilities.js.map +1 -0
- package/dist/src/utils/optimization-helpers.d.ts +42 -0
- package/dist/src/utils/optimization-helpers.d.ts.map +1 -0
- package/dist/src/utils/optimization-helpers.js +59 -0
- package/dist/src/utils/optimization-helpers.js.map +1 -0
- package/dist/src/utils/priorityQueue.d.ts +24 -0
- package/dist/src/utils/priorityQueue.d.ts.map +1 -1
- package/dist/src/utils/priorityQueue.js +34 -4
- package/dist/src/utils/priorityQueue.js.map +1 -1
- package/package.json +58 -39
- package/src/algorithms/centrality/betweenness.ts +185 -200
- package/src/algorithms/centrality/closeness.ts +93 -194
- package/src/algorithms/centrality/degree.ts +18 -22
- package/src/algorithms/centrality/delta-pagerank-simple.ts +374 -0
- package/src/algorithms/centrality/delta-pagerank.ts +458 -0
- package/src/algorithms/centrality/eigenvector.ts +14 -15
- package/src/algorithms/centrality/hits.ts +17 -17
- package/src/algorithms/centrality/index.ts +20 -13
- package/src/algorithms/centrality/katz.ts +17 -25
- package/src/algorithms/centrality/pagerank.ts +91 -16
- package/src/algorithms/community/girvan-newman.ts +90 -86
- package/src/algorithms/community/index.ts +6 -5
- package/src/algorithms/community/label-propagation.ts +69 -48
- package/src/algorithms/community/leiden.ts +88 -65
- package/src/algorithms/community/louvain-optimized.ts +474 -0
- package/src/algorithms/community/louvain.ts +52 -122
- package/src/algorithms/community/modularity-utils.ts +134 -0
- package/src/algorithms/components/connected.ts +40 -17
- package/src/algorithms/matching/bipartite.ts +24 -53
- package/src/algorithms/matching/index.ts +4 -4
- package/src/algorithms/matching/isomorphism.ts +53 -23
- package/src/algorithms/mst/index.ts +3 -4
- package/src/algorithms/mst/kruskal.ts +21 -6
- package/src/algorithms/mst/prim.ts +13 -4
- package/src/algorithms/shortest-path/bellman-ford.ts +16 -28
- package/src/algorithms/shortest-path/bidirectional-dijkstra.ts +248 -0
- package/src/algorithms/shortest-path/dijkstra.ts +38 -30
- package/src/algorithms/shortest-path/floyd-warshall.ts +21 -4
- package/src/algorithms/shortest-path/index.ts +5 -5
- package/src/algorithms/traversal/bfs-unified.ts +437 -0
- package/src/algorithms/traversal/bfs-variants.ts +520 -0
- package/src/algorithms/traversal/bfs.ts +5 -229
- package/src/algorithms/traversal/dfs.ts +61 -42
- package/src/algorithms/traversal/index.ts +3 -3
- package/src/benchmark-all-algorithms.ts +580 -0
- package/src/clustering/hierarchical.ts +268 -272
- package/src/clustering/index.ts +8 -6
- package/src/clustering/k-core.ts +93 -61
- package/src/clustering/mcl.ts +53 -23
- package/src/clustering/spectral.ts +130 -72
- package/src/core/graph.ts +58 -18
- package/src/data-structures/index.ts +2 -2
- package/src/data-structures/priority-queue.ts +36 -11
- package/src/data-structures/union-find.ts +22 -1
- package/src/flow/ford-fulkerson.ts +221 -262
- package/src/flow/min-cut.ts +59 -51
- package/src/index.ts +9 -2
- package/src/link-prediction/adamic-adar.ts +75 -74
- package/src/link-prediction/common-neighbors.ts +49 -49
- package/src/link-prediction/index.ts +1 -1
- package/src/optimized/bit-packed.ts +390 -0
- package/src/optimized/csr-graph.ts +518 -0
- package/src/optimized/direction-optimized-bfs.ts +310 -0
- package/src/optimized/graph-adapter.ts +248 -0
- package/src/optimized/index.ts +34 -0
- package/src/pathfinding/astar.ts +40 -25
- package/src/pathfinding/utils.ts +20 -13
- package/src/research/grsbm.ts +36 -39
- package/src/research/index.ts +4 -4
- package/src/research/sync.ts +41 -54
- package/src/research/terahac.ts +63 -21
- package/src/types/index.ts +8 -0
- package/src/utils/algorithm-utilities.ts +2 -0
- package/src/utils/graph-converters.ts +269 -0
- package/src/utils/graph-utilities.ts +173 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/math-utilities.ts +149 -0
- package/src/utils/matrix-utilities.ts +2 -0
- package/src/utils/optimization-helpers.ts +87 -0
- package/src/utils/priorityQueue.ts +40 -6
|
@@ -1,28 +1,32 @@
|
|
|
1
|
+
import { getCommonNeighbors, getIntermediateNodes } from "../utils/graph-utilities.js";
|
|
1
2
|
/**
|
|
2
3
|
* Calculate common neighbors score for a pair of nodes
|
|
4
|
+
* @param graph - The input graph
|
|
5
|
+
* @param source - The source node ID
|
|
6
|
+
* @param target - The target node ID
|
|
7
|
+
* @param options - Link prediction options
|
|
8
|
+
* @returns The number of common neighbors
|
|
3
9
|
*/
|
|
4
10
|
export function commonNeighborsScore(graph, source, target, options = {}) {
|
|
5
11
|
if (!graph.hasNode(source) || !graph.hasNode(target)) {
|
|
6
12
|
return 0;
|
|
7
13
|
}
|
|
8
14
|
const { directed = false } = options;
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (targetNeighbors.has(neighbor)) {
|
|
16
|
-
commonCount++;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return commonCount;
|
|
15
|
+
// Use utility function to get common neighbors
|
|
16
|
+
// For directed graphs, we want intermediate nodes that form paths source->X->target
|
|
17
|
+
const commonNeighborsSet = directed
|
|
18
|
+
? getIntermediateNodes(graph, source, target)
|
|
19
|
+
: getCommonNeighbors(graph, source, target, false);
|
|
20
|
+
return commonNeighborsSet.size;
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
22
23
|
* Calculate common neighbors scores for all possible node pairs
|
|
24
|
+
* @param graph - The input graph
|
|
25
|
+
* @param options - Link prediction options
|
|
26
|
+
* @returns Array of link prediction scores sorted by score descending
|
|
23
27
|
*/
|
|
24
28
|
export function commonNeighborsPrediction(graph, options = {}) {
|
|
25
|
-
const { directed = false, includeExisting = false, topK
|
|
29
|
+
const { directed = false, includeExisting = false, topK } = options;
|
|
26
30
|
const scores = [];
|
|
27
31
|
const nodes = Array.from(graph.nodes()).map((n) => n.id);
|
|
28
32
|
for (let i = 0; i < nodes.length; i++) {
|
|
@@ -56,6 +60,10 @@ export function commonNeighborsPrediction(graph, options = {}) {
|
|
|
56
60
|
}
|
|
57
61
|
/**
|
|
58
62
|
* Calculate common neighbors scores for specific node pairs
|
|
63
|
+
* @param graph - The input graph
|
|
64
|
+
* @param pairs - Array of node ID pairs to calculate scores for
|
|
65
|
+
* @param options - Link prediction options
|
|
66
|
+
* @returns Array of link prediction scores for the specified pairs
|
|
59
67
|
*/
|
|
60
68
|
export function commonNeighborsForPairs(graph, pairs, options = {}) {
|
|
61
69
|
return pairs.map(([source, target]) => ({
|
|
@@ -66,12 +74,16 @@ export function commonNeighborsForPairs(graph, pairs, options = {}) {
|
|
|
66
74
|
}
|
|
67
75
|
/**
|
|
68
76
|
* Get top candidates for link prediction for a specific node
|
|
77
|
+
* @param graph - The input graph
|
|
78
|
+
* @param node - The node ID to get candidates for
|
|
79
|
+
* @param options - Link prediction options with optional candidate list
|
|
80
|
+
* @returns Array of top link prediction candidates sorted by score descending
|
|
69
81
|
*/
|
|
70
82
|
export function getTopCandidatesForNode(graph, node, options = {}) {
|
|
71
83
|
if (!graph.hasNode(node)) {
|
|
72
84
|
return [];
|
|
73
85
|
}
|
|
74
|
-
const { directed = false, includeExisting = false, topK = 10, candidates
|
|
86
|
+
const { directed = false, includeExisting = false, topK = 10, candidates } = options;
|
|
75
87
|
const scores = [];
|
|
76
88
|
const targetNodes = candidates ?? Array.from(graph.nodes()).map((n) => n.id);
|
|
77
89
|
for (const target of targetNodes) {
|
|
@@ -93,6 +105,11 @@ export function getTopCandidatesForNode(graph, node, options = {}) {
|
|
|
93
105
|
}
|
|
94
106
|
/**
|
|
95
107
|
* Calculate precision and recall for link prediction evaluation
|
|
108
|
+
* @param trainingGraph - The training graph without test edges
|
|
109
|
+
* @param testEdges - Array of node pairs that are actual edges
|
|
110
|
+
* @param nonEdges - Array of node pairs that are not edges
|
|
111
|
+
* @param options - Link prediction options
|
|
112
|
+
* @returns Evaluation metrics including precision, recall, F1 score, and AUC
|
|
96
113
|
*/
|
|
97
114
|
export function evaluateCommonNeighbors(trainingGraph, testEdges, nonEdges, options = {}) {
|
|
98
115
|
// Get scores for test edges and non-edges
|
|
@@ -119,7 +136,7 @@ export function evaluateCommonNeighbors(trainingGraph, testEdges, nonEdges, opti
|
|
|
119
136
|
}
|
|
120
137
|
const precision = truePositives / (truePositives + falsePositives);
|
|
121
138
|
const recall = truePositives / totalPositives;
|
|
122
|
-
const f1 = precision + recall > 0 ? 2 * (precision * recall) / (precision + recall) : 0;
|
|
139
|
+
const f1 = precision + recall > 0 ? (2 * (precision * recall)) / (precision + recall) : 0;
|
|
123
140
|
if (f1 > bestF1) {
|
|
124
141
|
bestF1 = f1;
|
|
125
142
|
bestPrecision = precision;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common-neighbors.js","sourceRoot":"","sources":["../../../src/link-prediction/common-neighbors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"common-neighbors.js","sourceRoot":"","sources":["../../../src/link-prediction/common-neighbors.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAyBvF;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAChC,KAAY,EACZ,MAAc,EACd,MAAc,EACd,UAAiC,EAAE;IAEnC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACnD,OAAO,CAAC,CAAC;IACb,CAAC;IAED,MAAM,EAAE,QAAQ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CAAC,CAAC,GAAG,CAAC,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAE1F,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC;YACd,MAAM,GAAG,EAAE,CAAC;YACZ,aAAa,GAAG,SAAS,CAAC;YAC1B,UAAU,GAAG,MAAM,CAAC;QACxB,CAAC;IACL,CAAC;IAED,mCAAmC;IACnC,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,OAAO,GAAG,CAAC,CAAC;IAEhB,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;QAC3B,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,OAAO,EAAE,CAAC;QACd,CAAC;aAAM,CAAC;YACJ,GAAG,IAAI,OAAO,CAAC;YACf,OAAO,EAAE,CAAC;QACd,CAAC;IACL,CAAC;IAED,IAAI,OAAO,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;QAC7B,GAAG,GAAG,GAAG,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC,CAAC;IACpC,CAAC;SAAM,CAAC;QACJ,GAAG,GAAG,GAAG,CAAC,CAAC,qBAAqB;IACpC,CAAC;IAED,OAAO;QACH,SAAS,EAAE,aAAa;QACxB,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,MAAM;QACf,GAAG;KACN,CAAC;AACN,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/link-prediction/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACH,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,oCAAoC,EACpC,kBAAkB,EAClB,iCAAiC,GACpC,MAAM,kBAAkB,CAAC;AAC1B,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/link-prediction/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACH,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,oCAAoC,EACpC,kBAAkB,EAClB,iCAAiC,GACpC,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACxF,OAAO,EACH,uBAAuB,EACvB,yBAAyB,EACzB,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,GAC1B,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrapper around TypedFastBitSet with graph-specific optimizations
|
|
3
|
+
*
|
|
4
|
+
* Provides efficient bit-packed set operations optimized for graph algorithms
|
|
5
|
+
* with 8x memory reduction compared to standard JavaScript Set for boolean values.
|
|
6
|
+
*/
|
|
7
|
+
export declare class GraphBitSet {
|
|
8
|
+
private bitset;
|
|
9
|
+
private _cardinality;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new GraphBitSet with optional pre-allocated capacity.
|
|
12
|
+
* @param capacity - The initial capacity to pre-allocate for the bitset
|
|
13
|
+
*/
|
|
14
|
+
constructor(capacity?: number);
|
|
15
|
+
/**
|
|
16
|
+
* Add a single element to the set.
|
|
17
|
+
* @param index - The element index to add
|
|
18
|
+
*/
|
|
19
|
+
add(index: number): void;
|
|
20
|
+
/**
|
|
21
|
+
* Remove a single element from the set.
|
|
22
|
+
* @param index - The element index to remove
|
|
23
|
+
*/
|
|
24
|
+
remove(index: number): void;
|
|
25
|
+
/**
|
|
26
|
+
* Check if an element exists in the set.
|
|
27
|
+
* @param index - The element index to check
|
|
28
|
+
* @returns True if the element exists, false otherwise
|
|
29
|
+
*/
|
|
30
|
+
has(index: number): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Clear all elements
|
|
33
|
+
*/
|
|
34
|
+
clear(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Check if the set is empty.
|
|
37
|
+
* @returns True if the set contains no elements, false otherwise
|
|
38
|
+
*/
|
|
39
|
+
isEmpty(): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Optimized for graph algorithms - add a range of indices.
|
|
42
|
+
* @param start - The starting index (inclusive)
|
|
43
|
+
* @param end - The ending index (exclusive)
|
|
44
|
+
*/
|
|
45
|
+
addRange(start: number, end: number): void;
|
|
46
|
+
/**
|
|
47
|
+
* Fast cardinality tracking - get the number of elements in the set.
|
|
48
|
+
* @returns The number of elements in the set
|
|
49
|
+
*/
|
|
50
|
+
size(): number;
|
|
51
|
+
/**
|
|
52
|
+
* Batch operations for frontier management - swap contents with another GraphBitSet.
|
|
53
|
+
* @param other - The GraphBitSet to swap contents with
|
|
54
|
+
*/
|
|
55
|
+
swap(other: GraphBitSet): void;
|
|
56
|
+
/**
|
|
57
|
+
* Efficient iteration over all elements in the set.
|
|
58
|
+
* @yields The indices of elements in the set
|
|
59
|
+
*/
|
|
60
|
+
[Symbol.iterator](): Generator<number>;
|
|
61
|
+
/**
|
|
62
|
+
* Perform union operation with another GraphBitSet, updating this set in place.
|
|
63
|
+
* @param other - The GraphBitSet to union with
|
|
64
|
+
*/
|
|
65
|
+
union(other: GraphBitSet): void;
|
|
66
|
+
/**
|
|
67
|
+
* Perform intersection operation with another GraphBitSet, updating this set in place.
|
|
68
|
+
* @param other - The GraphBitSet to intersect with
|
|
69
|
+
*/
|
|
70
|
+
intersection(other: GraphBitSet): void;
|
|
71
|
+
/**
|
|
72
|
+
* Perform difference operation with another GraphBitSet, updating this set in place.
|
|
73
|
+
* @param other - The GraphBitSet to subtract from this set
|
|
74
|
+
*/
|
|
75
|
+
difference(other: GraphBitSet): void;
|
|
76
|
+
/**
|
|
77
|
+
* Clone the bitset.
|
|
78
|
+
* @returns A new GraphBitSet with the same elements
|
|
79
|
+
*/
|
|
80
|
+
clone(): GraphBitSet;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Specialized bit array for visited tracking
|
|
84
|
+
*
|
|
85
|
+
* More memory efficient than GraphBitSet for simple boolean arrays
|
|
86
|
+
* that don't need set operations.
|
|
87
|
+
*/
|
|
88
|
+
export declare class VisitedBitArray {
|
|
89
|
+
private words;
|
|
90
|
+
private wordCount;
|
|
91
|
+
private _size;
|
|
92
|
+
/**
|
|
93
|
+
* Creates a new VisitedBitArray with the specified size.
|
|
94
|
+
* @param size - The number of bits to allocate
|
|
95
|
+
*/
|
|
96
|
+
constructor(size: number);
|
|
97
|
+
/**
|
|
98
|
+
* Set bit at the specified index.
|
|
99
|
+
* @param index - The bit index to set
|
|
100
|
+
*/
|
|
101
|
+
set(index: number): void;
|
|
102
|
+
/**
|
|
103
|
+
* Get bit value at the specified index.
|
|
104
|
+
* @param index - The bit index to get
|
|
105
|
+
* @returns True if the bit is set, false otherwise
|
|
106
|
+
*/
|
|
107
|
+
get(index: number): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Clear all bits
|
|
110
|
+
*/
|
|
111
|
+
clear(): void;
|
|
112
|
+
/**
|
|
113
|
+
* Toggle bit at the specified index.
|
|
114
|
+
* @param index - The bit index to toggle
|
|
115
|
+
*/
|
|
116
|
+
toggle(index: number): void;
|
|
117
|
+
/**
|
|
118
|
+
* Population count for statistics - count the number of set bits.
|
|
119
|
+
* @returns The number of bits set to 1
|
|
120
|
+
*/
|
|
121
|
+
popcount(): number;
|
|
122
|
+
/**
|
|
123
|
+
* Efficient population count for a single word.
|
|
124
|
+
* Uses bit manipulation tricks for fast counting.
|
|
125
|
+
* @param n - The 32-bit word to count
|
|
126
|
+
* @returns The number of bits set to 1 in the word
|
|
127
|
+
*/
|
|
128
|
+
private popcountWord;
|
|
129
|
+
/**
|
|
130
|
+
* Get size of the bit array.
|
|
131
|
+
* @returns The total number of bits in the array
|
|
132
|
+
*/
|
|
133
|
+
size(): number;
|
|
134
|
+
/**
|
|
135
|
+
* Check if all bits are zero.
|
|
136
|
+
* @returns True if no bits are set, false otherwise
|
|
137
|
+
*/
|
|
138
|
+
isEmpty(): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Set multiple bits from an array of indices.
|
|
141
|
+
* @param indices - Array of bit indices to set
|
|
142
|
+
*/
|
|
143
|
+
setMultiple(indices: number[]): void;
|
|
144
|
+
/**
|
|
145
|
+
* Get indices of all set bits.
|
|
146
|
+
* @returns Array containing the indices of all bits that are set to 1
|
|
147
|
+
*/
|
|
148
|
+
getSetIndices(): number[];
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Bit-packed distance array for BFS
|
|
152
|
+
*
|
|
153
|
+
* Optimized for storing distances using 16-bit integers (up to 65,535 levels)
|
|
154
|
+
* Still provides 2x memory savings compared to standard 32-bit numbers
|
|
155
|
+
*/
|
|
156
|
+
export declare class CompactDistanceArray {
|
|
157
|
+
private data;
|
|
158
|
+
private _size;
|
|
159
|
+
private static readonly INFINITY;
|
|
160
|
+
/**
|
|
161
|
+
* Creates a new CompactDistanceArray with the specified size.
|
|
162
|
+
* @param size - The number of distance values to store
|
|
163
|
+
*/
|
|
164
|
+
constructor(size: number);
|
|
165
|
+
/**
|
|
166
|
+
* Set distance at the specified index.
|
|
167
|
+
* @param index - The node index to set the distance for
|
|
168
|
+
* @param distance - The distance value to set
|
|
169
|
+
*/
|
|
170
|
+
set(index: number, distance: number): void;
|
|
171
|
+
/**
|
|
172
|
+
* Get distance at the specified index.
|
|
173
|
+
* @param index - The node index to get the distance for
|
|
174
|
+
* @returns The distance value, or INFINITY if not set
|
|
175
|
+
*/
|
|
176
|
+
get(index: number): number;
|
|
177
|
+
/**
|
|
178
|
+
* Check if a node has been visited (has a valid distance).
|
|
179
|
+
* @param index - The node index to check
|
|
180
|
+
* @returns True if the node has been visited, false otherwise
|
|
181
|
+
*/
|
|
182
|
+
isVisited(index: number): boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Reset all distances to unvisited state.
|
|
185
|
+
*/
|
|
186
|
+
clear(): void;
|
|
187
|
+
/**
|
|
188
|
+
* Get the size of the distance array.
|
|
189
|
+
* @returns The number of elements in the array
|
|
190
|
+
*/
|
|
191
|
+
size(): number;
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=bit-packed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bit-packed.d.ts","sourceRoot":"","sources":["../../../src/optimized/bit-packed.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,qBAAa,WAAW;IACpB,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,YAAY,CAAK;IAEzB;;;OAGG;gBACS,QAAQ,CAAC,EAAE,MAAM;IAQ7B;;;OAGG;IACH,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAOxB;;;OAGG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAO3B;;;;OAIG;IACH,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAI3B;;OAEG;IACH,KAAK,IAAI,IAAI;IAKb;;;OAGG;IACH,OAAO,IAAI,OAAO;IAIlB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;IAS1C;;;OAGG;IACH,IAAI,IAAI,MAAM;IAId;;;OAGG;IACH,IAAI,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAK9B;;;OAGG;IACF,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,SAAS,CAAC,MAAM,CAAC;IAKvC;;;OAGG;IACH,KAAK,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAQ/B;;;OAGG;IACH,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAQtC;;;OAGG;IACH,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAQpC;;;OAGG;IACH,KAAK,IAAI,WAAW;CAOvB;AAED;;;;;GAKG;AACH,qBAAa,eAAe;IACxB,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,KAAK,CAAS;IAEtB;;;OAGG;gBACS,IAAI,EAAE,MAAM;IAMxB;;;OAGG;IACH,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAaxB;;;;OAIG;IACH,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAW3B;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;;OAGG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAa3B;;;OAGG;IACH,QAAQ,IAAI,MAAM;IAWlB;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAOpB;;;OAGG;IACH,IAAI,IAAI,MAAM;IAId;;;OAGG;IACH,OAAO,IAAI,OAAO;IASlB;;;OAGG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAMpC;;;OAGG;IACH,aAAa,IAAI,MAAM,EAAE;CAmB5B;AAED;;;;;GAKG;AACH,qBAAa,oBAAoB;IAC7B,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAEzC;;;OAGG;gBACS,IAAI,EAAE,MAAM;IAMxB;;;;OAIG;IACH,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAQ1C;;;;OAIG;IACH,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAK1B;;;;OAIG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIjC;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;;OAGG;IACH,IAAI,IAAI,MAAM;CAGjB"}
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import { TypedFastBitSet } from "typedfastbitset";
|
|
2
|
+
/**
|
|
3
|
+
* Wrapper around TypedFastBitSet with graph-specific optimizations
|
|
4
|
+
*
|
|
5
|
+
* Provides efficient bit-packed set operations optimized for graph algorithms
|
|
6
|
+
* with 8x memory reduction compared to standard JavaScript Set for boolean values.
|
|
7
|
+
*/
|
|
8
|
+
export class GraphBitSet {
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new GraphBitSet with optional pre-allocated capacity.
|
|
11
|
+
* @param capacity - The initial capacity to pre-allocate for the bitset
|
|
12
|
+
*/
|
|
13
|
+
constructor(capacity) {
|
|
14
|
+
this._cardinality = 0;
|
|
15
|
+
this.bitset = new TypedFastBitSet();
|
|
16
|
+
if (capacity) {
|
|
17
|
+
// Pre-allocate for known size
|
|
18
|
+
this.bitset.resize(capacity);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Add a single element to the set.
|
|
23
|
+
* @param index - The element index to add
|
|
24
|
+
*/
|
|
25
|
+
add(index) {
|
|
26
|
+
if (!this.bitset.has(index)) {
|
|
27
|
+
this.bitset.add(index);
|
|
28
|
+
this._cardinality++;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Remove a single element from the set.
|
|
33
|
+
* @param index - The element index to remove
|
|
34
|
+
*/
|
|
35
|
+
remove(index) {
|
|
36
|
+
if (this.bitset.has(index)) {
|
|
37
|
+
this.bitset.remove(index);
|
|
38
|
+
this._cardinality--;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Check if an element exists in the set.
|
|
43
|
+
* @param index - The element index to check
|
|
44
|
+
* @returns True if the element exists, false otherwise
|
|
45
|
+
*/
|
|
46
|
+
has(index) {
|
|
47
|
+
return this.bitset.has(index);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Clear all elements
|
|
51
|
+
*/
|
|
52
|
+
clear() {
|
|
53
|
+
this.bitset.clear();
|
|
54
|
+
this._cardinality = 0;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Check if the set is empty.
|
|
58
|
+
* @returns True if the set contains no elements, false otherwise
|
|
59
|
+
*/
|
|
60
|
+
isEmpty() {
|
|
61
|
+
return this._cardinality === 0;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Optimized for graph algorithms - add a range of indices.
|
|
65
|
+
* @param start - The starting index (inclusive)
|
|
66
|
+
* @param end - The ending index (exclusive)
|
|
67
|
+
*/
|
|
68
|
+
addRange(start, end) {
|
|
69
|
+
for (let i = start; i < end; i++) {
|
|
70
|
+
if (!this.bitset.has(i)) {
|
|
71
|
+
this.bitset.add(i);
|
|
72
|
+
this._cardinality++;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Fast cardinality tracking - get the number of elements in the set.
|
|
78
|
+
* @returns The number of elements in the set
|
|
79
|
+
*/
|
|
80
|
+
size() {
|
|
81
|
+
return this._cardinality;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Batch operations for frontier management - swap contents with another GraphBitSet.
|
|
85
|
+
* @param other - The GraphBitSet to swap contents with
|
|
86
|
+
*/
|
|
87
|
+
swap(other) {
|
|
88
|
+
[this.bitset, other.bitset] = [other.bitset, this.bitset];
|
|
89
|
+
[this._cardinality, other._cardinality] = [other._cardinality, this._cardinality];
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Efficient iteration over all elements in the set.
|
|
93
|
+
* @yields The indices of elements in the set
|
|
94
|
+
*/
|
|
95
|
+
*[Symbol.iterator]() {
|
|
96
|
+
// Use TypedFastBitSet's optimized iteration
|
|
97
|
+
yield* this.bitset;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Perform union operation with another GraphBitSet, updating this set in place.
|
|
101
|
+
* @param other - The GraphBitSet to union with
|
|
102
|
+
*/
|
|
103
|
+
union(other) {
|
|
104
|
+
const result = this.bitset.union(other.bitset);
|
|
105
|
+
this.bitset = result;
|
|
106
|
+
const size = this.bitset.size();
|
|
107
|
+
this._cardinality = size;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Perform intersection operation with another GraphBitSet, updating this set in place.
|
|
111
|
+
* @param other - The GraphBitSet to intersect with
|
|
112
|
+
*/
|
|
113
|
+
intersection(other) {
|
|
114
|
+
const result = this.bitset.intersection(other.bitset);
|
|
115
|
+
this.bitset = result;
|
|
116
|
+
const size = this.bitset.size();
|
|
117
|
+
this._cardinality = size;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Perform difference operation with another GraphBitSet, updating this set in place.
|
|
121
|
+
* @param other - The GraphBitSet to subtract from this set
|
|
122
|
+
*/
|
|
123
|
+
difference(other) {
|
|
124
|
+
const result = this.bitset.difference(other.bitset);
|
|
125
|
+
this.bitset = result;
|
|
126
|
+
const size = this.bitset.size();
|
|
127
|
+
this._cardinality = size;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Clone the bitset.
|
|
131
|
+
* @returns A new GraphBitSet with the same elements
|
|
132
|
+
*/
|
|
133
|
+
clone() {
|
|
134
|
+
const cloned = new GraphBitSet();
|
|
135
|
+
cloned.bitset = this.bitset.clone();
|
|
136
|
+
cloned._cardinality = this._cardinality;
|
|
137
|
+
return cloned;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Specialized bit array for visited tracking
|
|
142
|
+
*
|
|
143
|
+
* More memory efficient than GraphBitSet for simple boolean arrays
|
|
144
|
+
* that don't need set operations.
|
|
145
|
+
*/
|
|
146
|
+
export class VisitedBitArray {
|
|
147
|
+
/**
|
|
148
|
+
* Creates a new VisitedBitArray with the specified size.
|
|
149
|
+
* @param size - The number of bits to allocate
|
|
150
|
+
*/
|
|
151
|
+
constructor(size) {
|
|
152
|
+
this._size = size;
|
|
153
|
+
this.wordCount = Math.ceil(size / 32);
|
|
154
|
+
this.words = new Uint32Array(this.wordCount);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Set bit at the specified index.
|
|
158
|
+
* @param index - The bit index to set
|
|
159
|
+
*/
|
|
160
|
+
set(index) {
|
|
161
|
+
if (index < 0 || index >= this._size) {
|
|
162
|
+
throw new Error(`Index ${String(index)} out of bounds [0, ${String(this._size)})`);
|
|
163
|
+
}
|
|
164
|
+
const wordIndex = index >>> 5; // divide by 32
|
|
165
|
+
const bitIndex = index & 31; // modulo 32
|
|
166
|
+
const word = this.words[wordIndex];
|
|
167
|
+
if (word !== undefined) {
|
|
168
|
+
this.words[wordIndex] = word | (1 << bitIndex);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Get bit value at the specified index.
|
|
173
|
+
* @param index - The bit index to get
|
|
174
|
+
* @returns True if the bit is set, false otherwise
|
|
175
|
+
*/
|
|
176
|
+
get(index) {
|
|
177
|
+
if (index < 0 || index >= this._size) {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
const wordIndex = index >>> 5;
|
|
181
|
+
const bitIndex = index & 31;
|
|
182
|
+
const word = this.words[wordIndex];
|
|
183
|
+
return word !== undefined && (word & (1 << bitIndex)) !== 0;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Clear all bits
|
|
187
|
+
*/
|
|
188
|
+
clear() {
|
|
189
|
+
this.words.fill(0);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Toggle bit at the specified index.
|
|
193
|
+
* @param index - The bit index to toggle
|
|
194
|
+
*/
|
|
195
|
+
toggle(index) {
|
|
196
|
+
if (index < 0 || index >= this._size) {
|
|
197
|
+
throw new Error(`Index ${String(index)} out of bounds [0, ${String(this._size)})`);
|
|
198
|
+
}
|
|
199
|
+
const wordIndex = index >>> 5;
|
|
200
|
+
const bitIndex = index & 31;
|
|
201
|
+
const word = this.words[wordIndex];
|
|
202
|
+
if (word !== undefined) {
|
|
203
|
+
this.words[wordIndex] = word ^ (1 << bitIndex);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Population count for statistics - count the number of set bits.
|
|
208
|
+
* @returns The number of bits set to 1
|
|
209
|
+
*/
|
|
210
|
+
popcount() {
|
|
211
|
+
let count = 0;
|
|
212
|
+
for (let i = 0; i < this.wordCount; i++) {
|
|
213
|
+
const word = this.words[i];
|
|
214
|
+
if (word !== undefined) {
|
|
215
|
+
count += this.popcountWord(word);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return count;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Efficient population count for a single word.
|
|
222
|
+
* Uses bit manipulation tricks for fast counting.
|
|
223
|
+
* @param n - The 32-bit word to count
|
|
224
|
+
* @returns The number of bits set to 1 in the word
|
|
225
|
+
*/
|
|
226
|
+
popcountWord(n) {
|
|
227
|
+
let x = n;
|
|
228
|
+
x = x - ((x >>> 1) & 0x55555555);
|
|
229
|
+
x = (x & 0x33333333) + ((x >>> 2) & 0x33333333);
|
|
230
|
+
return (((x + (x >>> 4)) & 0xf0f0f0f) * 0x1010101) >>> 24;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Get size of the bit array.
|
|
234
|
+
* @returns The total number of bits in the array
|
|
235
|
+
*/
|
|
236
|
+
size() {
|
|
237
|
+
return this._size;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Check if all bits are zero.
|
|
241
|
+
* @returns True if no bits are set, false otherwise
|
|
242
|
+
*/
|
|
243
|
+
isEmpty() {
|
|
244
|
+
for (let i = 0; i < this.wordCount; i++) {
|
|
245
|
+
if (this.words[i] !== 0) {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return true;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Set multiple bits from an array of indices.
|
|
253
|
+
* @param indices - Array of bit indices to set
|
|
254
|
+
*/
|
|
255
|
+
setMultiple(indices) {
|
|
256
|
+
for (const index of indices) {
|
|
257
|
+
this.set(index);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Get indices of all set bits.
|
|
262
|
+
* @returns Array containing the indices of all bits that are set to 1
|
|
263
|
+
*/
|
|
264
|
+
getSetIndices() {
|
|
265
|
+
const indices = [];
|
|
266
|
+
for (let wordIndex = 0; wordIndex < this.wordCount; wordIndex++) {
|
|
267
|
+
const word = this.words[wordIndex];
|
|
268
|
+
if (!word || word === 0) {
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
for (let bitIndex = 0; bitIndex < 32; bitIndex++) {
|
|
272
|
+
if (word & (1 << bitIndex)) {
|
|
273
|
+
const index = (wordIndex << 5) + bitIndex;
|
|
274
|
+
if (index < this._size) {
|
|
275
|
+
indices.push(index);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return indices;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Bit-packed distance array for BFS
|
|
285
|
+
*
|
|
286
|
+
* Optimized for storing distances using 16-bit integers (up to 65,535 levels)
|
|
287
|
+
* Still provides 2x memory savings compared to standard 32-bit numbers
|
|
288
|
+
*/
|
|
289
|
+
export class CompactDistanceArray {
|
|
290
|
+
/**
|
|
291
|
+
* Creates a new CompactDistanceArray with the specified size.
|
|
292
|
+
* @param size - The number of distance values to store
|
|
293
|
+
*/
|
|
294
|
+
constructor(size) {
|
|
295
|
+
this._size = size;
|
|
296
|
+
this.data = new Uint16Array(size);
|
|
297
|
+
this.data.fill(CompactDistanceArray.INFINITY); // Initialize with max value (unvisited)
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Set distance at the specified index.
|
|
301
|
+
* @param index - The node index to set the distance for
|
|
302
|
+
* @param distance - The distance value to set
|
|
303
|
+
*/
|
|
304
|
+
set(index, distance) {
|
|
305
|
+
if (distance >= CompactDistanceArray.INFINITY) {
|
|
306
|
+
throw new Error(`Distance exceeds maximum value (${String(CompactDistanceArray.INFINITY - 1)})`);
|
|
307
|
+
}
|
|
308
|
+
this.data[index] = distance;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Get distance at the specified index.
|
|
312
|
+
* @param index - The node index to get the distance for
|
|
313
|
+
* @returns The distance value, or INFINITY if not set
|
|
314
|
+
*/
|
|
315
|
+
get(index) {
|
|
316
|
+
const value = this.data[index];
|
|
317
|
+
return value ?? CompactDistanceArray.INFINITY; // Default to unvisited
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Check if a node has been visited (has a valid distance).
|
|
321
|
+
* @param index - The node index to check
|
|
322
|
+
* @returns True if the node has been visited, false otherwise
|
|
323
|
+
*/
|
|
324
|
+
isVisited(index) {
|
|
325
|
+
return this.data[index] !== CompactDistanceArray.INFINITY;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Reset all distances to unvisited state.
|
|
329
|
+
*/
|
|
330
|
+
clear() {
|
|
331
|
+
this.data.fill(CompactDistanceArray.INFINITY);
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Get the size of the distance array.
|
|
335
|
+
* @returns The number of elements in the array
|
|
336
|
+
*/
|
|
337
|
+
size() {
|
|
338
|
+
return this._size;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
CompactDistanceArray.INFINITY = 65535;
|
|
342
|
+
//# sourceMappingURL=bit-packed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bit-packed.js","sourceRoot":"","sources":["../../../src/optimized/bit-packed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,OAAO,WAAW;IAIpB;;;OAGG;IACH,YAAY,QAAiB;QANrB,iBAAY,GAAG,CAAC,CAAC;QAOrB,IAAI,CAAC,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;QACpC,IAAI,QAAQ,EAAE,CAAC;YACX,8BAA8B;YAC9B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;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