@graphty/algorithms 2.1.1 → 2.2.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 +139 -50
- package/dist/algorithms.js +15260 -10390
- package/dist/algorithms.js.map +1 -1
- package/dist/algorithms.standalone.js +26675 -21542
- package/dist/algorithms.standalone.js.map +1 -1
- package/dist/src/algorithms/centrality/betweenness.d.ts +18 -0
- package/dist/src/algorithms/centrality/betweenness.d.ts.map +1 -1
- package/dist/src/algorithms/centrality/betweenness.js +40 -1
- package/dist/src/algorithms/centrality/betweenness.js.map +1 -1
- package/dist/src/algorithms/centrality/closeness.d.ts +20 -0
- package/dist/src/algorithms/centrality/closeness.d.ts.map +1 -1
- package/dist/src/algorithms/centrality/closeness.js +93 -8
- package/dist/src/algorithms/centrality/closeness.js.map +1 -1
- package/dist/src/algorithms/centrality/degree.d.ts +9 -0
- package/dist/src/algorithms/centrality/degree.d.ts.map +1 -1
- package/dist/src/algorithms/centrality/degree.js +18 -0
- package/dist/src/algorithms/centrality/degree.js.map +1 -1
- package/dist/src/algorithms/centrality/eigenvector.d.ts +10 -0
- package/dist/src/algorithms/centrality/eigenvector.d.ts.map +1 -1
- package/dist/src/algorithms/centrality/eigenvector.js +29 -0
- package/dist/src/algorithms/centrality/eigenvector.js.map +1 -1
- package/dist/src/algorithms/centrality/hits.d.ts +9 -0
- package/dist/src/algorithms/centrality/hits.d.ts.map +1 -1
- package/dist/src/algorithms/centrality/hits.js +23 -0
- package/dist/src/algorithms/centrality/hits.js.map +1 -1
- package/dist/src/algorithms/centrality/katz.d.ts +9 -0
- package/dist/src/algorithms/centrality/katz.d.ts.map +1 -1
- package/dist/src/algorithms/centrality/katz.js +31 -0
- package/dist/src/algorithms/centrality/katz.js.map +1 -1
- package/dist/src/algorithms/centrality/pagerank.d.ts +13 -13
- package/dist/src/algorithms/centrality/pagerank.d.ts.map +1 -1
- package/dist/src/algorithms/centrality/pagerank.js +47 -10
- package/dist/src/algorithms/centrality/pagerank.js.map +1 -1
- package/dist/src/algorithms/community/girvan-newman-legacy.d.ts +27 -0
- package/dist/src/algorithms/community/girvan-newman-legacy.d.ts.map +1 -0
- package/dist/src/algorithms/community/girvan-newman-legacy.js +335 -0
- package/dist/src/algorithms/community/girvan-newman-legacy.js.map +1 -0
- package/dist/src/algorithms/community/girvan-newman.d.ts +5 -3
- package/dist/src/algorithms/community/girvan-newman.d.ts.map +1 -1
- package/dist/src/algorithms/community/girvan-newman.js +34 -308
- package/dist/src/algorithms/community/girvan-newman.js.map +1 -1
- package/dist/src/algorithms/community/label-propagation.d.ts +9 -6
- package/dist/src/algorithms/community/label-propagation.d.ts.map +1 -1
- package/dist/src/algorithms/community/label-propagation.js +24 -110
- package/dist/src/algorithms/community/label-propagation.js.map +1 -1
- package/dist/src/algorithms/components/connected.d.ts.map +1 -1
- package/dist/src/algorithms/components/connected.js +28 -77
- package/dist/src/algorithms/components/connected.js.map +1 -1
- package/dist/src/algorithms/mst/kruskal.d.ts.map +1 -1
- package/dist/src/algorithms/mst/kruskal.js +59 -3
- package/dist/src/algorithms/mst/kruskal.js.map +1 -1
- package/dist/src/algorithms/shortest-path/bellman-ford.d.ts.map +1 -1
- package/dist/src/algorithms/shortest-path/bellman-ford.js +46 -0
- package/dist/src/algorithms/shortest-path/bellman-ford.js.map +1 -1
- package/dist/src/algorithms/shortest-path/dijkstra.d.ts.map +1 -1
- package/dist/src/algorithms/shortest-path/dijkstra.js +27 -0
- package/dist/src/algorithms/shortest-path/dijkstra.js.map +1 -1
- package/dist/src/algorithms/shortest-path/floyd-warshall.d.ts +15 -5
- package/dist/src/algorithms/shortest-path/floyd-warshall.d.ts.map +1 -1
- package/dist/src/algorithms/shortest-path/floyd-warshall.js +97 -107
- package/dist/src/algorithms/shortest-path/floyd-warshall.js.map +1 -1
- package/dist/src/algorithms/traversal/bfs-unified.d.ts +2 -12
- package/dist/src/algorithms/traversal/bfs-unified.d.ts.map +1 -1
- package/dist/src/algorithms/traversal/bfs-unified.js +47 -308
- package/dist/src/algorithms/traversal/bfs-unified.js.map +1 -1
- package/dist/src/algorithms/traversal/bfs-variants.d.ts.map +1 -1
- package/dist/src/algorithms/traversal/bfs-variants.js +5 -25
- package/dist/src/algorithms/traversal/bfs-variants.js.map +1 -1
- package/dist/src/algorithms/traversal/bfs.d.ts +0 -3
- package/dist/src/algorithms/traversal/bfs.d.ts.map +1 -1
- package/dist/src/algorithms/traversal/bfs.js +0 -4
- package/dist/src/algorithms/traversal/bfs.js.map +1 -1
- package/dist/src/algorithms/traversal/dfs.d.ts.map +1 -1
- package/dist/src/algorithms/traversal/dfs.js +33 -154
- package/dist/src/algorithms/traversal/dfs.js.map +1 -1
- package/dist/src/clustering/hierarchical-legacy.d.ts +56 -0
- package/dist/src/clustering/hierarchical-legacy.d.ts.map +1 -0
- package/dist/src/clustering/hierarchical-legacy.js +441 -0
- package/dist/src/clustering/hierarchical-legacy.js.map +1 -0
- package/dist/src/clustering/hierarchical.d.ts +7 -39
- package/dist/src/clustering/hierarchical.d.ts.map +1 -1
- package/dist/src/clustering/hierarchical.js +56 -417
- package/dist/src/clustering/hierarchical.js.map +1 -1
- package/dist/src/clustering/k-core-legacy.d.ts +30 -0
- package/dist/src/clustering/k-core-legacy.d.ts.map +1 -0
- package/dist/src/clustering/k-core-legacy.js +191 -0
- package/dist/src/clustering/k-core-legacy.js.map +1 -0
- package/dist/src/clustering/k-core.d.ts +8 -7
- package/dist/src/clustering/k-core.d.ts.map +1 -1
- package/dist/src/clustering/k-core.js +33 -174
- package/dist/src/clustering/k-core.js.map +1 -1
- package/dist/src/clustering/mcl-legacy.d.ts +42 -0
- package/dist/src/clustering/mcl-legacy.d.ts.map +1 -0
- package/dist/src/clustering/mcl-legacy.js +386 -0
- package/dist/src/clustering/mcl-legacy.js.map +1 -0
- package/dist/src/clustering/mcl.d.ts +9 -32
- package/dist/src/clustering/mcl.d.ts.map +1 -1
- package/dist/src/clustering/mcl.js +48 -374
- package/dist/src/clustering/mcl.js.map +1 -1
- package/dist/src/index.d.ts +29 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/indexed/accelerator.d.ts +141 -11
- package/dist/src/indexed/accelerator.d.ts.map +1 -1
- package/dist/src/indexed/accelerator.js +319 -5
- package/dist/src/indexed/accelerator.js.map +1 -1
- package/dist/src/indexed/all-pairs.d.ts +59 -0
- package/dist/src/indexed/all-pairs.d.ts.map +1 -0
- package/dist/src/indexed/all-pairs.js +274 -0
- package/dist/src/indexed/all-pairs.js.map +1 -0
- package/dist/src/indexed/bellman-ford.d.ts +25 -0
- package/dist/src/indexed/bellman-ford.d.ts.map +1 -0
- package/dist/src/indexed/bellman-ford.js +59 -0
- package/dist/src/indexed/bellman-ford.js.map +1 -0
- package/dist/src/indexed/betweenness.d.ts +85 -0
- package/dist/src/indexed/betweenness.d.ts.map +1 -0
- package/dist/src/indexed/betweenness.js +188 -0
- package/dist/src/indexed/betweenness.js.map +1 -0
- package/dist/src/indexed/bfs.d.ts +69 -2
- package/dist/src/indexed/bfs.d.ts.map +1 -1
- package/dist/src/indexed/bfs.js +148 -1
- package/dist/src/indexed/bfs.js.map +1 -1
- package/dist/src/indexed/bipartite.d.ts +37 -0
- package/dist/src/indexed/bipartite.d.ts.map +1 -0
- package/dist/src/indexed/bipartite.js +54 -0
- package/dist/src/indexed/bipartite.js.map +1 -0
- package/dist/src/indexed/closeness.d.ts +49 -0
- package/dist/src/indexed/closeness.d.ts.map +1 -0
- package/dist/src/indexed/closeness.js +127 -0
- package/dist/src/indexed/closeness.js.map +1 -0
- package/dist/src/indexed/common-neighbors.d.ts +14 -1
- package/dist/src/indexed/common-neighbors.d.ts.map +1 -1
- package/dist/src/indexed/common-neighbors.js +24 -14
- package/dist/src/indexed/common-neighbors.js.map +1 -1
- package/dist/src/indexed/degree.d.ts +19 -0
- package/dist/src/indexed/degree.d.ts.map +1 -0
- package/dist/src/indexed/degree.js +45 -0
- package/dist/src/indexed/degree.js.map +1 -0
- package/dist/src/indexed/delta-pagerank.d.ts +145 -0
- package/dist/src/indexed/delta-pagerank.d.ts.map +1 -0
- package/dist/src/indexed/delta-pagerank.js +428 -0
- package/dist/src/indexed/delta-pagerank.js.map +1 -0
- package/dist/src/indexed/dfs.d.ts +55 -0
- package/dist/src/indexed/dfs.d.ts.map +1 -0
- package/dist/src/indexed/dfs.js +146 -0
- package/dist/src/indexed/dfs.js.map +1 -0
- package/dist/src/indexed/eigenvector.d.ts +48 -0
- package/dist/src/indexed/eigenvector.d.ts.map +1 -0
- package/dist/src/indexed/eigenvector.js +162 -0
- package/dist/src/indexed/eigenvector.js.map +1 -0
- package/dist/src/indexed/facade.d.ts +109 -0
- package/dist/src/indexed/facade.d.ts.map +1 -0
- package/dist/src/indexed/facade.js +204 -0
- package/dist/src/indexed/facade.js.map +1 -0
- package/dist/src/indexed/flow.d.ts +120 -0
- package/dist/src/indexed/flow.d.ts.map +1 -0
- package/dist/src/indexed/flow.js +377 -0
- package/dist/src/indexed/flow.js.map +1 -0
- package/dist/src/indexed/girvan-newman.d.ts +42 -0
- package/dist/src/indexed/girvan-newman.d.ts.map +1 -0
- package/dist/src/indexed/girvan-newman.js +90 -0
- package/dist/src/indexed/girvan-newman.js.map +1 -0
- package/dist/src/indexed/grsbm.d.ts +85 -0
- package/dist/src/indexed/grsbm.d.ts.map +1 -0
- package/dist/src/indexed/grsbm.js +287 -0
- package/dist/src/indexed/grsbm.js.map +1 -0
- package/dist/src/indexed/hierarchical.d.ts +69 -0
- package/dist/src/indexed/hierarchical.d.ts.map +1 -0
- package/dist/src/indexed/hierarchical.js +245 -0
- package/dist/src/indexed/hierarchical.js.map +1 -0
- package/dist/src/indexed/index.d.ts +29 -3
- package/dist/src/indexed/index.d.ts.map +1 -1
- package/dist/src/indexed/index.js +29 -3
- package/dist/src/indexed/index.js.map +1 -1
- package/dist/src/indexed/isomorphism.d.ts +42 -0
- package/dist/src/indexed/isomorphism.d.ts.map +1 -0
- package/dist/src/indexed/isomorphism.js +269 -0
- package/dist/src/indexed/isomorphism.js.map +1 -0
- package/dist/src/indexed/label-propagation.d.ts +134 -0
- package/dist/src/indexed/label-propagation.d.ts.map +1 -0
- package/dist/src/indexed/label-propagation.js +486 -0
- package/dist/src/indexed/label-propagation.js.map +1 -0
- package/dist/src/indexed/leiden.d.ts +52 -0
- package/dist/src/indexed/leiden.d.ts.map +1 -0
- package/dist/src/indexed/leiden.js +384 -0
- package/dist/src/indexed/leiden.js.map +1 -0
- package/dist/src/indexed/link-prediction.d.ts +147 -0
- package/dist/src/indexed/link-prediction.d.ts.map +1 -0
- package/dist/src/indexed/link-prediction.js +317 -0
- package/dist/src/indexed/link-prediction.js.map +1 -0
- package/dist/src/indexed/markov.d.ts +54 -0
- package/dist/src/indexed/markov.d.ts.map +1 -0
- package/dist/src/indexed/markov.js +284 -0
- package/dist/src/indexed/markov.js.map +1 -0
- package/dist/src/indexed/matching.d.ts +53 -0
- package/dist/src/indexed/matching.d.ts.map +1 -0
- package/dist/src/indexed/matching.js +139 -0
- package/dist/src/indexed/matching.js.map +1 -0
- package/dist/src/indexed/min-cut.d.ts +48 -0
- package/dist/src/indexed/min-cut.d.ts.map +1 -0
- package/dist/src/indexed/min-cut.js +175 -0
- package/dist/src/indexed/min-cut.js.map +1 -0
- package/dist/src/indexed/modularity.d.ts +34 -0
- package/dist/src/indexed/modularity.d.ts.map +1 -0
- package/dist/src/indexed/modularity.js +74 -0
- package/dist/src/indexed/modularity.js.map +1 -0
- package/dist/src/indexed/mst.d.ts +29 -1
- package/dist/src/indexed/mst.d.ts.map +1 -1
- package/dist/src/indexed/mst.js +62 -0
- package/dist/src/indexed/mst.js.map +1 -1
- package/dist/src/indexed/pagerank.d.ts +29 -6
- package/dist/src/indexed/pagerank.d.ts.map +1 -1
- package/dist/src/indexed/pagerank.js +107 -11
- package/dist/src/indexed/pagerank.js.map +1 -1
- package/dist/src/indexed/point-to-point.d.ts +53 -0
- package/dist/src/indexed/point-to-point.d.ts.map +1 -0
- package/dist/src/indexed/point-to-point.js +173 -0
- package/dist/src/indexed/point-to-point.js.map +1 -0
- package/dist/src/indexed/scc.d.ts +53 -0
- package/dist/src/indexed/scc.d.ts.map +1 -0
- package/dist/src/indexed/scc.js +110 -0
- package/dist/src/indexed/scc.js.map +1 -0
- package/dist/src/indexed/spectral.d.ts +61 -0
- package/dist/src/indexed/spectral.d.ts.map +1 -0
- package/dist/src/indexed/spectral.js +476 -0
- package/dist/src/indexed/spectral.js.map +1 -0
- package/dist/src/indexed/structures/bit-set.d.ts +45 -0
- package/dist/src/indexed/structures/bit-set.d.ts.map +1 -0
- package/dist/src/indexed/structures/bit-set.js +57 -0
- package/dist/src/indexed/structures/bit-set.js.map +1 -0
- package/dist/src/indexed/structures/max-heap.d.ts +52 -0
- package/dist/src/indexed/structures/max-heap.d.ts.map +1 -0
- package/dist/src/indexed/structures/max-heap.js +66 -0
- package/dist/src/indexed/structures/max-heap.js.map +1 -0
- package/dist/src/indexed/structures/min-heap.d.ts +30 -1
- package/dist/src/indexed/structures/min-heap.d.ts.map +1 -1
- package/dist/src/indexed/structures/min-heap.js +46 -6
- package/dist/src/indexed/structures/min-heap.js.map +1 -1
- package/dist/src/indexed/structures/ring-queue.d.ts +41 -0
- package/dist/src/indexed/structures/ring-queue.d.ts.map +1 -0
- package/dist/src/indexed/structures/ring-queue.js +64 -0
- package/dist/src/indexed/structures/ring-queue.js.map +1 -0
- package/dist/src/indexed/sync.d.ts +50 -0
- package/dist/src/indexed/sync.d.ts.map +1 -0
- package/dist/src/indexed/sync.js +175 -0
- package/dist/src/indexed/sync.js.map +1 -0
- package/dist/src/indexed/terahac.d.ts +58 -0
- package/dist/src/indexed/terahac.d.ts.map +1 -0
- package/dist/src/indexed/terahac.js +244 -0
- package/dist/src/indexed/terahac.js.map +1 -0
- package/dist/src/indexed/to-snapshot.d.ts +45 -2
- package/dist/src/indexed/to-snapshot.d.ts.map +1 -1
- package/dist/src/indexed/to-snapshot.js +140 -6
- package/dist/src/indexed/to-snapshot.js.map +1 -1
- package/dist/src/link-prediction/common-neighbors-legacy.d.ts +71 -0
- package/dist/src/link-prediction/common-neighbors-legacy.d.ts.map +1 -0
- package/dist/src/link-prediction/common-neighbors-legacy.js +172 -0
- package/dist/src/link-prediction/common-neighbors-legacy.js.map +1 -0
- package/dist/src/link-prediction/common-neighbors.d.ts +11 -19
- package/dist/src/link-prediction/common-neighbors.d.ts.map +1 -1
- package/dist/src/link-prediction/common-neighbors.js +56 -123
- package/dist/src/link-prediction/common-neighbors.js.map +1 -1
- package/dist/src/optimized/direction-optimized-bfs.d.ts +6 -0
- package/dist/src/optimized/direction-optimized-bfs.d.ts.map +1 -1
- package/dist/src/optimized/direction-optimized-bfs.js +6 -0
- package/dist/src/optimized/direction-optimized-bfs.js.map +1 -1
- package/dist/src/research/grsbm-legacy.d.ts +82 -0
- package/dist/src/research/grsbm-legacy.d.ts.map +1 -0
- package/dist/src/research/grsbm-legacy.js +416 -0
- package/dist/src/research/grsbm-legacy.js.map +1 -0
- package/dist/src/research/grsbm.d.ts +9 -66
- package/dist/src/research/grsbm.d.ts.map +1 -1
- package/dist/src/research/grsbm.js +67 -391
- package/dist/src/research/grsbm.js.map +1 -1
- package/dist/src/research/sync-legacy.d.ts +48 -0
- package/dist/src/research/sync-legacy.d.ts.map +1 -0
- package/dist/src/research/sync-legacy.js +337 -0
- package/dist/src/research/sync-legacy.js.map +1 -0
- package/dist/src/research/sync.d.ts +10 -32
- package/dist/src/research/sync.d.ts.map +1 -1
- package/dist/src/research/sync.js +28 -316
- package/dist/src/research/sync.js.map +1 -1
- package/package.json +4 -3
- package/src/algorithms/centrality/betweenness.ts +51 -1
- package/src/algorithms/centrality/closeness.ts +112 -12
- package/src/algorithms/centrality/degree.ts +19 -0
- package/src/algorithms/centrality/eigenvector.ts +34 -0
- package/src/algorithms/centrality/hits.ts +24 -0
- package/src/algorithms/centrality/katz.ts +32 -0
- package/src/algorithms/centrality/pagerank.ts +53 -13
- package/src/algorithms/community/girvan-newman-legacy.ts +414 -0
- package/src/algorithms/community/girvan-newman.ts +36 -386
- package/src/algorithms/community/label-propagation.ts +24 -133
- package/src/algorithms/components/connected.ts +28 -95
- package/src/algorithms/mst/kruskal.ts +65 -4
- package/src/algorithms/shortest-path/bellman-ford.ts +49 -0
- package/src/algorithms/shortest-path/dijkstra.ts +29 -0
- package/src/algorithms/shortest-path/floyd-warshall.ts +106 -136
- package/src/algorithms/traversal/bfs-unified.ts +52 -366
- package/src/algorithms/traversal/bfs-variants.ts +5 -28
- package/src/algorithms/traversal/bfs.ts +0 -4
- package/src/algorithms/traversal/dfs.ts +39 -182
- package/src/clustering/hierarchical-legacy.ts +551 -0
- package/src/clustering/hierarchical.ts +64 -520
- package/src/clustering/k-core-legacy.ts +229 -0
- package/src/clustering/k-core.ts +38 -209
- package/src/clustering/mcl-legacy.ts +498 -0
- package/src/clustering/mcl.ts +46 -479
- package/src/index.ts +90 -3
- package/src/indexed/accelerator.ts +502 -16
- package/src/indexed/all-pairs.ts +342 -0
- package/src/indexed/bellman-ford.ts +72 -0
- package/src/indexed/betweenness.ts +258 -0
- package/src/indexed/bfs.ts +189 -3
- package/src/indexed/bipartite.ts +77 -0
- package/src/indexed/closeness.ts +160 -0
- package/src/indexed/common-neighbors.ts +31 -14
- package/src/indexed/degree.ts +55 -0
- package/src/indexed/delta-pagerank.ts +513 -0
- package/src/indexed/dfs.ts +189 -0
- package/src/indexed/eigenvector.ts +202 -0
- package/src/indexed/facade.ts +229 -0
- package/src/indexed/flow.ts +500 -0
- package/src/indexed/girvan-newman.ts +120 -0
- package/src/indexed/grsbm.ts +390 -0
- package/src/indexed/hierarchical.ts +295 -0
- package/src/indexed/index.ts +94 -3
- package/src/indexed/isomorphism.ts +305 -0
- package/src/indexed/label-propagation.ts +582 -0
- package/src/indexed/leiden.ts +436 -0
- package/src/indexed/link-prediction.ts +399 -0
- package/src/indexed/markov.ts +324 -0
- package/src/indexed/matching.ts +192 -0
- package/src/indexed/min-cut.ts +201 -0
- package/src/indexed/modularity.ts +81 -0
- package/src/indexed/mst.ts +79 -1
- package/src/indexed/pagerank.ts +128 -15
- package/src/indexed/point-to-point.ts +220 -0
- package/src/indexed/scc.ts +132 -0
- package/src/indexed/spectral.ts +550 -0
- package/src/indexed/structures/bit-set.ts +65 -0
- package/src/indexed/structures/max-heap.ts +74 -0
- package/src/indexed/structures/min-heap.ts +51 -6
- package/src/indexed/structures/ring-queue.ts +70 -0
- package/src/indexed/sync.ts +229 -0
- package/src/indexed/terahac.ts +290 -0
- package/src/indexed/to-snapshot.ts +156 -6
- package/src/link-prediction/common-neighbors-legacy.ts +252 -0
- package/src/link-prediction/common-neighbors.ts +65 -168
- package/src/optimized/direction-optimized-bfs.ts +6 -1
- package/src/research/grsbm-legacy.ts +586 -0
- package/src/research/grsbm.ts +76 -555
- package/src/research/sync-legacy.ts +456 -0
- package/src/research/sync.ts +30 -431
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { INVALID_INDEX } from "@graphty/graph-format";
|
|
2
|
+
/**
|
|
3
|
+
* Hop distances from every node, over out-arcs: `nodeCount * nodeCount` entries, `INVALID_INDEX`
|
|
4
|
+
* where no path exists.
|
|
5
|
+
* @param s - The adjacency
|
|
6
|
+
* @returns The row-major hop matrix
|
|
7
|
+
*/
|
|
8
|
+
function hopMatrix(s) {
|
|
9
|
+
const n = s.nodeCount;
|
|
10
|
+
const hops = new Uint32Array(n * n).fill(INVALID_INDEX);
|
|
11
|
+
const queue = new Uint32Array(n);
|
|
12
|
+
for (let start = 0; start < n; start++) {
|
|
13
|
+
const row = start * n;
|
|
14
|
+
hops[row + start] = 0;
|
|
15
|
+
queue[0] = start;
|
|
16
|
+
let head = 0;
|
|
17
|
+
let tail = 1;
|
|
18
|
+
while (head < tail) {
|
|
19
|
+
const u = queue[head++];
|
|
20
|
+
const next = hops[row + u] + 1;
|
|
21
|
+
const end = s.rowPtr[u + 1];
|
|
22
|
+
for (let a = s.rowPtr[u]; a < end; a++) {
|
|
23
|
+
const v = s.colIdx[a];
|
|
24
|
+
if (hops[row + v] === INVALID_INDEX) {
|
|
25
|
+
hops[row + v] = next;
|
|
26
|
+
queue[tail++] = v;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return hops;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The rank of every cluster's legacy id string (`leaf-<i>` for a node, `cluster-<k>` for a merge),
|
|
35
|
+
* in string order. The legacy function breaks distance ties by comparing those strings, so the port
|
|
36
|
+
* compares these ranks to make the same merges.
|
|
37
|
+
* @param n - Node count
|
|
38
|
+
* @returns One rank per possible cluster, `2n - 1` of them
|
|
39
|
+
*/
|
|
40
|
+
function legacyIdRanks(n) {
|
|
41
|
+
const total = Math.max(0, 2 * n - 1);
|
|
42
|
+
const names = Array.from({ length: total }, (_, c) => (c < n ? `leaf-${c}` : `cluster-${c}`));
|
|
43
|
+
// Code-unit order, as the legacy `>=` on strings compares; localeCompare would not.
|
|
44
|
+
const order = Array.from({ length: total }, (_, c) => c).sort((a, b) => Number(names[a] > names[b]) - Number(names[a] < names[b]));
|
|
45
|
+
const rank = new Uint32Array(total);
|
|
46
|
+
order.forEach((c, r) => (rank[c] = r));
|
|
47
|
+
return rank;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Agglomerative hierarchical clustering over hop distances, the index-based port of the legacy
|
|
51
|
+
* `hierarchicalClustering`: every node starts as its own cluster and the closest pair is merged
|
|
52
|
+
* until one cluster remains or no remaining pair is linked by a path.
|
|
53
|
+
*
|
|
54
|
+
* The distance between two nodes is the BFS hop count over out-arcs (weights are ignored, as the
|
|
55
|
+
* legacy function ignores them); an unreachable pair has none and is left out of every linkage.
|
|
56
|
+
* The distance between two clusters over the member pairs that have one is their minimum
|
|
57
|
+
* (`single`), maximum (`complete`), mean (`average`), or mean times `|A| |B| / (|A| + |B|)`
|
|
58
|
+
* (`ward`). A pair with no connected member pair is never merged. On a directed snapshot the
|
|
59
|
+
* distance is taken in one direction, and which one follows the legacy function exactly, as do the
|
|
60
|
+
* tie-breaks: the merges, their order and their distances equal the legacy function's.
|
|
61
|
+
*
|
|
62
|
+
* One difference in what the result offers: `cut` descends into every root of a disconnected
|
|
63
|
+
* snapshot, where the legacy `clusters` map lists all nodes as one cluster at every height (its
|
|
64
|
+
* forest node has no children, so its cut never splits it).
|
|
65
|
+
*
|
|
66
|
+
* O(n^2) memory for the distance aggregates and O(n^3) time for the pair search; the legacy
|
|
67
|
+
* function is the same order with Map and Set per step.
|
|
68
|
+
* @param s - Any snapshot or adjacency view
|
|
69
|
+
* @param options - The linkage
|
|
70
|
+
* @returns The dendrogram
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
export function hierarchicalClustering(s, options = {}) {
|
|
74
|
+
const linkage = options.linkage ?? "single";
|
|
75
|
+
if (!["single", "complete", "average", "ward"].includes(linkage)) {
|
|
76
|
+
throw new RangeError(`unknown linkage "${linkage}"`);
|
|
77
|
+
}
|
|
78
|
+
const n = s.nodeCount;
|
|
79
|
+
const hops = hopMatrix(s);
|
|
80
|
+
// Per ordered pair of cluster SLOTS: the min, max, sum and count of the member hop distances
|
|
81
|
+
// from the first to the second. A merge reuses its first child's slot.
|
|
82
|
+
const min = new Uint32Array(n * n);
|
|
83
|
+
const max = new Uint32Array(n * n);
|
|
84
|
+
const sum = new Float64Array(n * n);
|
|
85
|
+
const count = new Float64Array(n * n);
|
|
86
|
+
for (let i = 0; i < n * n; i++) {
|
|
87
|
+
const h = hops[i];
|
|
88
|
+
if (h !== INVALID_INDEX) {
|
|
89
|
+
min[i] = h;
|
|
90
|
+
max[i] = h;
|
|
91
|
+
sum[i] = h;
|
|
92
|
+
count[i] = 1;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const total = Math.max(0, 2 * n - 1);
|
|
96
|
+
const rank = legacyIdRanks(n);
|
|
97
|
+
const slot = new Uint32Array(total);
|
|
98
|
+
const size = new Float64Array(total);
|
|
99
|
+
const height = new Uint32Array(total);
|
|
100
|
+
for (let i = 0; i < n; i++) {
|
|
101
|
+
slot[i] = i;
|
|
102
|
+
size[i] = 1;
|
|
103
|
+
}
|
|
104
|
+
const left = [];
|
|
105
|
+
const right = [];
|
|
106
|
+
const distance = [];
|
|
107
|
+
/**
|
|
108
|
+
* The linkage distance from one cluster to another, as the legacy clusterDistance(x, y).
|
|
109
|
+
* @param x - The cluster the member distances start from
|
|
110
|
+
* @param y - The cluster they end at
|
|
111
|
+
* @returns The distance, Infinity when no member of y is reachable from x
|
|
112
|
+
*/
|
|
113
|
+
const link = (x, y) => {
|
|
114
|
+
const at = slot[x] * n + slot[y];
|
|
115
|
+
const c = count[at];
|
|
116
|
+
if (c === 0) {
|
|
117
|
+
return Infinity;
|
|
118
|
+
}
|
|
119
|
+
switch (linkage) {
|
|
120
|
+
case "single":
|
|
121
|
+
return min[at];
|
|
122
|
+
case "complete":
|
|
123
|
+
return max[at];
|
|
124
|
+
case "average":
|
|
125
|
+
return sum[at] / c;
|
|
126
|
+
default:
|
|
127
|
+
return (sum[at] / c) * ((size[x] * size[y]) / (size[x] + size[y]));
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* The distance the legacy function stores for a pair: a leaf pair's from the lower node to the
|
|
132
|
+
* higher, a pair involving a merge from the later-created cluster to the earlier one.
|
|
133
|
+
* @param x - One cluster
|
|
134
|
+
* @param y - The other
|
|
135
|
+
* @returns The stored distance
|
|
136
|
+
*/
|
|
137
|
+
const pairDistance = (x, y) => {
|
|
138
|
+
const [early, late] = x < y ? [x, y] : [y, x];
|
|
139
|
+
return late < n ? link(early, late) : link(late, early);
|
|
140
|
+
};
|
|
141
|
+
// Active clusters in the legacy Set's insertion order: the nodes, then each merge appended.
|
|
142
|
+
let active = Array.from({ length: n }, (_, i) => i);
|
|
143
|
+
while (active.length > 1) {
|
|
144
|
+
let best = Infinity;
|
|
145
|
+
let a = -1;
|
|
146
|
+
let b = -1;
|
|
147
|
+
for (const x of active) {
|
|
148
|
+
for (const y of active) {
|
|
149
|
+
if (rank[x] >= rank[y]) {
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
const d = pairDistance(x, y);
|
|
153
|
+
if (d < best) {
|
|
154
|
+
best = d;
|
|
155
|
+
a = x;
|
|
156
|
+
b = y;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (a < 0) {
|
|
161
|
+
break; // no linked pair left: the rest stay separate roots
|
|
162
|
+
}
|
|
163
|
+
const created = n + left.length;
|
|
164
|
+
left.push(a);
|
|
165
|
+
right.push(b);
|
|
166
|
+
distance.push(best);
|
|
167
|
+
height[created] = Math.max(height[a], height[b]) + 1;
|
|
168
|
+
size[created] = size[a] + size[b];
|
|
169
|
+
const sa = slot[a];
|
|
170
|
+
const sb = slot[b];
|
|
171
|
+
for (const x of active) {
|
|
172
|
+
if (x === a || x === b) {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
const sx = slot[x];
|
|
176
|
+
for (const [to, from1, from2] of [
|
|
177
|
+
[sa * n + sx, sa * n + sx, sb * n + sx],
|
|
178
|
+
[sx * n + sa, sx * n + sa, sx * n + sb],
|
|
179
|
+
]) {
|
|
180
|
+
const c1 = count[from1];
|
|
181
|
+
const c2 = count[from2];
|
|
182
|
+
// An empty aggregate's min and max are meaningless: take the other side's.
|
|
183
|
+
if (c1 === 0 || c2 === 0) {
|
|
184
|
+
const from = c1 === 0 ? from2 : from1;
|
|
185
|
+
min[to] = min[from];
|
|
186
|
+
max[to] = max[from];
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
min[to] = Math.min(min[from1], min[from2]);
|
|
190
|
+
max[to] = Math.max(max[from1], max[from2]);
|
|
191
|
+
}
|
|
192
|
+
sum[to] = sum[from1] + sum[from2];
|
|
193
|
+
count[to] = c1 + c2;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
slot[created] = sa;
|
|
197
|
+
active = active.filter((x) => x !== a && x !== b);
|
|
198
|
+
active.push(created);
|
|
199
|
+
}
|
|
200
|
+
const merges = left.length;
|
|
201
|
+
const leftArr = Uint32Array.from(left);
|
|
202
|
+
const rightArr = Uint32Array.from(right);
|
|
203
|
+
const members = (cluster) => {
|
|
204
|
+
if (!(cluster >= 0 && cluster < n + merges)) {
|
|
205
|
+
throw new RangeError(`cluster ${cluster} is not in [0, ${n + merges})`);
|
|
206
|
+
}
|
|
207
|
+
const out = [];
|
|
208
|
+
const stack = [cluster];
|
|
209
|
+
while (stack.length > 0) {
|
|
210
|
+
const c = stack.pop();
|
|
211
|
+
if (c < n) {
|
|
212
|
+
out.push(c);
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
stack.push(rightArr[c - n], leftArr[c - n]);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return Uint32Array.from(out);
|
|
219
|
+
};
|
|
220
|
+
const roots = Uint32Array.from(active);
|
|
221
|
+
return {
|
|
222
|
+
nodeCount: n,
|
|
223
|
+
left: leftArr,
|
|
224
|
+
right: rightArr,
|
|
225
|
+
distance: Float64Array.from(distance),
|
|
226
|
+
height: height.slice(0, n + merges),
|
|
227
|
+
roots,
|
|
228
|
+
members,
|
|
229
|
+
cut(h) {
|
|
230
|
+
const out = [];
|
|
231
|
+
const visit = (c) => {
|
|
232
|
+
if (c < n || height[c] <= h) {
|
|
233
|
+
out.push(members(c));
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
visit(leftArr[c - n]);
|
|
237
|
+
visit(rightArr[c - n]);
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
roots.forEach(visit);
|
|
241
|
+
return out;
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
//# sourceMappingURL=hierarchical.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hierarch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AI,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC1B,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;gBACzB,CAAC;qBAAM,CAAC;oBACJ,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;oBACtB,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;gBAC3B,CAAC;YACL,CAAC,CAAC;YACF,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO,GAAG,CAAC;QACf,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -12,15 +12,41 @@
|
|
|
12
12
|
* promises. It is exported flat too.
|
|
13
13
|
* @module
|
|
14
14
|
*/
|
|
15
|
-
export {
|
|
15
|
+
export { allPairsShortestPath, APSP_DEFAULT_MAX_NODES, type ApspOptions, type ApspResult } from "./all-pairs.js";
|
|
16
|
+
export { bellmanFord, type BellmanFordResult } from "./bellman-ford.js";
|
|
17
|
+
export { betweennessCentrality, type BetweennessOptions, edgeBetweennessCentrality, type EdgeBetweennessOptions, type EdgeScoresResult, type ScoresResult, } from "./betweenness.js";
|
|
18
|
+
export { type ArcOrderOption, type BfsOptions, type BfsResult, breadthFirstSearch, directionOptimizedBfs, type DirectionOptimizedBfsOptions, } from "./bfs.js";
|
|
19
|
+
export { type BipartiteOptions, type BipartiteResult, isBipartite } from "./bipartite.js";
|
|
20
|
+
export { closenessCentrality, type ClosenessOptions, nodeClosenessCentrality } from "./closeness.js";
|
|
16
21
|
export { type CommonNeighborsOptions, commonNeighborsScore } from "./common-neighbors.js";
|
|
17
22
|
export { connectedComponents, type LabelResult, weaklyConnectedComponents } from "./components.js";
|
|
23
|
+
export { degreeCentrality, type DegreeCentralityOptions } from "./degree.js";
|
|
24
|
+
export { DeltaPageRank, type DeltaPageRankComputeOptions, type DeltaPageRankEngineOptions, PriorityDeltaPageRank, } from "./delta-pagerank.js";
|
|
25
|
+
export { depthFirstSearch, type DfsOptions, type DfsResult, hasCycle, topologicalSort } from "./dfs.js";
|
|
18
26
|
export { dijkstra, type SsspOptions, type SsspResult, walkPredArcs, walkPredEdges } from "./dijkstra.js";
|
|
27
|
+
export { eigenvectorCentrality, type EigenvectorOptions, type EigenvectorResult } from "./eigenvector.js";
|
|
28
|
+
export { type BipartiteFlowNetwork, bipartiteFlowNetwork, maxFlow, type MaxFlowOptions, type MaxFlowResult, type MinCutResult, minSTCut, } from "./flow.js";
|
|
29
|
+
export { girvanNewman, type GirvanNewmanOptions, type GirvanNewmanResult } from "./girvan-newman.js";
|
|
30
|
+
export { grsbm, type GrsbmCluster, type GrsbmOptions, type GrsbmResult, type GrsbmSplit } from "./grsbm.js";
|
|
31
|
+
export { hierarchicalClustering, type HierarchicalOptions, type HierarchicalResult, type Linkage, } from "./hierarchical.js";
|
|
19
32
|
export { hits, type HitsOptions, type HitsResult } from "./hits.js";
|
|
33
|
+
export { findAllIsomorphisms, isGraphIsomorphic, type IsomorphismOptions, type IsomorphismResult, } from "./isomorphism.js";
|
|
20
34
|
export { type CorenessResult, kCoreDecomposition } from "./k-core.js";
|
|
21
35
|
export { katzCentrality, type KatzOptions, type KatzResult } from "./katz.js";
|
|
36
|
+
export { labelPropagation, type LabelPropagationOptions, type LabelPropagationResult, labelPropagationSemiSupervised, labelPropagationSynchronous, type SynchronousLabelPropagationOptions, } from "./label-propagation.js";
|
|
37
|
+
export { leiden, type LeidenOptions, type LeidenResult } from "./leiden.js";
|
|
38
|
+
export { adamicAdarForPairs, adamicAdarPrediction, adamicAdarScore, type CandidateOptions, commonNeighborsForPairs, commonNeighborsPrediction, compareAdamicAdarWithCommonNeighbors, evaluateAdamicAdar, evaluateCommonNeighbors, getTopAdamicAdarCandidatesForNode, getTopCandidatesForNode, type LinkPredictionMetrics, type LinkPredictionOptions, type LinkPredictionResult, type NodePairs, } from "./link-prediction.js";
|
|
22
39
|
export { louvain, type LouvainOptions, type LouvainResult } from "./louvain.js";
|
|
23
|
-
export {
|
|
24
|
-
export {
|
|
40
|
+
export { markovClustering, type MarkovOptions, type MarkovResult } from "./markov.js";
|
|
41
|
+
export { type BipartiteMatchingOptions, type BipartiteMatchingResult, greedyBipartiteMatching, maximumBipartiteMatching, } from "./matching.js";
|
|
42
|
+
export { kargerMinCut, type KargerOptions, stoerWagner, type StoerWagnerOptions } from "./min-cut.js";
|
|
43
|
+
export { modularity, type ModularityOptions } from "./modularity.js";
|
|
44
|
+
export { kruskalMST, type MstOptions, type MstResult, primMST, type PrimOptions, type PrimResult } from "./mst.js";
|
|
45
|
+
export { pageRank, type PageRankOptions, type PageRankResult, personalizedPageRank } from "./pagerank.js";
|
|
46
|
+
export { astar, type AstarResult, bidirectionalDijkstra, type PathOptions, type PathResult } from "./point-to-point.js";
|
|
47
|
+
export { condensation, type CondensationResult, stronglyConnectedComponents } from "./scc.js";
|
|
48
|
+
export { type LaplacianType, spectralClustering, type SpectralOptions, type SpectralResult } from "./spectral.js";
|
|
25
49
|
export { arcSourceIn, IndexedMinHeap, IntUnionFind } from "./structures/index.js";
|
|
50
|
+
export { syncClustering, type SyncClusteringOptions, type SyncClusteringResult } from "./sync.js";
|
|
51
|
+
export { teraHAC, type TeraHacOptions, type TeraHacResult } from "./terahac.js";
|
|
26
52
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/indexed/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/indexed/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAA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AAClG,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -12,15 +12,41 @@
|
|
|
12
12
|
* promises. It is exported flat too.
|
|
13
13
|
* @module
|
|
14
14
|
*/
|
|
15
|
-
export {
|
|
15
|
+
export { allPairsShortestPath, APSP_DEFAULT_MAX_NODES } from "./all-pairs.js";
|
|
16
|
+
export { bellmanFord } from "./bellman-ford.js";
|
|
17
|
+
export { betweennessCentrality, edgeBetweennessCentrality, } from "./betweenness.js";
|
|
18
|
+
export { breadthFirstSearch, directionOptimizedBfs, } from "./bfs.js";
|
|
19
|
+
export { isBipartite } from "./bipartite.js";
|
|
20
|
+
export { closenessCentrality, nodeClosenessCentrality } from "./closeness.js";
|
|
16
21
|
export { commonNeighborsScore } from "./common-neighbors.js";
|
|
17
22
|
export { connectedComponents, weaklyConnectedComponents } from "./components.js";
|
|
23
|
+
export { degreeCentrality } from "./degree.js";
|
|
24
|
+
export { DeltaPageRank, PriorityDeltaPageRank, } from "./delta-pagerank.js";
|
|
25
|
+
export { depthFirstSearch, hasCycle, topologicalSort } from "./dfs.js";
|
|
18
26
|
export { dijkstra, walkPredArcs, walkPredEdges } from "./dijkstra.js";
|
|
27
|
+
export { eigenvectorCentrality } from "./eigenvector.js";
|
|
28
|
+
export { bipartiteFlowNetwork, maxFlow, minSTCut, } from "./flow.js";
|
|
29
|
+
export { girvanNewman } from "./girvan-newman.js";
|
|
30
|
+
export { grsbm } from "./grsbm.js";
|
|
31
|
+
export { hierarchicalClustering, } from "./hierarchical.js";
|
|
19
32
|
export { hits } from "./hits.js";
|
|
33
|
+
export { findAllIsomorphisms, isGraphIsomorphic, } from "./isomorphism.js";
|
|
20
34
|
export { kCoreDecomposition } from "./k-core.js";
|
|
21
35
|
export { katzCentrality } from "./katz.js";
|
|
36
|
+
export { labelPropagation, labelPropagationSemiSupervised, labelPropagationSynchronous, } from "./label-propagation.js";
|
|
37
|
+
export { leiden } from "./leiden.js";
|
|
38
|
+
export { adamicAdarForPairs, adamicAdarPrediction, adamicAdarScore, commonNeighborsForPairs, commonNeighborsPrediction, compareAdamicAdarWithCommonNeighbors, evaluateAdamicAdar, evaluateCommonNeighbors, getTopAdamicAdarCandidatesForNode, getTopCandidatesForNode, } from "./link-prediction.js";
|
|
22
39
|
export { louvain } from "./louvain.js";
|
|
23
|
-
export {
|
|
24
|
-
export {
|
|
40
|
+
export { markovClustering } from "./markov.js";
|
|
41
|
+
export { greedyBipartiteMatching, maximumBipartiteMatching, } from "./matching.js";
|
|
42
|
+
export { kargerMinCut, stoerWagner } from "./min-cut.js";
|
|
43
|
+
export { modularity } from "./modularity.js";
|
|
44
|
+
export { kruskalMST, primMST } from "./mst.js";
|
|
45
|
+
export { pageRank, personalizedPageRank } from "./pagerank.js";
|
|
46
|
+
export { astar, bidirectionalDijkstra } from "./point-to-point.js";
|
|
47
|
+
export { condensation, stronglyConnectedComponents } from "./scc.js";
|
|
48
|
+
export { spectralClustering } from "./spectral.js";
|
|
25
49
|
export { arcSourceIn, IndexedMinHeap, IntUnionFind } from "./structures/index.js";
|
|
50
|
+
export { syncClustering } from "./sync.js";
|
|
51
|
+
export { teraHAC } from "./terahac.js";
|
|
26
52
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/indexed/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/indexed/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAqC,MAAM,gBAAgB,CAAC;AACjH,OAAO,EAAE,WAAW,EAA0B,MAAM,mBAAmB,CAAC;AACxE,OAAO,EACH,qBAAqB,EAErB,yBAAyB,GAI5B,MAAM,kBAAkB,CAAC;AAC1B,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kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EAEf,uBAAuB,EACvB,yBAAyB,EACzB,oCAAoC,EACpC,kBAAkB,EAClB,uBAAuB,EACvB,iCAAiC,EACjC,uBAAuB,GAK1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,OAAO,EAA2C,MAAM,cAAc,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAyC,MAAM,aAAa,CAAC;AACtF,OAAO,EAGH,uBAAuB,EACvB,wBAAwB,GAC3B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAsB,WAAW,EAA2B,MAAM,cAAc,CAAC;AACtG,OAAO,EAAE,UAAU,EAA0B,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,UAAU,EAAmC,OAAO,EAAqC,MAAM,UAAU,CAAC;AACnH,OAAO,EAAE,QAAQ,EAA6C,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC1G,OAAO,EAAE,KAAK,EAAoB,qBAAqB,EAAqC,MAAM,qBAAqB,CAAC;AACxH,OAAO,EAAE,YAAY,EAA2B,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAC9F,OAAO,EAAsB,kBAAkB,EAA6C,MAAM,eAAe,CAAC;AAClH,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,cAAc,EAAyD,MAAM,WAAW,CAAC;AAClG,OAAO,EAAE,OAAO,EAA2C,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type GraphSnapshot, type U32 } from "@graphty/graph-format";
|
|
2
|
+
/** Options of {@link isGraphIsomorphic} and {@link findAllIsomorphisms}. @public */
|
|
3
|
+
export interface IsomorphismOptions {
|
|
4
|
+
/** Whether node `i1` of `s1` may map to node `i2` of `s2`. */
|
|
5
|
+
readonly nodeMatch?: ((i1: number, i2: number, s1: GraphSnapshot, s2: GraphSnapshot) => boolean) | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Whether logical edge `e1` of `s1` may map to logical edge `e2` of `s2`. Called once for every
|
|
8
|
+
* pair of adjacent nodes, when the second of them is mapped, and once for a self-loop, when its
|
|
9
|
+
* node is mapped; between parallel edges it sees the lowest edge index. On a directed snapshot
|
|
10
|
+
* it sees every arc, whichever end is mapped last.
|
|
11
|
+
*/
|
|
12
|
+
readonly edgeMatch?: ((e1: number, e2: number, s1: GraphSnapshot, s2: GraphSnapshot) => boolean) | undefined;
|
|
13
|
+
}
|
|
14
|
+
/** Result of {@link isGraphIsomorphic}. @public */
|
|
15
|
+
export interface IsomorphismResult {
|
|
16
|
+
/** Whether the two graphs are isomorphic. */
|
|
17
|
+
readonly isomorphic: boolean;
|
|
18
|
+
/** The image in `s2` of every node of `s1`; null when not isomorphic. */
|
|
19
|
+
readonly mapping: U32 | null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Whether two snapshots are isomorphic, by a VF2-style search. Neighbourhoods are simple-graph:
|
|
23
|
+
* parallel arcs count once and a self-loop maps only to a self-loop. On a directed snapshot both
|
|
24
|
+
* arc directions are preserved.
|
|
25
|
+
* @param s1 - The first graph
|
|
26
|
+
* @param s2 - The second graph
|
|
27
|
+
* @param options - Node and edge match predicates
|
|
28
|
+
* @returns Whether an isomorphism exists and, when it does, the first one found
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export declare function isGraphIsomorphic(s1: GraphSnapshot, s2: GraphSnapshot, options?: IsomorphismOptions): IsomorphismResult;
|
|
32
|
+
/**
|
|
33
|
+
* Every isomorphism from `s1` to `s2`, with the neighbourhood rules of {@link isGraphIsomorphic}.
|
|
34
|
+
* Two empty graphs have one, the empty mapping.
|
|
35
|
+
* @param s1 - The first graph
|
|
36
|
+
* @param s2 - The second graph
|
|
37
|
+
* @param options - Node and edge match predicates
|
|
38
|
+
* @returns One array per isomorphism: the image in `s2` of every node of `s1`
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
export declare function findAllIsomorphisms(s1: GraphSnapshot, s2: GraphSnapshot, options?: IsomorphismOptions): U32[];
|
|
42
|
+
//# sourceMappingURL=isomorphism.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isomorphism.d.ts","sourceRoot":"","sources":["../../../src/indexed/isomorphism.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,aAAa,EAAiB,KAAK,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAExG,oFAAoF;AACpF,MAAM,WAAW,kBAAkB;IAC/B,8DAA8D;IAC9D,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,aAAa,KAAK,OAAO,CAAC,GAAG,SAAS,CAAC;IAC7G;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,aAAa,KAAK,OAAO,CAAC,GAAG,SAAS,CAAC;CAChH;AAED,mDAAmD;AACnD,MAAM,WAAW,iBAAiB;IAC9B,6CAA6C;IAC7C,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,yEAAyE;IACzE,QAAQ,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI,CAAC;CAChC;AAoPD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC7B,EAAE,EAAE,aAAa,EACjB,EAAE,EAAE,aAAa,EACjB,OAAO,GAAE,kBAAuB,GACjC,iBAAiB,CAOnB;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,aAAa,EAAE,OAAO,GAAE,kBAAuB,GAAG,GAAG,EAAE,CAOjH"}
|