@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
package/src/indexed/index.ts
CHANGED
|
@@ -13,14 +13,105 @@
|
|
|
13
13
|
* @module
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
export {
|
|
16
|
+
export { allPairsShortestPath, APSP_DEFAULT_MAX_NODES, type ApspOptions, type ApspResult } from "./all-pairs.js";
|
|
17
|
+
export { bellmanFord, type BellmanFordResult } from "./bellman-ford.js";
|
|
18
|
+
export {
|
|
19
|
+
betweennessCentrality,
|
|
20
|
+
type BetweennessOptions,
|
|
21
|
+
edgeBetweennessCentrality,
|
|
22
|
+
type EdgeBetweennessOptions,
|
|
23
|
+
type EdgeScoresResult,
|
|
24
|
+
type ScoresResult,
|
|
25
|
+
} from "./betweenness.js";
|
|
26
|
+
export {
|
|
27
|
+
type ArcOrderOption,
|
|
28
|
+
type BfsOptions,
|
|
29
|
+
type BfsResult,
|
|
30
|
+
breadthFirstSearch,
|
|
31
|
+
directionOptimizedBfs,
|
|
32
|
+
type DirectionOptimizedBfsOptions,
|
|
33
|
+
} from "./bfs.js";
|
|
34
|
+
export { type BipartiteOptions, type BipartiteResult, isBipartite } from "./bipartite.js";
|
|
35
|
+
export { closenessCentrality, type ClosenessOptions, nodeClosenessCentrality } from "./closeness.js";
|
|
17
36
|
export { type CommonNeighborsOptions, commonNeighborsScore } from "./common-neighbors.js";
|
|
18
37
|
export { connectedComponents, type LabelResult, weaklyConnectedComponents } from "./components.js";
|
|
38
|
+
export { degreeCentrality, type DegreeCentralityOptions } from "./degree.js";
|
|
39
|
+
export {
|
|
40
|
+
DeltaPageRank,
|
|
41
|
+
type DeltaPageRankComputeOptions,
|
|
42
|
+
type DeltaPageRankEngineOptions,
|
|
43
|
+
PriorityDeltaPageRank,
|
|
44
|
+
} from "./delta-pagerank.js";
|
|
45
|
+
export { depthFirstSearch, type DfsOptions, type DfsResult, hasCycle, topologicalSort } from "./dfs.js";
|
|
19
46
|
export { dijkstra, type SsspOptions, type SsspResult, walkPredArcs, walkPredEdges } from "./dijkstra.js";
|
|
47
|
+
export { eigenvectorCentrality, type EigenvectorOptions, type EigenvectorResult } from "./eigenvector.js";
|
|
48
|
+
export {
|
|
49
|
+
type BipartiteFlowNetwork,
|
|
50
|
+
bipartiteFlowNetwork,
|
|
51
|
+
maxFlow,
|
|
52
|
+
type MaxFlowOptions,
|
|
53
|
+
type MaxFlowResult,
|
|
54
|
+
type MinCutResult,
|
|
55
|
+
minSTCut,
|
|
56
|
+
} from "./flow.js";
|
|
57
|
+
export { girvanNewman, type GirvanNewmanOptions, type GirvanNewmanResult } from "./girvan-newman.js";
|
|
58
|
+
export { grsbm, type GrsbmCluster, type GrsbmOptions, type GrsbmResult, type GrsbmSplit } from "./grsbm.js";
|
|
59
|
+
export {
|
|
60
|
+
hierarchicalClustering,
|
|
61
|
+
type HierarchicalOptions,
|
|
62
|
+
type HierarchicalResult,
|
|
63
|
+
type Linkage,
|
|
64
|
+
} from "./hierarchical.js";
|
|
20
65
|
export { hits, type HitsOptions, type HitsResult } from "./hits.js";
|
|
66
|
+
export {
|
|
67
|
+
findAllIsomorphisms,
|
|
68
|
+
isGraphIsomorphic,
|
|
69
|
+
type IsomorphismOptions,
|
|
70
|
+
type IsomorphismResult,
|
|
71
|
+
} from "./isomorphism.js";
|
|
21
72
|
export { type CorenessResult, kCoreDecomposition } from "./k-core.js";
|
|
22
73
|
export { katzCentrality, type KatzOptions, type KatzResult } from "./katz.js";
|
|
74
|
+
export {
|
|
75
|
+
labelPropagation,
|
|
76
|
+
type LabelPropagationOptions,
|
|
77
|
+
type LabelPropagationResult,
|
|
78
|
+
labelPropagationSemiSupervised,
|
|
79
|
+
labelPropagationSynchronous,
|
|
80
|
+
type SynchronousLabelPropagationOptions,
|
|
81
|
+
} from "./label-propagation.js";
|
|
82
|
+
export { leiden, type LeidenOptions, type LeidenResult } from "./leiden.js";
|
|
83
|
+
export {
|
|
84
|
+
adamicAdarForPairs,
|
|
85
|
+
adamicAdarPrediction,
|
|
86
|
+
adamicAdarScore,
|
|
87
|
+
type CandidateOptions,
|
|
88
|
+
commonNeighborsForPairs,
|
|
89
|
+
commonNeighborsPrediction,
|
|
90
|
+
compareAdamicAdarWithCommonNeighbors,
|
|
91
|
+
evaluateAdamicAdar,
|
|
92
|
+
evaluateCommonNeighbors,
|
|
93
|
+
getTopAdamicAdarCandidatesForNode,
|
|
94
|
+
getTopCandidatesForNode,
|
|
95
|
+
type LinkPredictionMetrics,
|
|
96
|
+
type LinkPredictionOptions,
|
|
97
|
+
type LinkPredictionResult,
|
|
98
|
+
type NodePairs,
|
|
99
|
+
} from "./link-prediction.js";
|
|
23
100
|
export { louvain, type LouvainOptions, type LouvainResult } from "./louvain.js";
|
|
24
|
-
export {
|
|
25
|
-
export {
|
|
101
|
+
export { markovClustering, type MarkovOptions, type MarkovResult } from "./markov.js";
|
|
102
|
+
export {
|
|
103
|
+
type BipartiteMatchingOptions,
|
|
104
|
+
type BipartiteMatchingResult,
|
|
105
|
+
greedyBipartiteMatching,
|
|
106
|
+
maximumBipartiteMatching,
|
|
107
|
+
} from "./matching.js";
|
|
108
|
+
export { kargerMinCut, type KargerOptions, stoerWagner, type StoerWagnerOptions } from "./min-cut.js";
|
|
109
|
+
export { modularity, type ModularityOptions } from "./modularity.js";
|
|
110
|
+
export { kruskalMST, type MstOptions, type MstResult, primMST, type PrimOptions, type PrimResult } from "./mst.js";
|
|
111
|
+
export { pageRank, type PageRankOptions, type PageRankResult, personalizedPageRank } from "./pagerank.js";
|
|
112
|
+
export { astar, type AstarResult, bidirectionalDijkstra, type PathOptions, type PathResult } from "./point-to-point.js";
|
|
113
|
+
export { condensation, type CondensationResult, stronglyConnectedComponents } from "./scc.js";
|
|
114
|
+
export { type LaplacianType, spectralClustering, type SpectralOptions, type SpectralResult } from "./spectral.js";
|
|
26
115
|
export { arcSourceIn, IndexedMinHeap, IntUnionFind } from "./structures/index.js";
|
|
116
|
+
export { syncClustering, type SyncClusteringOptions, type SyncClusteringResult } from "./sync.js";
|
|
117
|
+
export { teraHAC, type TeraHacOptions, type TeraHacResult } from "./terahac.js";
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import { type AdjacencyView, type GraphSnapshot, INVALID_INDEX, type U32 } from "@graphty/graph-format";
|
|
2
|
+
|
|
3
|
+
/** Options of {@link isGraphIsomorphic} and {@link findAllIsomorphisms}. @public */
|
|
4
|
+
export interface IsomorphismOptions {
|
|
5
|
+
/** Whether node `i1` of `s1` may map to node `i2` of `s2`. */
|
|
6
|
+
readonly nodeMatch?: ((i1: number, i2: number, s1: GraphSnapshot, s2: GraphSnapshot) => boolean) | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Whether logical edge `e1` of `s1` may map to logical edge `e2` of `s2`. Called once for every
|
|
9
|
+
* pair of adjacent nodes, when the second of them is mapped, and once for a self-loop, when its
|
|
10
|
+
* node is mapped; between parallel edges it sees the lowest edge index. On a directed snapshot
|
|
11
|
+
* it sees every arc, whichever end is mapped last.
|
|
12
|
+
*/
|
|
13
|
+
readonly edgeMatch?: ((e1: number, e2: number, s1: GraphSnapshot, s2: GraphSnapshot) => boolean) | undefined;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Result of {@link isGraphIsomorphic}. @public */
|
|
17
|
+
export interface IsomorphismResult {
|
|
18
|
+
/** Whether the two graphs are isomorphic. */
|
|
19
|
+
readonly isomorphic: boolean;
|
|
20
|
+
/** The image in `s2` of every node of `s1`; null when not isomorphic. */
|
|
21
|
+
readonly mapping: U32 | null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Count the distinct neighbours of `u` other than itself in one adjacency.
|
|
26
|
+
* @param view - The adjacency to read the row of
|
|
27
|
+
* @param u - The node
|
|
28
|
+
* @returns The simple degree, and whether `u` has a self-loop
|
|
29
|
+
*/
|
|
30
|
+
function simpleDegree(view: AdjacencyView, u: number): { degree: number; loop: boolean } {
|
|
31
|
+
let degree = 0;
|
|
32
|
+
let loop = false;
|
|
33
|
+
let prev = INVALID_INDEX;
|
|
34
|
+
for (let a = view.rowPtr[u]; a < view.rowPtr[u + 1]; a++) {
|
|
35
|
+
const v = view.colIdx[a];
|
|
36
|
+
if (v === prev) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
prev = v;
|
|
40
|
+
if (v === u) {
|
|
41
|
+
loop = true;
|
|
42
|
+
} else {
|
|
43
|
+
degree++;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return { degree, loop };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A per-node signature a node and its image must share: simple out-degree, simple in-degree
|
|
51
|
+
* (directed only) and the self-loop bit, packed in one number.
|
|
52
|
+
* @param s - The snapshot
|
|
53
|
+
* @returns One signature per node
|
|
54
|
+
*/
|
|
55
|
+
function signatures(s: GraphSnapshot): Float64Array {
|
|
56
|
+
const out = new Float64Array(s.nodeCount);
|
|
57
|
+
const rev = s.directed ? s.reverse() : null;
|
|
58
|
+
for (let u = 0; u < s.nodeCount; u++) {
|
|
59
|
+
const f = simpleDegree(s, u);
|
|
60
|
+
const inDegree = rev === null ? 0 : simpleDegree(rev, u).degree;
|
|
61
|
+
out[u] = (f.degree * 2 ** 26 + inDegree) * 2 + (f.loop ? 1 : 0);
|
|
62
|
+
}
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The order the nodes of `s1` are mapped in: BFS over out- and in-arcs, one component after another
|
|
68
|
+
* from the lowest unvisited index. Every node after a component's first is adjacent to an earlier
|
|
69
|
+
* one (its parent), so its candidates are the neighbours of the parent's image.
|
|
70
|
+
* @param views - The forward adjacency, and on a directed snapshot the reverse one
|
|
71
|
+
* @param n - The node count
|
|
72
|
+
* @returns The order, each node's BFS parent (INVALID_INDEX for a component's first node) and
|
|
73
|
+
* which view the parent reached it through
|
|
74
|
+
*/
|
|
75
|
+
function matchOrder(views: readonly AdjacencyView[], n: number): { order: U32; parent: U32; parentView: Uint8Array } {
|
|
76
|
+
const order = new Uint32Array(n);
|
|
77
|
+
const parent = new Uint32Array(n).fill(INVALID_INDEX);
|
|
78
|
+
const parentView = new Uint8Array(n);
|
|
79
|
+
const seen = new Uint8Array(n);
|
|
80
|
+
let tail = 0;
|
|
81
|
+
for (let r = 0; r < n; r++) {
|
|
82
|
+
if (seen[r] === 1) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
seen[r] = 1;
|
|
86
|
+
let head = tail;
|
|
87
|
+
order[tail++] = r;
|
|
88
|
+
while (head < tail) {
|
|
89
|
+
const u = order[head++];
|
|
90
|
+
for (let k = 0; k < views.length; k++) {
|
|
91
|
+
const { rowPtr, colIdx } = views[k];
|
|
92
|
+
for (let a = rowPtr[u]; a < rowPtr[u + 1]; a++) {
|
|
93
|
+
const v = colIdx[a];
|
|
94
|
+
if (seen[v] === 0) {
|
|
95
|
+
seen[v] = 1;
|
|
96
|
+
parent[v] = u;
|
|
97
|
+
parentView[v] = k;
|
|
98
|
+
order[tail++] = v;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return { order, parent, parentView };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* VF2-style depth-first search for isomorphisms from `s1` to `s2`.
|
|
109
|
+
* @param s1 - The first graph
|
|
110
|
+
* @param s2 - The second graph
|
|
111
|
+
* @param options - Node and edge match predicates
|
|
112
|
+
* @param found - Called with every isomorphism (a live array: copy it to keep it); returning true
|
|
113
|
+
* stops the search
|
|
114
|
+
*/
|
|
115
|
+
function search(
|
|
116
|
+
s1: GraphSnapshot,
|
|
117
|
+
s2: GraphSnapshot,
|
|
118
|
+
options: IsomorphismOptions,
|
|
119
|
+
found: (mapping: U32) => boolean,
|
|
120
|
+
): void {
|
|
121
|
+
const n = s1.nodeCount;
|
|
122
|
+
if (s1.directed !== s2.directed || n !== s2.nodeCount) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const sig1 = signatures(s1);
|
|
126
|
+
const sig2 = signatures(s2);
|
|
127
|
+
const sorted1 = sig1.slice().sort();
|
|
128
|
+
const sorted2 = sig2.slice().sort();
|
|
129
|
+
if (sorted1.some((x, i) => x !== sorted2[i])) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const views1: AdjacencyView[] = s1.directed ? [s1, s1.reverse()] : [s1];
|
|
133
|
+
const views2: AdjacencyView[] = s2.directed ? [s2, s2.reverse()] : [s2];
|
|
134
|
+
const { order, parent, parentView } = matchOrder(views1, n);
|
|
135
|
+
const core1 = new Uint32Array(n).fill(INVALID_INDEX);
|
|
136
|
+
const core2 = new Uint32Array(n).fill(INVALID_INDEX);
|
|
137
|
+
// Per view, the arc of s2 from the candidate to each neighbour, stamped with the search step.
|
|
138
|
+
const stamp = views2.map(() => new Uint32Array(n));
|
|
139
|
+
const arcTo = views2.map(() => new Uint32Array(n));
|
|
140
|
+
let step = 0;
|
|
141
|
+
const { nodeMatch, edgeMatch } = options;
|
|
142
|
+
|
|
143
|
+
const feasible = (u1: number, u2: number): boolean => {
|
|
144
|
+
if (sig1[u1] !== sig2[u2] || (nodeMatch !== undefined && !nodeMatch(u1, u2, s1, s2))) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
// The signatures agree, so u1 has a self-loop exactly when u2 has one: offer the two loops.
|
|
148
|
+
if (edgeMatch !== undefined && sig1[u1] % 2 === 1) {
|
|
149
|
+
const loop1 = s1.arcToEdge[s1.findArc(u1, u1)];
|
|
150
|
+
const loop2 = s2.arcToEdge[s2.findArc(u2, u2)];
|
|
151
|
+
if (!edgeMatch(loop1, loop2, s1, s2)) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
step++;
|
|
156
|
+
for (let k = 0; k < views1.length; k++) {
|
|
157
|
+
const g1 = views1[k];
|
|
158
|
+
const g2 = views2[k];
|
|
159
|
+
let mapped2 = 0;
|
|
160
|
+
let prev = INVALID_INDEX;
|
|
161
|
+
for (let a = g2.rowPtr[u2]; a < g2.rowPtr[u2 + 1]; a++) {
|
|
162
|
+
const v = g2.colIdx[a];
|
|
163
|
+
if (v === prev || v === u2) {
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
prev = v;
|
|
167
|
+
stamp[k][v] = step;
|
|
168
|
+
arcTo[k][v] = a;
|
|
169
|
+
if (core2[v] !== INVALID_INDEX) {
|
|
170
|
+
mapped2++;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
let mapped1 = 0;
|
|
174
|
+
prev = INVALID_INDEX;
|
|
175
|
+
for (let a = g1.rowPtr[u1]; a < g1.rowPtr[u1 + 1]; a++) {
|
|
176
|
+
const v = g1.colIdx[a];
|
|
177
|
+
if (v === prev || v === u1) {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
prev = v;
|
|
181
|
+
const image = core1[v];
|
|
182
|
+
if (image === INVALID_INDEX) {
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
if (stamp[k][image] !== step) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
mapped1++;
|
|
189
|
+
// An undirected edge is offered once: through the out-rows. A directed arc is
|
|
190
|
+
// offered through the view it is an out-arc or an in-arc of the new node in.
|
|
191
|
+
if (edgeMatch !== undefined && !edgeMatch(g1.arcToEdge[a], g2.arcToEdge[arcTo[k][image]], s1, s2)) {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (mapped1 !== mapped2) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return true;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
// Iterative DFS over depth; cursor[d] walks the candidate list of order[d].
|
|
203
|
+
const cursor = new Uint32Array(n + 1);
|
|
204
|
+
let depth = 0;
|
|
205
|
+
let stop = false;
|
|
206
|
+
const candidatesOf = (d: number): { view: AdjacencyView | null; from: number; to: number } => {
|
|
207
|
+
const p = parent[order[d]];
|
|
208
|
+
if (p === INVALID_INDEX) {
|
|
209
|
+
return { view: null, from: 0, to: n };
|
|
210
|
+
}
|
|
211
|
+
const view = views2[parentView[order[d]]];
|
|
212
|
+
const image = core1[p];
|
|
213
|
+
return { view, from: view.rowPtr[image], to: view.rowPtr[image + 1] };
|
|
214
|
+
};
|
|
215
|
+
if (n === 0) {
|
|
216
|
+
found(core1);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
let range = candidatesOf(0);
|
|
220
|
+
cursor[0] = range.from;
|
|
221
|
+
while (!stop) {
|
|
222
|
+
const u1 = order[depth];
|
|
223
|
+
let advanced = false;
|
|
224
|
+
while (cursor[depth] < range.to) {
|
|
225
|
+
const c = cursor[depth]++;
|
|
226
|
+
const u2 = range.view === null ? c : range.view.colIdx[c];
|
|
227
|
+
// Parallel arcs repeat a candidate; take it once.
|
|
228
|
+
if (range.view !== null && c > range.from && range.view.colIdx[c - 1] === u2) {
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
if (core2[u2] !== INVALID_INDEX || !feasible(u1, u2)) {
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
core1[u1] = u2;
|
|
235
|
+
core2[u2] = u1;
|
|
236
|
+
if (depth === n - 1) {
|
|
237
|
+
stop = found(core1);
|
|
238
|
+
core1[u1] = INVALID_INDEX;
|
|
239
|
+
core2[u2] = INVALID_INDEX;
|
|
240
|
+
if (stop) {
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
depth++;
|
|
246
|
+
range = candidatesOf(depth);
|
|
247
|
+
cursor[depth] = range.from;
|
|
248
|
+
advanced = true;
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
if (stop || advanced) {
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
// Exhausted: undo the mapping of the node below and resume its candidates.
|
|
255
|
+
if (depth === 0) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
depth--;
|
|
259
|
+
const back = order[depth];
|
|
260
|
+
core2[core1[back]] = INVALID_INDEX;
|
|
261
|
+
core1[back] = INVALID_INDEX;
|
|
262
|
+
range = candidatesOf(depth);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Whether two snapshots are isomorphic, by a VF2-style search. Neighbourhoods are simple-graph:
|
|
268
|
+
* parallel arcs count once and a self-loop maps only to a self-loop. On a directed snapshot both
|
|
269
|
+
* arc directions are preserved.
|
|
270
|
+
* @param s1 - The first graph
|
|
271
|
+
* @param s2 - The second graph
|
|
272
|
+
* @param options - Node and edge match predicates
|
|
273
|
+
* @returns Whether an isomorphism exists and, when it does, the first one found
|
|
274
|
+
* @public
|
|
275
|
+
*/
|
|
276
|
+
export function isGraphIsomorphic(
|
|
277
|
+
s1: GraphSnapshot,
|
|
278
|
+
s2: GraphSnapshot,
|
|
279
|
+
options: IsomorphismOptions = {},
|
|
280
|
+
): IsomorphismResult {
|
|
281
|
+
let mapping: U32 | null = null;
|
|
282
|
+
search(s1, s2, options, (m) => {
|
|
283
|
+
mapping = m.slice();
|
|
284
|
+
return true;
|
|
285
|
+
});
|
|
286
|
+
return { isomorphic: mapping !== null, mapping };
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Every isomorphism from `s1` to `s2`, with the neighbourhood rules of {@link isGraphIsomorphic}.
|
|
291
|
+
* Two empty graphs have one, the empty mapping.
|
|
292
|
+
* @param s1 - The first graph
|
|
293
|
+
* @param s2 - The second graph
|
|
294
|
+
* @param options - Node and edge match predicates
|
|
295
|
+
* @returns One array per isomorphism: the image in `s2` of every node of `s1`
|
|
296
|
+
* @public
|
|
297
|
+
*/
|
|
298
|
+
export function findAllIsomorphisms(s1: GraphSnapshot, s2: GraphSnapshot, options: IsomorphismOptions = {}): U32[] {
|
|
299
|
+
const all: U32[] = [];
|
|
300
|
+
search(s1, s2, options, (m) => {
|
|
301
|
+
all.push(m.slice());
|
|
302
|
+
return false;
|
|
303
|
+
});
|
|
304
|
+
return all;
|
|
305
|
+
}
|