@graphty/algorithms 2.1.2 → 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,386 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Perform Markov Clustering on a graph
|
|
3
|
+
* @param graph - The input graph to cluster
|
|
4
|
+
* @param options - MCL algorithm options (expansion, inflation, iterations, etc.)
|
|
5
|
+
* @returns MCL clustering result with communities, attractors, and convergence info
|
|
6
|
+
*/
|
|
7
|
+
export function markovClustering(graph, options = {}) {
|
|
8
|
+
const { expansion = 2, inflation = 2, maxIterations = 100, tolerance = 1e-6, pruningThreshold = 1e-5, selfLoops = true, } = options;
|
|
9
|
+
const nodes = Array.from(graph.nodes());
|
|
10
|
+
const nodeIds = nodes.map((node) => node.id);
|
|
11
|
+
const n = nodeIds.length;
|
|
12
|
+
if (n === 0) {
|
|
13
|
+
return {
|
|
14
|
+
communities: [],
|
|
15
|
+
attractors: new Set(),
|
|
16
|
+
iterations: 0,
|
|
17
|
+
converged: true,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
// Build initial transition matrix
|
|
21
|
+
let matrix = buildTransitionMatrix(graph, nodeIds, selfLoops);
|
|
22
|
+
let converged = false;
|
|
23
|
+
let iteration = 0;
|
|
24
|
+
for (iteration = 0; iteration < maxIterations; iteration++) {
|
|
25
|
+
const oldMatrix = matrix.map((row) => [...row]);
|
|
26
|
+
// Expansion step (matrix multiplication)
|
|
27
|
+
matrix = matrixPower(matrix, expansion);
|
|
28
|
+
// Inflation step (element-wise powering and column normalization)
|
|
29
|
+
matrix = inflate(matrix, inflation);
|
|
30
|
+
// Pruning step (remove small values)
|
|
31
|
+
matrix = prune(matrix, pruningThreshold);
|
|
32
|
+
// Check for convergence
|
|
33
|
+
if (hasConverged(oldMatrix, matrix, tolerance)) {
|
|
34
|
+
converged = true;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// Extract clusters from final matrix
|
|
39
|
+
const { communities, attractors } = extractClusters(matrix, nodeIds);
|
|
40
|
+
return {
|
|
41
|
+
communities,
|
|
42
|
+
attractors,
|
|
43
|
+
iterations: iteration + 1,
|
|
44
|
+
converged,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Build initial transition matrix from graph
|
|
49
|
+
* @param graph - The input graph
|
|
50
|
+
* @param nodeIds - Array of node IDs in the graph
|
|
51
|
+
* @param selfLoops - Whether to add self-loops to the matrix
|
|
52
|
+
* @returns Column-normalized transition matrix
|
|
53
|
+
*/
|
|
54
|
+
function buildTransitionMatrix(graph, nodeIds, selfLoops) {
|
|
55
|
+
const n = nodeIds.length;
|
|
56
|
+
const matrix = Array.from({ length: n }, () => Array(n).fill(0));
|
|
57
|
+
const nodeToIndex = new Map();
|
|
58
|
+
nodeIds.forEach((id, index) => nodeToIndex.set(id, index));
|
|
59
|
+
// Fill adjacency values
|
|
60
|
+
for (let i = 0; i < n; i++) {
|
|
61
|
+
const nodeId = nodeIds[i];
|
|
62
|
+
if (nodeId === undefined) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const neighbors = graph.neighbors(nodeId);
|
|
66
|
+
for (const neighbor of neighbors) {
|
|
67
|
+
const j = nodeToIndex.get(neighbor);
|
|
68
|
+
if (j !== undefined) {
|
|
69
|
+
const edge = graph.getEdge(nodeId, neighbor);
|
|
70
|
+
const weight = edge?.weight ?? 1;
|
|
71
|
+
const row = matrix[i];
|
|
72
|
+
if (!row) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
row[j] = weight;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Add self-loops
|
|
79
|
+
if (selfLoops) {
|
|
80
|
+
const row = matrix[i];
|
|
81
|
+
if (!row) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
row[i] = 1;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// Column-normalize the matrix
|
|
88
|
+
for (let j = 0; j < n; j++) {
|
|
89
|
+
let colSum = 0;
|
|
90
|
+
for (let i = 0; i < n; i++) {
|
|
91
|
+
const val = matrix[i]?.[j];
|
|
92
|
+
if (val !== undefined) {
|
|
93
|
+
colSum += val;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (colSum > 0) {
|
|
97
|
+
for (let i = 0; i < n; i++) {
|
|
98
|
+
const row = matrix[i];
|
|
99
|
+
if (!row) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const val = row[j];
|
|
103
|
+
if (val !== undefined) {
|
|
104
|
+
row[j] = val / colSum;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return matrix;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Raise matrix to a power (for expansion step)
|
|
113
|
+
* @param matrix - Input square matrix
|
|
114
|
+
* @param power - Power to raise the matrix to
|
|
115
|
+
* @returns Matrix raised to the specified power
|
|
116
|
+
*/
|
|
117
|
+
function matrixPower(matrix, power) {
|
|
118
|
+
if (power === 1) {
|
|
119
|
+
return matrix;
|
|
120
|
+
}
|
|
121
|
+
if (power === 2) {
|
|
122
|
+
return matrixMultiply(matrix, matrix);
|
|
123
|
+
}
|
|
124
|
+
let result = matrix;
|
|
125
|
+
for (let i = 1; i < power; i++) {
|
|
126
|
+
result = matrixMultiply(result, matrix);
|
|
127
|
+
}
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Multiply two matrices
|
|
132
|
+
* @param a - First matrix
|
|
133
|
+
* @param b - Second matrix
|
|
134
|
+
* @returns Product matrix a * b
|
|
135
|
+
*/
|
|
136
|
+
function matrixMultiply(a, b) {
|
|
137
|
+
const n = a.length;
|
|
138
|
+
const m = b[0]?.length ?? 0;
|
|
139
|
+
const p = b.length;
|
|
140
|
+
const result = Array.from({ length: n }, () => Array(m).fill(0));
|
|
141
|
+
for (let i = 0; i < n; i++) {
|
|
142
|
+
for (let j = 0; j < m; j++) {
|
|
143
|
+
for (let k = 0; k < p; k++) {
|
|
144
|
+
const aVal = a[i]?.[k] ?? 0;
|
|
145
|
+
const bVal = b[k]?.[j] ?? 0;
|
|
146
|
+
const resultRow = result[i];
|
|
147
|
+
if (!resultRow) {
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
const prevVal = resultRow[j];
|
|
151
|
+
if (prevVal !== undefined) {
|
|
152
|
+
resultRow[j] = prevVal + aVal * bVal;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Inflation step: element-wise powering and column normalization
|
|
161
|
+
* @param matrix - Input matrix to inflate
|
|
162
|
+
* @param inflation - Inflation parameter for element-wise powering
|
|
163
|
+
* @returns Inflated and column-normalized matrix
|
|
164
|
+
*/
|
|
165
|
+
function inflate(matrix, inflation) {
|
|
166
|
+
const n = matrix.length;
|
|
167
|
+
const result = Array.from({ length: n }, () => Array(n).fill(0));
|
|
168
|
+
// Element-wise powering
|
|
169
|
+
for (let i = 0; i < n; i++) {
|
|
170
|
+
for (let j = 0; j < n; j++) {
|
|
171
|
+
const val = matrix[i]?.[j];
|
|
172
|
+
if (val !== undefined) {
|
|
173
|
+
const resultRow = result[i];
|
|
174
|
+
if (resultRow) {
|
|
175
|
+
resultRow[j] = Math.pow(val, inflation);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// Column normalization
|
|
181
|
+
for (let j = 0; j < n; j++) {
|
|
182
|
+
let colSum = 0;
|
|
183
|
+
for (let i = 0; i < n; i++) {
|
|
184
|
+
const val = result[i]?.[j];
|
|
185
|
+
if (val !== undefined) {
|
|
186
|
+
colSum += val;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (colSum > 0) {
|
|
190
|
+
for (let i = 0; i < n; i++) {
|
|
191
|
+
const row = result[i];
|
|
192
|
+
if (!row) {
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
const val = row[j];
|
|
196
|
+
if (val !== undefined) {
|
|
197
|
+
row[j] = val / colSum;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return result;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Pruning step: remove small values
|
|
206
|
+
* @param matrix - Input matrix to prune
|
|
207
|
+
* @param threshold - Values below this threshold are set to zero
|
|
208
|
+
* @returns Pruned and re-normalized matrix
|
|
209
|
+
*/
|
|
210
|
+
function prune(matrix, threshold) {
|
|
211
|
+
const n = matrix.length;
|
|
212
|
+
const result = Array.from({ length: n }, () => Array(n).fill(0));
|
|
213
|
+
for (let i = 0; i < n; i++) {
|
|
214
|
+
for (let j = 0; j < n; j++) {
|
|
215
|
+
const matrixRow = matrix[i];
|
|
216
|
+
if (!matrixRow) {
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
const matrixVal = matrixRow[j];
|
|
220
|
+
if (matrixVal !== undefined && matrixVal >= threshold) {
|
|
221
|
+
const resultRow = result[i];
|
|
222
|
+
if (resultRow) {
|
|
223
|
+
resultRow[j] = matrixVal;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
// Re-normalize columns after pruning
|
|
229
|
+
for (let j = 0; j < n; j++) {
|
|
230
|
+
let colSum = 0;
|
|
231
|
+
for (let i = 0; i < n; i++) {
|
|
232
|
+
const resultRow = result[i];
|
|
233
|
+
if (!resultRow) {
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
const val = resultRow[j];
|
|
237
|
+
if (val !== undefined) {
|
|
238
|
+
colSum += val;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (colSum > 0) {
|
|
242
|
+
for (let i = 0; i < n; i++) {
|
|
243
|
+
const resultRow = result[i];
|
|
244
|
+
if (!resultRow) {
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
const val = resultRow[j];
|
|
248
|
+
if (val !== undefined) {
|
|
249
|
+
resultRow[j] = val / colSum;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return result;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Check if the algorithm has converged
|
|
258
|
+
* @param oldMatrix - Matrix from previous iteration
|
|
259
|
+
* @param newMatrix - Matrix from current iteration
|
|
260
|
+
* @param tolerance - Convergence tolerance threshold
|
|
261
|
+
* @returns True if the maximum difference between matrices is below tolerance
|
|
262
|
+
*/
|
|
263
|
+
function hasConverged(oldMatrix, newMatrix, tolerance) {
|
|
264
|
+
const n = oldMatrix.length;
|
|
265
|
+
for (let i = 0; i < n; i++) {
|
|
266
|
+
for (let j = 0; j < n; j++) {
|
|
267
|
+
const oldRow = oldMatrix[i];
|
|
268
|
+
const newRow = newMatrix[i];
|
|
269
|
+
if (!oldRow || !newRow) {
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
const oldVal = oldRow[j];
|
|
273
|
+
const newVal = newRow[j];
|
|
274
|
+
if (oldVal !== undefined && newVal !== undefined && Math.abs(oldVal - newVal) > tolerance) {
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return true;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Extract clusters from the final matrix
|
|
283
|
+
* @param matrix - Final converged MCL matrix
|
|
284
|
+
* @param nodeIds - Array of node IDs corresponding to matrix indices
|
|
285
|
+
* @returns Object containing communities and attractor nodes
|
|
286
|
+
*/
|
|
287
|
+
function extractClusters(matrix, nodeIds) {
|
|
288
|
+
const n = matrix.length;
|
|
289
|
+
const attractors = new Set();
|
|
290
|
+
const communities = [];
|
|
291
|
+
const nodeToCluster = new Map();
|
|
292
|
+
// Find attractors (columns with non-zero diagonal elements)
|
|
293
|
+
for (let i = 0; i < n; i++) {
|
|
294
|
+
const matrixRow = matrix[i];
|
|
295
|
+
if (!matrixRow) {
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
const diagonalVal = matrixRow[i];
|
|
299
|
+
const nodeId = nodeIds[i];
|
|
300
|
+
if (diagonalVal !== undefined && diagonalVal > 0 && nodeId !== undefined) {
|
|
301
|
+
attractors.add(nodeId);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
// Assign nodes (columns) to clusters based on which attractor (row) they flow to
|
|
305
|
+
// After MCL convergence, matrix[i][j] > 0 means node j belongs to attractor i's cluster
|
|
306
|
+
const attractorToCommunity = new Map();
|
|
307
|
+
for (let j = 0; j < n; j++) {
|
|
308
|
+
// Find the attractor for this column (node j)
|
|
309
|
+
// Look for the row with the highest non-zero value in column j
|
|
310
|
+
let maxVal = 0;
|
|
311
|
+
let attractorRow = -1;
|
|
312
|
+
for (let i = 0; i < n; i++) {
|
|
313
|
+
const matrixRow = matrix[i];
|
|
314
|
+
if (!matrixRow) {
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
const val = matrixRow[j];
|
|
318
|
+
if (val !== undefined && val > maxVal) {
|
|
319
|
+
maxVal = val;
|
|
320
|
+
attractorRow = i;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
if (attractorRow >= 0) {
|
|
324
|
+
// Node j belongs to the cluster of attractor at row attractorRow
|
|
325
|
+
let community = attractorToCommunity.get(attractorRow);
|
|
326
|
+
if (!community) {
|
|
327
|
+
community = [];
|
|
328
|
+
attractorToCommunity.set(attractorRow, community);
|
|
329
|
+
}
|
|
330
|
+
community.push(j);
|
|
331
|
+
nodeToCluster.set(j, attractorRow);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
// Convert attractor communities to node ID arrays
|
|
335
|
+
for (const [, memberIndices] of attractorToCommunity) {
|
|
336
|
+
communities.push(memberIndices
|
|
337
|
+
.map((idx) => {
|
|
338
|
+
const nodeId = nodeIds[idx];
|
|
339
|
+
return nodeId;
|
|
340
|
+
})
|
|
341
|
+
.filter((node) => node !== undefined));
|
|
342
|
+
}
|
|
343
|
+
// Handle isolated nodes (nodes with all-zero columns)
|
|
344
|
+
for (let j = 0; j < n; j++) {
|
|
345
|
+
if (!nodeToCluster.has(j)) {
|
|
346
|
+
const nodeId = nodeIds[j];
|
|
347
|
+
if (nodeId !== undefined) {
|
|
348
|
+
communities.push([nodeId]);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return { communities, attractors };
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Calculate modularity of MCL clustering result
|
|
356
|
+
* @param graph - The original graph that was clustered
|
|
357
|
+
* @param communities - Array of communities (each community is an array of node IDs)
|
|
358
|
+
* @returns Modularity score between -0.5 and 1.0
|
|
359
|
+
*/
|
|
360
|
+
export function calculateMCLModularity(graph, communities) {
|
|
361
|
+
const m = graph.totalEdgeCount;
|
|
362
|
+
if (m === 0) {
|
|
363
|
+
return 0;
|
|
364
|
+
}
|
|
365
|
+
let modularity = 0;
|
|
366
|
+
const communityMap = new Map();
|
|
367
|
+
// Build community map
|
|
368
|
+
communities.forEach((community, index) => {
|
|
369
|
+
community.forEach((nodeId) => {
|
|
370
|
+
communityMap.set(nodeId, index);
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
// Calculate modularity
|
|
374
|
+
for (const edge of graph.edges()) {
|
|
375
|
+
const sourceCommunity = communityMap.get(edge.source);
|
|
376
|
+
const targetCommunity = communityMap.get(edge.target);
|
|
377
|
+
if (sourceCommunity !== undefined && targetCommunity !== undefined && sourceCommunity === targetCommunity) {
|
|
378
|
+
modularity += 1;
|
|
379
|
+
}
|
|
380
|
+
const sourceDegree = graph.degree(edge.source);
|
|
381
|
+
const targetDegree = graph.degree(edge.target);
|
|
382
|
+
modularity -= (sourceDegree * targetDegree) / (2 * m);
|
|
383
|
+
}
|
|
384
|
+
return modularity / (2 * m);
|
|
385
|
+
}
|
|
386
|
+
//# sourceMappingURL=mcl-legacy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcl-legacy.js","sourceRoot":"","sources":["../../../src/clustering/mcl-legacy.ts"],"names":[],"mappings":"AA+BA;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAY,EAAE,UAAsB,EAAE;IACnE,MAAM,EACF,SAAS,GAAG,CAAC,EACb,SAAS,GAAG,CAAC,EACb,aAAa,GAAG,GAAG,EACnB,SAAS,GAAG,IAAI,EAChB,gBAAgB,GAAG,IAAI,EACvB,SAAS,GAAG,IAAI,GACnB,GAAG,OAAO,CAAC;IAEZ,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7C,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAEzB,IAAI,CAAC,KA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*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* inflation (element-wise powering and normalization).
|
|
10
|
-
*
|
|
11
|
-
* Time complexity: O(V³) per iteration
|
|
12
|
-
* Space complexity: O(V²)
|
|
2
|
+
* Markov Clustering (MCL) over a legacy `Graph`. `markovClustering` delegates to
|
|
3
|
+
* `indexed.markovClustering` through `toSnapshot`, with the graph's exact f64 weights; the result
|
|
4
|
+
* equals the pre-migration implementation in `mcl-legacy.ts` exactly. Parameters or weights the port
|
|
5
|
+
* refuses (a fractional expansion, a negative, infinite or NaN weight, an undirected edge whose two
|
|
6
|
+
* stored halves carry different weights, ...) keep the old code.
|
|
13
7
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
tolerance?: number;
|
|
19
|
-
pruningThreshold?: number;
|
|
20
|
-
selfLoops?: boolean;
|
|
21
|
-
}
|
|
22
|
-
export interface MCLResult {
|
|
23
|
-
communities: NodeId[][];
|
|
24
|
-
attractors: Set<NodeId>;
|
|
25
|
-
iterations: number;
|
|
26
|
-
converged: boolean;
|
|
27
|
-
}
|
|
8
|
+
import type { Graph } from "../core/graph.js";
|
|
9
|
+
import { type MCLOptions, type MCLResult } from "./mcl-legacy.js";
|
|
10
|
+
export type { MCLOptions, MCLResult } from "./mcl-legacy.js";
|
|
11
|
+
export { calculateMCLModularity } from "./mcl-legacy.js";
|
|
28
12
|
/**
|
|
29
13
|
* Perform Markov Clustering on a graph
|
|
30
14
|
* @param graph - The input graph to cluster
|
|
@@ -32,11 +16,4 @@ export interface MCLResult {
|
|
|
32
16
|
* @returns MCL clustering result with communities, attractors, and convergence info
|
|
33
17
|
*/
|
|
34
18
|
export declare function markovClustering(graph: Graph, options?: MCLOptions): MCLResult;
|
|
35
|
-
/**
|
|
36
|
-
* Calculate modularity of MCL clustering result
|
|
37
|
-
* @param graph - The original graph that was clustered
|
|
38
|
-
* @param communities - Array of communities (each community is an array of node IDs)
|
|
39
|
-
* @returns Modularity score between -0.5 and 1.0
|
|
40
|
-
*/
|
|
41
|
-
export declare function calculateMCLModularity(graph: Graph, communities: NodeId[][]): number;
|
|
42
19
|
//# sourceMappingURL=mcl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcl.d.ts","sourceRoot":"","sources":["../../../src/clustering/mcl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"mcl.d.ts","sourceRoot":"","sources":["../../../src/clustering/mcl.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAI9C,OAAO,EAA8C,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE9G,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AA8BzD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,GAAE,UAAe,GAAG,SAAS,CAalF"}
|