@graphty/algorithms 1.0.1 → 1.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 +1259 -61
- package/dist/algorithms.d.ts +2 -0
- package/dist/algorithms.d.ts.map +1 -0
- package/dist/algorithms.js +2 -0
- package/dist/algorithms.js.map +1 -0
- package/dist/src/algorithms/centrality/betweenness.d.ts.map +1 -1
- package/dist/src/algorithms/centrality/betweenness.js +22 -7
- package/dist/src/algorithms/centrality/betweenness.js.map +1 -1
- package/dist/src/algorithms/centrality/closeness.js +7 -7
- package/dist/src/algorithms/centrality/closeness.js.map +1 -1
- package/dist/src/algorithms/centrality/degree.js +1 -1
- package/dist/src/algorithms/centrality/degree.js.map +1 -1
- package/dist/src/algorithms/centrality/eigenvector.d.ts +27 -0
- package/dist/src/algorithms/centrality/eigenvector.d.ts.map +1 -0
- package/dist/src/algorithms/centrality/eigenvector.js +113 -0
- package/dist/src/algorithms/centrality/eigenvector.js.map +1 -0
- package/dist/src/algorithms/centrality/hits.d.ts +35 -0
- package/dist/src/algorithms/centrality/hits.d.ts.map +1 -0
- package/dist/src/algorithms/centrality/hits.js +146 -0
- package/dist/src/algorithms/centrality/hits.js.map +1 -0
- package/dist/src/algorithms/centrality/index.d.ts +6 -0
- package/dist/src/algorithms/centrality/index.d.ts.map +1 -1
- package/dist/src/algorithms/centrality/index.js +3 -0
- package/dist/src/algorithms/centrality/index.js.map +1 -1
- package/dist/src/algorithms/centrality/katz.d.ts +30 -0
- package/dist/src/algorithms/centrality/katz.d.ts.map +1 -0
- package/dist/src/algorithms/centrality/katz.js +85 -0
- package/dist/src/algorithms/centrality/katz.js.map +1 -0
- package/dist/src/algorithms/centrality/pagerank.js +3 -3
- package/dist/src/algorithms/centrality/pagerank.js.map +1 -1
- package/dist/src/algorithms/community/girvan-newman.d.ts +23 -0
- package/dist/src/algorithms/community/girvan-newman.d.ts.map +1 -0
- package/dist/src/algorithms/community/girvan-newman.js +297 -0
- package/dist/src/algorithms/community/girvan-newman.js.map +1 -0
- package/dist/src/algorithms/community/index.d.ts +12 -0
- package/dist/src/algorithms/community/index.d.ts.map +1 -0
- package/dist/src/algorithms/community/index.js +12 -0
- package/dist/src/algorithms/community/index.js.map +1 -0
- package/dist/src/algorithms/community/label-propagation.d.ts +42 -0
- package/dist/src/algorithms/community/label-propagation.d.ts.map +1 -0
- package/dist/src/algorithms/community/label-propagation.js +307 -0
- package/dist/src/algorithms/community/label-propagation.js.map +1 -0
- package/dist/src/algorithms/community/leiden.d.ts +33 -0
- package/dist/src/algorithms/community/leiden.d.ts.map +1 -0
- package/dist/src/algorithms/community/leiden.js +434 -0
- package/dist/src/algorithms/community/leiden.js.map +1 -0
- package/dist/src/algorithms/community/louvain.d.ts +19 -0
- package/dist/src/algorithms/community/louvain.d.ts.map +1 -0
- package/dist/src/algorithms/community/louvain.js +219 -0
- package/dist/src/algorithms/community/louvain.js.map +1 -0
- package/dist/src/algorithms/components/connected.js +7 -7
- package/dist/src/algorithms/components/connected.js.map +1 -1
- package/dist/src/algorithms/index.d.ts +7 -0
- package/dist/src/algorithms/index.d.ts.map +1 -1
- package/dist/src/algorithms/index.js +14 -0
- package/dist/src/algorithms/index.js.map +1 -1
- package/dist/src/algorithms/matching/bipartite.d.ts +37 -0
- package/dist/src/algorithms/matching/bipartite.d.ts.map +1 -0
- package/dist/src/algorithms/matching/bipartite.js +127 -0
- package/dist/src/algorithms/matching/bipartite.js.map +1 -0
- package/dist/src/algorithms/matching/index.d.ts +8 -0
- package/dist/src/algorithms/matching/index.d.ts.map +1 -0
- package/dist/src/algorithms/matching/index.js +6 -0
- package/dist/src/algorithms/matching/index.js.map +1 -0
- package/dist/src/algorithms/matching/isomorphism.d.ts +32 -0
- package/dist/src/algorithms/matching/isomorphism.d.ts.map +1 -0
- package/dist/src/algorithms/matching/isomorphism.js +291 -0
- package/dist/src/algorithms/matching/isomorphism.js.map +1 -0
- package/dist/src/algorithms/mst/index.d.ts +4 -0
- package/dist/src/algorithms/mst/index.d.ts.map +1 -0
- package/dist/src/algorithms/mst/index.js +3 -0
- package/dist/src/algorithms/mst/index.js.map +1 -0
- package/dist/src/algorithms/mst/kruskal.d.ts +9 -0
- package/dist/src/algorithms/mst/kruskal.d.ts.map +1 -0
- package/dist/src/algorithms/mst/kruskal.js +43 -0
- package/dist/src/algorithms/mst/kruskal.js.map +1 -0
- package/dist/src/algorithms/mst/prim.d.ts +5 -0
- package/dist/src/algorithms/mst/prim.d.ts.map +1 -0
- package/dist/src/algorithms/mst/prim.js +63 -0
- package/dist/src/algorithms/mst/prim.js.map +1 -0
- package/dist/src/algorithms/shortest-path/bellman-ford.js +2 -2
- package/dist/src/algorithms/shortest-path/bellman-ford.js.map +1 -1
- package/dist/src/algorithms/shortest-path/dijkstra.js +5 -5
- package/dist/src/algorithms/shortest-path/dijkstra.js.map +1 -1
- package/dist/src/algorithms/shortest-path/floyd-warshall.d.ts +14 -0
- package/dist/src/algorithms/shortest-path/floyd-warshall.d.ts.map +1 -0
- package/dist/src/algorithms/shortest-path/floyd-warshall.js +129 -0
- package/dist/src/algorithms/shortest-path/floyd-warshall.js.map +1 -0
- package/dist/src/algorithms/shortest-path/index.d.ts +2 -0
- package/dist/src/algorithms/shortest-path/index.d.ts.map +1 -1
- package/dist/src/algorithms/shortest-path/index.js +1 -0
- package/dist/src/algorithms/shortest-path/index.js.map +1 -1
- package/dist/src/algorithms/traversal/bfs.js +2 -2
- package/dist/src/algorithms/traversal/bfs.js.map +1 -1
- package/dist/src/algorithms/traversal/dfs.js +11 -11
- package/dist/src/algorithms/traversal/dfs.js.map +1 -1
- package/dist/src/clustering/hierarchical.d.ts +48 -0
- package/dist/src/clustering/hierarchical.d.ts.map +1 -0
- package/dist/src/clustering/hierarchical.js +439 -0
- package/dist/src/clustering/hierarchical.js.map +1 -0
- package/dist/src/clustering/index.d.ts +7 -0
- package/dist/src/clustering/index.d.ts.map +1 -0
- package/dist/src/clustering/index.js +5 -0
- package/dist/src/clustering/index.js.map +1 -0
- package/dist/src/clustering/k-core.d.ts +63 -0
- package/dist/src/clustering/k-core.d.ts.map +1 -0
- package/dist/src/clustering/k-core.js +377 -0
- package/dist/src/clustering/k-core.js.map +1 -0
- package/dist/src/clustering/mcl.d.ts +36 -0
- package/dist/src/clustering/mcl.d.ts.map +1 -0
- package/dist/src/clustering/mcl.js +343 -0
- package/dist/src/clustering/mcl.js.map +1 -0
- package/dist/src/clustering/spectral.d.ts +28 -0
- package/dist/src/clustering/spectral.d.ts.map +1 -0
- package/dist/src/clustering/spectral.js +551 -0
- package/dist/src/clustering/spectral.js.map +1 -0
- package/dist/src/core/graph.d.ts +9 -0
- package/dist/src/core/graph.d.ts.map +1 -1
- package/dist/src/core/graph.js +31 -11
- package/dist/src/core/graph.js.map +1 -1
- package/dist/src/data-structures/priority-queue.js +0 -2
- package/dist/src/data-structures/priority-queue.js.map +1 -1
- package/dist/src/data-structures/union-find.js +2 -5
- package/dist/src/data-structures/union-find.js.map +1 -1
- package/dist/src/flow/ford-fulkerson.d.ts +53 -0
- package/dist/src/flow/ford-fulkerson.d.ts.map +1 -0
- package/dist/src/flow/ford-fulkerson.js +355 -0
- package/dist/src/flow/ford-fulkerson.js.map +1 -0
- package/dist/src/flow/index.d.ts +3 -0
- package/dist/src/flow/index.d.ts.map +1 -0
- package/dist/src/flow/index.js +3 -0
- package/dist/src/flow/index.js.map +1 -0
- package/dist/src/flow/min-cut.d.ts +49 -0
- package/dist/src/flow/min-cut.d.ts.map +1 -0
- package/dist/src/flow/min-cut.js +383 -0
- package/dist/src/flow/min-cut.js.map +1 -0
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/link-prediction/adamic-adar.d.ts +56 -0
- package/dist/src/link-prediction/adamic-adar.d.ts.map +1 -0
- package/dist/src/link-prediction/adamic-adar.js +256 -0
- package/dist/src/link-prediction/adamic-adar.js.map +1 -0
- package/dist/src/link-prediction/common-neighbors.d.ts +50 -0
- package/dist/src/link-prediction/common-neighbors.d.ts.map +1 -0
- package/dist/src/link-prediction/common-neighbors.js +155 -0
- package/dist/src/link-prediction/common-neighbors.js.map +1 -0
- package/dist/src/link-prediction/index.d.ts +7 -0
- package/dist/src/link-prediction/index.d.ts.map +1 -0
- package/dist/src/link-prediction/index.js +6 -0
- package/dist/src/link-prediction/index.js.map +1 -0
- package/dist/src/pathfinding/astar.d.ts +50 -0
- package/dist/src/pathfinding/astar.d.ts.map +1 -0
- package/dist/src/pathfinding/astar.js +180 -0
- package/dist/src/pathfinding/astar.js.map +1 -0
- package/dist/src/pathfinding/index.d.ts +3 -0
- package/dist/src/pathfinding/index.d.ts.map +1 -0
- package/dist/src/pathfinding/index.js +3 -0
- package/dist/src/pathfinding/index.js.map +1 -0
- package/dist/src/pathfinding/utils.d.ts +18 -0
- package/dist/src/pathfinding/utils.d.ts.map +1 -0
- package/dist/src/pathfinding/utils.js +68 -0
- package/dist/src/pathfinding/utils.js.map +1 -0
- package/dist/src/research/grsbm.d.ts +83 -0
- package/dist/src/research/grsbm.d.ts.map +1 -0
- package/dist/src/research/grsbm.js +411 -0
- package/dist/src/research/grsbm.js.map +1 -0
- package/dist/src/research/index.d.ts +12 -0
- package/dist/src/research/index.d.ts.map +1 -0
- package/dist/src/research/index.js +14 -0
- package/dist/src/research/index.js.map +1 -0
- package/dist/src/research/sync.d.ts +49 -0
- package/dist/src/research/sync.d.ts.map +1 -0
- package/dist/src/research/sync.js +342 -0
- package/dist/src/research/sync.js.map +1 -0
- package/dist/src/research/terahac.d.ts +63 -0
- package/dist/src/research/terahac.d.ts.map +1 -0
- package/dist/src/research/terahac.js +375 -0
- package/dist/src/research/terahac.js.map +1 -0
- package/dist/src/types/index.d.ts +9 -0
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/utils/graphNode.d.ts +8 -0
- package/dist/src/utils/graphNode.d.ts.map +1 -0
- package/dist/src/utils/graphNode.js +2 -0
- package/dist/src/utils/graphNode.js.map +1 -0
- package/dist/src/utils/priorityQueue.d.ts +21 -0
- package/dist/src/utils/priorityQueue.d.ts.map +1 -0
- package/dist/src/utils/priorityQueue.js +101 -0
- package/dist/src/utils/priorityQueue.js.map +1 -0
- package/package.json +13 -2
- package/src/algorithms/centrality/betweenness.ts +25 -7
- package/src/algorithms/centrality/closeness.ts +7 -7
- package/src/algorithms/centrality/degree.ts +1 -1
- package/src/algorithms/centrality/eigenvector.ts +162 -0
- package/src/algorithms/centrality/hits.ts +210 -0
- package/src/algorithms/centrality/index.ts +6 -0
- package/src/algorithms/centrality/katz.ts +139 -0
- package/src/algorithms/centrality/pagerank.ts +3 -3
- package/src/algorithms/community/girvan-newman.ts +372 -0
- package/src/algorithms/community/index.ts +13 -0
- package/src/algorithms/community/label-propagation.ts +392 -0
- package/src/algorithms/community/leiden.ts +572 -0
- package/src/algorithms/community/louvain.ts +298 -0
- package/src/algorithms/components/connected.ts +7 -7
- package/src/algorithms/index.ts +21 -0
- package/src/algorithms/matching/bipartite.ts +179 -0
- package/src/algorithms/matching/index.ts +8 -0
- package/src/algorithms/matching/isomorphism.ts +392 -0
- package/src/algorithms/mst/index.ts +4 -0
- package/src/algorithms/mst/kruskal.ts +61 -0
- package/src/algorithms/mst/prim.ts +80 -0
- package/src/algorithms/shortest-path/bellman-ford.ts +2 -2
- package/src/algorithms/shortest-path/dijkstra.ts +5 -5
- package/src/algorithms/shortest-path/floyd-warshall.ts +170 -0
- package/src/algorithms/shortest-path/index.ts +2 -0
- package/src/algorithms/traversal/bfs.ts +2 -2
- package/src/algorithms/traversal/dfs.ts +11 -11
- package/src/clustering/hierarchical.ts +555 -0
- package/src/clustering/index.ts +6 -0
- package/src/clustering/k-core.ts +460 -0
- package/src/clustering/mcl.ts +454 -0
- package/src/clustering/spectral.ts +672 -0
- package/src/core/graph.ts +34 -6
- package/src/data-structures/union-find.ts +2 -2
- package/src/flow/ford-fulkerson.ts +459 -0
- package/src/flow/index.ts +2 -0
- package/src/flow/min-cut.ts +482 -0
- package/src/index.ts +5 -0
- package/src/link-prediction/adamic-adar.ts +353 -0
- package/src/link-prediction/common-neighbors.ts +252 -0
- package/src/link-prediction/index.ts +20 -0
- package/src/pathfinding/astar.ts +229 -0
- package/src/pathfinding/index.ts +2 -0
- package/src/pathfinding/utils.ts +87 -0
- package/src/research/grsbm.ts +589 -0
- package/src/research/index.ts +17 -0
- package/src/research/sync.ts +469 -0
- package/src/research/terahac.ts +506 -0
- package/src/types/index.ts +11 -0
- package/src/utils/graphNode.ts +7 -0
- package/src/utils/priorityQueue.ts +120 -0
- package/dist/test/browser/basic.test.d.ts +0 -2
- package/dist/test/browser/basic.test.d.ts.map +0 -1
- package/dist/test/browser/basic.test.js +0 -70
- package/dist/test/browser/basic.test.js.map +0 -1
- package/dist/test/unit/bellman-ford.test.d.ts +0 -2
- package/dist/test/unit/bellman-ford.test.d.ts.map +0 -1
- package/dist/test/unit/bellman-ford.test.js +0 -231
- package/dist/test/unit/bellman-ford.test.js.map +0 -1
- package/dist/test/unit/betweenness-centrality.test.d.ts +0 -2
- package/dist/test/unit/betweenness-centrality.test.d.ts.map +0 -1
- package/dist/test/unit/betweenness-centrality.test.js +0 -311
- package/dist/test/unit/betweenness-centrality.test.js.map +0 -1
- package/dist/test/unit/bfs.test.d.ts +0 -2
- package/dist/test/unit/bfs.test.d.ts.map +0 -1
- package/dist/test/unit/bfs.test.js +0 -277
- package/dist/test/unit/bfs.test.js.map +0 -1
- package/dist/test/unit/closeness.test.d.ts +0 -2
- package/dist/test/unit/closeness.test.d.ts.map +0 -1
- package/dist/test/unit/closeness.test.js +0 -266
- package/dist/test/unit/closeness.test.js.map +0 -1
- package/dist/test/unit/connected-components.test.d.ts +0 -2
- package/dist/test/unit/connected-components.test.d.ts.map +0 -1
- package/dist/test/unit/connected-components.test.js +0 -355
- package/dist/test/unit/connected-components.test.js.map +0 -1
- package/dist/test/unit/degree-centrality.test.d.ts +0 -2
- package/dist/test/unit/degree-centrality.test.d.ts.map +0 -1
- package/dist/test/unit/degree-centrality.test.js +0 -260
- package/dist/test/unit/degree-centrality.test.js.map +0 -1
- package/dist/test/unit/dfs.test.d.ts +0 -2
- package/dist/test/unit/dfs.test.d.ts.map +0 -1
- package/dist/test/unit/dfs.test.js +0 -350
- package/dist/test/unit/dfs.test.js.map +0 -1
- package/dist/test/unit/dijkstra.test.d.ts +0 -2
- package/dist/test/unit/dijkstra.test.d.ts.map +0 -1
- package/dist/test/unit/dijkstra.test.js +0 -311
- package/dist/test/unit/dijkstra.test.js.map +0 -1
- package/dist/test/unit/graph.test.d.ts +0 -2
- package/dist/test/unit/graph.test.d.ts.map +0 -1
- package/dist/test/unit/graph.test.js +0 -175
- package/dist/test/unit/graph.test.js.map +0 -1
- package/dist/test/unit/pagerank.test.d.ts +0 -2
- package/dist/test/unit/pagerank.test.d.ts.map +0 -1
- package/dist/test/unit/pagerank.test.js +0 -281
- package/dist/test/unit/pagerank.test.js.map +0 -1
- package/dist/test/unit/priority-queue.test.d.ts +0 -2
- package/dist/test/unit/priority-queue.test.d.ts.map +0 -1
- package/dist/test/unit/priority-queue.test.js +0 -189
- package/dist/test/unit/priority-queue.test.js.map +0 -1
- package/dist/test/unit/union-find.test.d.ts +0 -2
- package/dist/test/unit/union-find.test.d.ts.map +0 -1
- package/dist/test/unit/union-find.test.js +0 -245
- package/dist/test/unit/union-find.test.js.map +0 -1
|
@@ -1,355 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { condensationGraph, connectedComponents, connectedComponentsDFS, getConnectedComponent, isConnected, isStronglyConnected, isWeaklyConnected, largestConnectedComponent, numberOfConnectedComponents, stronglyConnectedComponents, weaklyConnectedComponents, } from "../../src/algorithms/components/connected.js";
|
|
3
|
-
import { Graph } from "../../src/core/graph.js";
|
|
4
|
-
describe("Connected Components", () => {
|
|
5
|
-
describe("connectedComponents", () => {
|
|
6
|
-
it("should find single component in connected graph", () => {
|
|
7
|
-
const graph = new Graph();
|
|
8
|
-
graph.addEdge("a", "b");
|
|
9
|
-
graph.addEdge("b", "c");
|
|
10
|
-
graph.addEdge("c", "d");
|
|
11
|
-
const components = connectedComponents(graph);
|
|
12
|
-
expect(components).toHaveLength(1);
|
|
13
|
-
expect(components[0]).toHaveLength(4);
|
|
14
|
-
expect(components[0]?.sort()).toEqual(["a", "b", "c", "d"]);
|
|
15
|
-
});
|
|
16
|
-
it("should find multiple components in disconnected graph", () => {
|
|
17
|
-
const graph = new Graph();
|
|
18
|
-
// Two disconnected components
|
|
19
|
-
graph.addEdge("a", "b");
|
|
20
|
-
graph.addEdge("c", "d");
|
|
21
|
-
graph.addNode("isolated");
|
|
22
|
-
const components = connectedComponents(graph);
|
|
23
|
-
expect(components).toHaveLength(3);
|
|
24
|
-
const sizes = components.map((comp) => comp.length).sort();
|
|
25
|
-
expect(sizes).toEqual([1, 2, 2]);
|
|
26
|
-
});
|
|
27
|
-
it("should handle empty graph", () => {
|
|
28
|
-
const graph = new Graph();
|
|
29
|
-
const components = connectedComponents(graph);
|
|
30
|
-
expect(components).toEqual([]);
|
|
31
|
-
});
|
|
32
|
-
it("should handle single node", () => {
|
|
33
|
-
const graph = new Graph();
|
|
34
|
-
graph.addNode("only");
|
|
35
|
-
const components = connectedComponents(graph);
|
|
36
|
-
expect(components).toHaveLength(1);
|
|
37
|
-
expect(components[0]).toEqual(["only"]);
|
|
38
|
-
});
|
|
39
|
-
it("should throw error for directed graph", () => {
|
|
40
|
-
const graph = new Graph({ directed: true });
|
|
41
|
-
graph.addEdge("a", "b");
|
|
42
|
-
expect(() => connectedComponents(graph)).toThrow("Connected components algorithm requires an undirected graph");
|
|
43
|
-
});
|
|
44
|
-
it("should handle complex graph", () => {
|
|
45
|
-
const graph = new Graph();
|
|
46
|
-
// Component 1: triangle
|
|
47
|
-
graph.addEdge("a", "b");
|
|
48
|
-
graph.addEdge("b", "c");
|
|
49
|
-
graph.addEdge("c", "a");
|
|
50
|
-
// Component 2: path
|
|
51
|
-
graph.addEdge("d", "e");
|
|
52
|
-
graph.addEdge("e", "f");
|
|
53
|
-
// Component 3: isolated nodes
|
|
54
|
-
graph.addNode("g");
|
|
55
|
-
graph.addNode("h");
|
|
56
|
-
const components = connectedComponents(graph);
|
|
57
|
-
expect(components).toHaveLength(4);
|
|
58
|
-
const sizes = components.map((comp) => comp.length).sort();
|
|
59
|
-
expect(sizes).toEqual([1, 1, 3, 3]);
|
|
60
|
-
});
|
|
61
|
-
it("should work with numeric node IDs", () => {
|
|
62
|
-
const graph = new Graph();
|
|
63
|
-
graph.addEdge(1, 2);
|
|
64
|
-
graph.addEdge(3, 4);
|
|
65
|
-
const components = connectedComponents(graph);
|
|
66
|
-
expect(components).toHaveLength(2);
|
|
67
|
-
expect(components[0]).toHaveLength(2);
|
|
68
|
-
expect(components[1]).toHaveLength(2);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
describe("connectedComponentsDFS", () => {
|
|
72
|
-
it("should produce same results as Union-Find method", () => {
|
|
73
|
-
const graph = new Graph();
|
|
74
|
-
graph.addEdge("a", "b");
|
|
75
|
-
graph.addEdge("c", "d");
|
|
76
|
-
graph.addNode("isolated");
|
|
77
|
-
const componentsUF = connectedComponents(graph);
|
|
78
|
-
const componentsDFS = connectedComponentsDFS(graph);
|
|
79
|
-
expect(componentsDFS).toHaveLength(componentsUF.length);
|
|
80
|
-
// Sort for comparison
|
|
81
|
-
const sortedUF = componentsUF.map((comp) => comp.sort()).sort();
|
|
82
|
-
const sortedDFS = componentsDFS.map((comp) => comp.sort()).sort();
|
|
83
|
-
expect(sortedDFS).toEqual(sortedUF);
|
|
84
|
-
});
|
|
85
|
-
it("should throw error for directed graph", () => {
|
|
86
|
-
const graph = new Graph({ directed: true });
|
|
87
|
-
graph.addEdge("a", "b");
|
|
88
|
-
expect(() => connectedComponentsDFS(graph)).toThrow("Connected components algorithm requires an undirected graph");
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
describe("numberOfConnectedComponents", () => {
|
|
92
|
-
it("should count components correctly", () => {
|
|
93
|
-
const graph = new Graph();
|
|
94
|
-
graph.addEdge("a", "b");
|
|
95
|
-
graph.addEdge("c", "d");
|
|
96
|
-
graph.addNode("isolated");
|
|
97
|
-
expect(numberOfConnectedComponents(graph)).toBe(3);
|
|
98
|
-
});
|
|
99
|
-
it("should return 0 for empty graph", () => {
|
|
100
|
-
const graph = new Graph();
|
|
101
|
-
expect(numberOfConnectedComponents(graph)).toBe(0);
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
describe("isConnected", () => {
|
|
105
|
-
it("should return true for connected graph", () => {
|
|
106
|
-
const graph = new Graph();
|
|
107
|
-
graph.addEdge("a", "b");
|
|
108
|
-
graph.addEdge("b", "c");
|
|
109
|
-
expect(isConnected(graph)).toBe(true);
|
|
110
|
-
});
|
|
111
|
-
it("should return false for disconnected graph", () => {
|
|
112
|
-
const graph = new Graph();
|
|
113
|
-
graph.addEdge("a", "b");
|
|
114
|
-
graph.addEdge("c", "d");
|
|
115
|
-
expect(isConnected(graph)).toBe(false);
|
|
116
|
-
});
|
|
117
|
-
it("should return true for empty graph", () => {
|
|
118
|
-
const graph = new Graph();
|
|
119
|
-
expect(isConnected(graph)).toBe(true);
|
|
120
|
-
});
|
|
121
|
-
it("should return true for single node", () => {
|
|
122
|
-
const graph = new Graph();
|
|
123
|
-
graph.addNode("only");
|
|
124
|
-
expect(isConnected(graph)).toBe(true);
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
describe("largestConnectedComponent", () => {
|
|
128
|
-
it("should find largest component", () => {
|
|
129
|
-
const graph = new Graph();
|
|
130
|
-
// Small component
|
|
131
|
-
graph.addEdge("a", "b");
|
|
132
|
-
// Large component
|
|
133
|
-
graph.addEdge("c", "d");
|
|
134
|
-
graph.addEdge("d", "e");
|
|
135
|
-
graph.addEdge("e", "f");
|
|
136
|
-
const largest = largestConnectedComponent(graph);
|
|
137
|
-
expect(largest).toHaveLength(4);
|
|
138
|
-
expect(largest.sort()).toEqual(["c", "d", "e", "f"]);
|
|
139
|
-
});
|
|
140
|
-
it("should return empty array for empty graph", () => {
|
|
141
|
-
const graph = new Graph();
|
|
142
|
-
const largest = largestConnectedComponent(graph);
|
|
143
|
-
expect(largest).toEqual([]);
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
describe("getConnectedComponent", () => {
|
|
147
|
-
it("should get component containing specific node", () => {
|
|
148
|
-
const graph = new Graph();
|
|
149
|
-
graph.addEdge("a", "b");
|
|
150
|
-
graph.addEdge("b", "c");
|
|
151
|
-
graph.addEdge("d", "e");
|
|
152
|
-
const component = getConnectedComponent(graph, "b");
|
|
153
|
-
expect(component).toHaveLength(3);
|
|
154
|
-
expect(component.sort()).toEqual(["a", "b", "c"]);
|
|
155
|
-
});
|
|
156
|
-
it("should throw error for non-existent node", () => {
|
|
157
|
-
const graph = new Graph();
|
|
158
|
-
graph.addNode("a");
|
|
159
|
-
expect(() => getConnectedComponent(graph, "nonexistent")).toThrow("Node nonexistent not found");
|
|
160
|
-
});
|
|
161
|
-
it("should throw error for directed graph", () => {
|
|
162
|
-
const graph = new Graph({ directed: true });
|
|
163
|
-
graph.addEdge("a", "b");
|
|
164
|
-
expect(() => getConnectedComponent(graph, "a")).toThrow("Connected components algorithm requires an undirected graph");
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
describe("stronglyConnectedComponents", () => {
|
|
168
|
-
it("should find SCCs in directed graph", () => {
|
|
169
|
-
const graph = new Graph({ directed: true });
|
|
170
|
-
// Create two SCCs
|
|
171
|
-
graph.addEdge("a", "b");
|
|
172
|
-
graph.addEdge("b", "c");
|
|
173
|
-
graph.addEdge("c", "a"); // SCC 1: {a, b, c}
|
|
174
|
-
graph.addEdge("c", "d");
|
|
175
|
-
graph.addEdge("d", "e");
|
|
176
|
-
graph.addEdge("e", "d"); // SCC 2: {d, e}
|
|
177
|
-
const components = stronglyConnectedComponents(graph);
|
|
178
|
-
expect(components).toHaveLength(2);
|
|
179
|
-
const sizes = components.map((comp) => comp.length).sort();
|
|
180
|
-
expect(sizes).toEqual([2, 3]);
|
|
181
|
-
});
|
|
182
|
-
it("should handle single node components", () => {
|
|
183
|
-
const graph = new Graph({ directed: true });
|
|
184
|
-
// Create a DAG (each node is its own SCC)
|
|
185
|
-
graph.addEdge("a", "b");
|
|
186
|
-
graph.addEdge("b", "c");
|
|
187
|
-
const components = stronglyConnectedComponents(graph);
|
|
188
|
-
expect(components).toHaveLength(3);
|
|
189
|
-
expect(components.every((comp) => comp.length === 1)).toBe(true);
|
|
190
|
-
});
|
|
191
|
-
it("should handle self-loops", () => {
|
|
192
|
-
const graph = new Graph({ directed: true, allowSelfLoops: true });
|
|
193
|
-
graph.addEdge("a", "a");
|
|
194
|
-
graph.addEdge("a", "b");
|
|
195
|
-
const components = stronglyConnectedComponents(graph);
|
|
196
|
-
expect(components).toHaveLength(2);
|
|
197
|
-
expect(components.some((comp) => comp.includes("a") && comp.length === 1)).toBe(true);
|
|
198
|
-
expect(components.some((comp) => comp.includes("b") && comp.length === 1)).toBe(true);
|
|
199
|
-
});
|
|
200
|
-
it("should throw error for undirected graph", () => {
|
|
201
|
-
const graph = new Graph();
|
|
202
|
-
graph.addEdge("a", "b");
|
|
203
|
-
expect(() => stronglyConnectedComponents(graph)).toThrow("Strongly connected components require a directed graph");
|
|
204
|
-
});
|
|
205
|
-
it("should handle empty graph", () => {
|
|
206
|
-
const graph = new Graph({ directed: true });
|
|
207
|
-
const components = stronglyConnectedComponents(graph);
|
|
208
|
-
expect(components).toEqual([]);
|
|
209
|
-
});
|
|
210
|
-
it("should handle complex SCC structure", () => {
|
|
211
|
-
const graph = new Graph({ directed: true });
|
|
212
|
-
// Complex graph with multiple SCCs
|
|
213
|
-
graph.addEdge("a", "b");
|
|
214
|
-
graph.addEdge("b", "a"); // SCC 1: {a, b}
|
|
215
|
-
graph.addEdge("c", "d");
|
|
216
|
-
graph.addEdge("d", "e");
|
|
217
|
-
graph.addEdge("e", "c"); // SCC 2: {c, d, e}
|
|
218
|
-
graph.addEdge("b", "c"); // Connection between SCCs
|
|
219
|
-
graph.addEdge("e", "f"); // f is isolated
|
|
220
|
-
const components = stronglyConnectedComponents(graph);
|
|
221
|
-
expect(components).toHaveLength(3);
|
|
222
|
-
const sizes = components.map((comp) => comp.length).sort();
|
|
223
|
-
expect(sizes).toEqual([1, 2, 3]);
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
describe("isStronglyConnected", () => {
|
|
227
|
-
it("should return true for strongly connected graph", () => {
|
|
228
|
-
const graph = new Graph({ directed: true });
|
|
229
|
-
graph.addEdge("a", "b");
|
|
230
|
-
graph.addEdge("b", "c");
|
|
231
|
-
graph.addEdge("c", "a");
|
|
232
|
-
expect(isStronglyConnected(graph)).toBe(true);
|
|
233
|
-
});
|
|
234
|
-
it("should return false for weakly connected graph", () => {
|
|
235
|
-
const graph = new Graph({ directed: true });
|
|
236
|
-
graph.addEdge("a", "b");
|
|
237
|
-
graph.addEdge("b", "c");
|
|
238
|
-
expect(isStronglyConnected(graph)).toBe(false);
|
|
239
|
-
});
|
|
240
|
-
it("should throw error for undirected graph", () => {
|
|
241
|
-
const graph = new Graph();
|
|
242
|
-
graph.addEdge("a", "b");
|
|
243
|
-
expect(() => isStronglyConnected(graph)).toThrow("Strong connectivity check requires a directed graph");
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
|
-
describe("weaklyConnectedComponents", () => {
|
|
247
|
-
it("should find weakly connected components", () => {
|
|
248
|
-
const graph = new Graph({ directed: true });
|
|
249
|
-
// Two weakly connected components
|
|
250
|
-
graph.addEdge("a", "b");
|
|
251
|
-
graph.addEdge("c", "d");
|
|
252
|
-
const components = weaklyConnectedComponents(graph);
|
|
253
|
-
expect(components).toHaveLength(2);
|
|
254
|
-
expect(components[0]).toHaveLength(2);
|
|
255
|
-
expect(components[1]).toHaveLength(2);
|
|
256
|
-
});
|
|
257
|
-
it("should treat directed edges as undirected", () => {
|
|
258
|
-
const graph = new Graph({ directed: true });
|
|
259
|
-
graph.addEdge("a", "b");
|
|
260
|
-
graph.addEdge("c", "b"); // b is reachable from both a and c
|
|
261
|
-
const components = weaklyConnectedComponents(graph);
|
|
262
|
-
expect(components).toHaveLength(1);
|
|
263
|
-
expect(components[0]).toHaveLength(3);
|
|
264
|
-
});
|
|
265
|
-
it("should throw error for undirected graph", () => {
|
|
266
|
-
const graph = new Graph();
|
|
267
|
-
graph.addEdge("a", "b");
|
|
268
|
-
expect(() => weaklyConnectedComponents(graph)).toThrow("Weakly connected components are for directed graphs");
|
|
269
|
-
});
|
|
270
|
-
});
|
|
271
|
-
describe("isWeaklyConnected", () => {
|
|
272
|
-
it("should return true for weakly connected graph", () => {
|
|
273
|
-
const graph = new Graph({ directed: true });
|
|
274
|
-
graph.addEdge("a", "b");
|
|
275
|
-
graph.addEdge("c", "b");
|
|
276
|
-
expect(isWeaklyConnected(graph)).toBe(true);
|
|
277
|
-
});
|
|
278
|
-
it("should return false for disconnected graph", () => {
|
|
279
|
-
const graph = new Graph({ directed: true });
|
|
280
|
-
graph.addEdge("a", "b");
|
|
281
|
-
graph.addEdge("c", "d");
|
|
282
|
-
expect(isWeaklyConnected(graph)).toBe(false);
|
|
283
|
-
});
|
|
284
|
-
it("should throw error for undirected graph", () => {
|
|
285
|
-
const graph = new Graph();
|
|
286
|
-
graph.addEdge("a", "b");
|
|
287
|
-
expect(() => isWeaklyConnected(graph)).toThrow("Weak connectivity check requires a directed graph");
|
|
288
|
-
});
|
|
289
|
-
});
|
|
290
|
-
describe("condensationGraph", () => {
|
|
291
|
-
it("should create condensation graph", () => {
|
|
292
|
-
const graph = new Graph({ directed: true });
|
|
293
|
-
// Two SCCs with connection
|
|
294
|
-
graph.addEdge("a", "b");
|
|
295
|
-
graph.addEdge("b", "a"); // SCC 0: {a, b}
|
|
296
|
-
graph.addEdge("c", "d");
|
|
297
|
-
graph.addEdge("d", "c"); // SCC 1: {c, d}
|
|
298
|
-
graph.addEdge("b", "c"); // Edge between SCCs
|
|
299
|
-
const result = condensationGraph(graph);
|
|
300
|
-
expect(result.components).toHaveLength(2);
|
|
301
|
-
expect(result.condensedGraph.nodeCount).toBe(2);
|
|
302
|
-
expect(result.condensedGraph.totalEdgeCount).toBe(1);
|
|
303
|
-
// Check component mapping
|
|
304
|
-
expect(result.componentMap.get("a")).toBeDefined();
|
|
305
|
-
expect(result.componentMap.get("b")).toBeDefined();
|
|
306
|
-
expect(result.componentMap.get("c")).toBeDefined();
|
|
307
|
-
expect(result.componentMap.get("d")).toBeDefined();
|
|
308
|
-
});
|
|
309
|
-
it("should handle single SCC", () => {
|
|
310
|
-
const graph = new Graph({ directed: true });
|
|
311
|
-
graph.addEdge("a", "b");
|
|
312
|
-
graph.addEdge("b", "c");
|
|
313
|
-
graph.addEdge("c", "a");
|
|
314
|
-
const result = condensationGraph(graph);
|
|
315
|
-
expect(result.components).toHaveLength(1);
|
|
316
|
-
expect(result.condensedGraph.nodeCount).toBe(1);
|
|
317
|
-
expect(result.condensedGraph.totalEdgeCount).toBe(0);
|
|
318
|
-
});
|
|
319
|
-
it("should throw error for undirected graph", () => {
|
|
320
|
-
const graph = new Graph();
|
|
321
|
-
graph.addEdge("a", "b");
|
|
322
|
-
expect(() => condensationGraph(graph)).toThrow("Condensation graph requires a directed graph");
|
|
323
|
-
});
|
|
324
|
-
});
|
|
325
|
-
describe("edge cases", () => {
|
|
326
|
-
it("should handle graphs with self-loops", () => {
|
|
327
|
-
const graph = new Graph({ allowSelfLoops: true });
|
|
328
|
-
graph.addEdge("a", "a");
|
|
329
|
-
graph.addEdge("a", "b");
|
|
330
|
-
const components = connectedComponents(graph);
|
|
331
|
-
expect(components).toHaveLength(1);
|
|
332
|
-
expect(components[0]?.sort()).toEqual(["a", "b"]);
|
|
333
|
-
});
|
|
334
|
-
it("should handle large graphs efficiently", () => {
|
|
335
|
-
const graph = new Graph();
|
|
336
|
-
const nodeCount = 1000;
|
|
337
|
-
// Create a path graph
|
|
338
|
-
for (let i = 0; i < nodeCount - 1; i++) {
|
|
339
|
-
graph.addEdge(i, i + 1);
|
|
340
|
-
}
|
|
341
|
-
const components = connectedComponents(graph);
|
|
342
|
-
expect(components).toHaveLength(1);
|
|
343
|
-
expect(components[0]).toHaveLength(nodeCount);
|
|
344
|
-
});
|
|
345
|
-
it("should handle mixed node ID types", () => {
|
|
346
|
-
const graph = new Graph();
|
|
347
|
-
graph.addEdge("string", 123);
|
|
348
|
-
graph.addEdge(123, "another");
|
|
349
|
-
const components = connectedComponents(graph);
|
|
350
|
-
expect(components).toHaveLength(1);
|
|
351
|
-
expect(components[0]).toHaveLength(3);
|
|
352
|
-
});
|
|
353
|
-
});
|
|
354
|
-
});
|
|
355
|
-
//# sourceMappingURL=connected-components.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connected-components.test.js","sourceRoot":"","sources":["../../../test/unit/connected-components.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAC,MAAM,QAAQ,CAAC;AAE5C,OAAO,EACH,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,yBAAyB,EACzB,2BAA2B,EAC3B,2BAA2B,EAC3B,yBAAyB,GAC5B,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAC,KAAK,EAAC,MAAM,yBAAyB,CAAC;AAE9C,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IAClC,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;QACjC,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;YACvD,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC;YAE1B,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YACxB,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;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CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;YACzC,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC;YAE1B,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;YAC7B,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;YAE9B,MAAM,UAAU,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;YAE9C,MAAM,CAAC,UAAU,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YACnC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"degree-centrality.test.d.ts","sourceRoot":"","sources":["../../../test/unit/degree-centrality.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
/* eslint-disable dot-notation */
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
import { degreeCentrality, nodeDegreeCentrality } from "../../src/algorithms/centrality/degree.js";
|
|
4
|
-
import { Graph } from "../../src/core/graph.js";
|
|
5
|
-
describe("Degree Centrality", () => {
|
|
6
|
-
describe("degreeCentrality", () => {
|
|
7
|
-
it("should calculate degree centrality for undirected graph", () => {
|
|
8
|
-
const graph = new Graph();
|
|
9
|
-
// Create a star graph: center connected to 3 others
|
|
10
|
-
graph.addEdge("center", "a");
|
|
11
|
-
graph.addEdge("center", "b");
|
|
12
|
-
graph.addEdge("center", "c");
|
|
13
|
-
const centrality = degreeCentrality(graph);
|
|
14
|
-
expect(centrality["center"]).toBe(3);
|
|
15
|
-
expect(centrality["a"]).toBe(1);
|
|
16
|
-
expect(centrality["b"]).toBe(1);
|
|
17
|
-
expect(centrality["c"]).toBe(1);
|
|
18
|
-
});
|
|
19
|
-
it("should calculate normalized degree centrality", () => {
|
|
20
|
-
const graph = new Graph();
|
|
21
|
-
// 4 nodes: max possible degree is 3
|
|
22
|
-
graph.addEdge("center", "a");
|
|
23
|
-
graph.addEdge("center", "b");
|
|
24
|
-
graph.addEdge("center", "c");
|
|
25
|
-
const centrality = degreeCentrality(graph, { normalized: true });
|
|
26
|
-
expect(centrality["center"]).toBeCloseTo(1.0); // 3/3 = 1.0
|
|
27
|
-
expect(centrality["a"]).toBeCloseTo(0.333, 2); // 1/3 ≈ 0.333
|
|
28
|
-
expect(centrality["b"]).toBeCloseTo(0.333, 2);
|
|
29
|
-
expect(centrality["c"]).toBeCloseTo(0.333, 2);
|
|
30
|
-
});
|
|
31
|
-
it("should handle directed graph with total degree mode", () => {
|
|
32
|
-
const graph = new Graph({ directed: true });
|
|
33
|
-
graph.addEdge("a", "b");
|
|
34
|
-
graph.addEdge("c", "b");
|
|
35
|
-
graph.addEdge("b", "d");
|
|
36
|
-
const centrality = degreeCentrality(graph, { mode: "total" });
|
|
37
|
-
expect(centrality["a"]).toBe(1); // out-degree: 1
|
|
38
|
-
expect(centrality["b"]).toBe(3); // in-degree: 2, out-degree: 1
|
|
39
|
-
expect(centrality["c"]).toBe(1); // out-degree: 1
|
|
40
|
-
expect(centrality["d"]).toBe(1); // in-degree: 1
|
|
41
|
-
});
|
|
42
|
-
it("should handle directed graph with in-degree mode", () => {
|
|
43
|
-
const graph = new Graph({ directed: true });
|
|
44
|
-
graph.addEdge("a", "b");
|
|
45
|
-
graph.addEdge("c", "b");
|
|
46
|
-
graph.addEdge("b", "d");
|
|
47
|
-
const centrality = degreeCentrality(graph, { mode: "in" });
|
|
48
|
-
expect(centrality["a"]).toBe(0);
|
|
49
|
-
expect(centrality["b"]).toBe(2); // Receives edges from a and c
|
|
50
|
-
expect(centrality["c"]).toBe(0);
|
|
51
|
-
expect(centrality["d"]).toBe(1); // Receives edge from b
|
|
52
|
-
});
|
|
53
|
-
it("should handle directed graph with out-degree mode", () => {
|
|
54
|
-
const graph = new Graph({ directed: true });
|
|
55
|
-
graph.addEdge("a", "b");
|
|
56
|
-
graph.addEdge("c", "b");
|
|
57
|
-
graph.addEdge("b", "d");
|
|
58
|
-
const centrality = degreeCentrality(graph, { mode: "out" });
|
|
59
|
-
expect(centrality["a"]).toBe(1); // Sends edge to b
|
|
60
|
-
expect(centrality["b"]).toBe(1); // Sends edge to d
|
|
61
|
-
expect(centrality["c"]).toBe(1); // Sends edge to b
|
|
62
|
-
expect(centrality["d"]).toBe(0);
|
|
63
|
-
});
|
|
64
|
-
it("should handle single node graph", () => {
|
|
65
|
-
const graph = new Graph();
|
|
66
|
-
graph.addNode("only");
|
|
67
|
-
const centrality = degreeCentrality(graph);
|
|
68
|
-
expect(centrality["only"]).toBe(0);
|
|
69
|
-
});
|
|
70
|
-
it("should handle empty graph", () => {
|
|
71
|
-
const graph = new Graph();
|
|
72
|
-
const centrality = degreeCentrality(graph);
|
|
73
|
-
expect(Object.keys(centrality)).toHaveLength(0);
|
|
74
|
-
});
|
|
75
|
-
it("should handle disconnected components", () => {
|
|
76
|
-
const graph = new Graph();
|
|
77
|
-
// Two disconnected pairs
|
|
78
|
-
graph.addEdge("a", "b");
|
|
79
|
-
graph.addEdge("c", "d");
|
|
80
|
-
graph.addNode("isolated");
|
|
81
|
-
const centrality = degreeCentrality(graph);
|
|
82
|
-
expect(centrality["a"]).toBe(1);
|
|
83
|
-
expect(centrality["b"]).toBe(1);
|
|
84
|
-
expect(centrality["c"]).toBe(1);
|
|
85
|
-
expect(centrality["d"]).toBe(1);
|
|
86
|
-
expect(centrality["isolated"]).toBe(0);
|
|
87
|
-
});
|
|
88
|
-
it("should handle self-loops correctly", () => {
|
|
89
|
-
const graph = new Graph({ allowSelfLoops: true });
|
|
90
|
-
graph.addEdge("a", "a"); // Self-loop
|
|
91
|
-
graph.addEdge("a", "b");
|
|
92
|
-
const centrality = degreeCentrality(graph);
|
|
93
|
-
// Self-loop should count as degree 1 in undirected graph
|
|
94
|
-
expect(centrality["a"]).toBe(2); // Self-loop + edge to b
|
|
95
|
-
expect(centrality["b"]).toBe(1);
|
|
96
|
-
});
|
|
97
|
-
it("should convert node IDs to strings in result", () => {
|
|
98
|
-
const graph = new Graph();
|
|
99
|
-
graph.addEdge(1, 2);
|
|
100
|
-
graph.addEdge(2, 3);
|
|
101
|
-
const centrality = degreeCentrality(graph);
|
|
102
|
-
expect(centrality["1"]).toBe(1);
|
|
103
|
-
expect(centrality["2"]).toBe(2);
|
|
104
|
-
expect(centrality["3"]).toBe(1);
|
|
105
|
-
});
|
|
106
|
-
it("should handle normalized centrality with single node", () => {
|
|
107
|
-
const graph = new Graph();
|
|
108
|
-
graph.addNode("only");
|
|
109
|
-
const centrality = degreeCentrality(graph, { normalized: true });
|
|
110
|
-
expect(centrality["only"]).toBe(0); // 0/0 should be handled gracefully
|
|
111
|
-
});
|
|
112
|
-
it("should handle normalized centrality with two nodes", () => {
|
|
113
|
-
const graph = new Graph();
|
|
114
|
-
graph.addEdge("a", "b");
|
|
115
|
-
const centrality = degreeCentrality(graph, { normalized: true });
|
|
116
|
-
expect(centrality["a"]).toBe(1); // 1/1 = 1.0
|
|
117
|
-
expect(centrality["b"]).toBe(1); // 1/1 = 1.0
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
describe("nodeDegreeCentrality", () => {
|
|
121
|
-
it("should calculate centrality for specific node", () => {
|
|
122
|
-
const graph = new Graph();
|
|
123
|
-
graph.addEdge("center", "a");
|
|
124
|
-
graph.addEdge("center", "b");
|
|
125
|
-
graph.addEdge("a", "b");
|
|
126
|
-
const centralityA = nodeDegreeCentrality(graph, "a");
|
|
127
|
-
const centralityCenter = nodeDegreeCentrality(graph, "center");
|
|
128
|
-
expect(centralityA).toBe(2);
|
|
129
|
-
expect(centralityCenter).toBe(2);
|
|
130
|
-
});
|
|
131
|
-
it("should calculate normalized centrality for specific node", () => {
|
|
132
|
-
const graph = new Graph();
|
|
133
|
-
// 3 nodes: max possible degree is 2
|
|
134
|
-
graph.addEdge("a", "b");
|
|
135
|
-
graph.addEdge("a", "c");
|
|
136
|
-
const centrality = nodeDegreeCentrality(graph, "a", { normalized: true });
|
|
137
|
-
expect(centrality).toBe(1.0); // 2/2 = 1.0
|
|
138
|
-
});
|
|
139
|
-
it("should handle directed graph modes for specific node", () => {
|
|
140
|
-
const graph = new Graph({ directed: true });
|
|
141
|
-
graph.addEdge("a", "b");
|
|
142
|
-
graph.addEdge("c", "b");
|
|
143
|
-
graph.addEdge("b", "d");
|
|
144
|
-
expect(nodeDegreeCentrality(graph, "b", { mode: "in" })).toBe(2);
|
|
145
|
-
expect(nodeDegreeCentrality(graph, "b", { mode: "out" })).toBe(1);
|
|
146
|
-
expect(nodeDegreeCentrality(graph, "b", { mode: "total" })).toBe(3);
|
|
147
|
-
});
|
|
148
|
-
it("should throw error for non-existent node", () => {
|
|
149
|
-
const graph = new Graph();
|
|
150
|
-
graph.addNode("a");
|
|
151
|
-
expect(() => nodeDegreeCentrality(graph, "nonexistent")).toThrow("Node nonexistent not found");
|
|
152
|
-
});
|
|
153
|
-
it("should handle numeric node ID", () => {
|
|
154
|
-
const graph = new Graph();
|
|
155
|
-
graph.addEdge(1, 2);
|
|
156
|
-
graph.addEdge(1, 3);
|
|
157
|
-
const centrality = nodeDegreeCentrality(graph, 1);
|
|
158
|
-
expect(centrality).toBe(2);
|
|
159
|
-
});
|
|
160
|
-
it("should handle normalized centrality for single node graph", () => {
|
|
161
|
-
const graph = new Graph();
|
|
162
|
-
graph.addNode("only");
|
|
163
|
-
const centrality = nodeDegreeCentrality(graph, "only", { normalized: true });
|
|
164
|
-
expect(centrality).toBe(0);
|
|
165
|
-
});
|
|
166
|
-
it("should handle self-loops for specific node", () => {
|
|
167
|
-
const graph = new Graph({ allowSelfLoops: true, directed: true });
|
|
168
|
-
graph.addEdge("a", "a"); // Self-loop
|
|
169
|
-
graph.addEdge("a", "b");
|
|
170
|
-
graph.addEdge("c", "a");
|
|
171
|
-
expect(nodeDegreeCentrality(graph, "a", { mode: "in" })).toBe(2); // Self-loop + from c
|
|
172
|
-
expect(nodeDegreeCentrality(graph, "a", { mode: "out" })).toBe(2); // Self-loop + to b
|
|
173
|
-
expect(nodeDegreeCentrality(graph, "a", { mode: "total" })).toBe(4);
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
describe("edge cases", () => {
|
|
177
|
-
it("should handle graph with only self-loops", () => {
|
|
178
|
-
const graph = new Graph({ allowSelfLoops: true });
|
|
179
|
-
graph.addEdge("a", "a");
|
|
180
|
-
graph.addEdge("b", "b");
|
|
181
|
-
const centrality = degreeCentrality(graph);
|
|
182
|
-
expect(centrality["a"]).toBe(1);
|
|
183
|
-
expect(centrality["b"]).toBe(1);
|
|
184
|
-
});
|
|
185
|
-
it("should handle complete graph", () => {
|
|
186
|
-
const graph = new Graph();
|
|
187
|
-
// Complete graph with 4 nodes
|
|
188
|
-
const nodes = ["a", "b", "c", "d"];
|
|
189
|
-
for (let i = 0; i < nodes.length; i++) {
|
|
190
|
-
for (let j = i + 1; j < nodes.length; j++) {
|
|
191
|
-
const nodeI = nodes[i];
|
|
192
|
-
const nodeJ = nodes[j];
|
|
193
|
-
if (nodeI && nodeJ) {
|
|
194
|
-
graph.addEdge(nodeI, nodeJ);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
const centrality = degreeCentrality(graph, { normalized: true });
|
|
199
|
-
// Each node connected to all others
|
|
200
|
-
for (const node of nodes) {
|
|
201
|
-
expect(centrality[node]).toBe(1.0);
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
it("should handle large graphs efficiently", () => {
|
|
205
|
-
const graph = new Graph();
|
|
206
|
-
const nodeCount = 1000;
|
|
207
|
-
// Create a star graph
|
|
208
|
-
for (let i = 1; i < nodeCount; i++) {
|
|
209
|
-
graph.addEdge(0, i);
|
|
210
|
-
}
|
|
211
|
-
const centrality = degreeCentrality(graph);
|
|
212
|
-
expect(centrality["0"]).toBe(nodeCount - 1);
|
|
213
|
-
for (let i = 1; i < nodeCount; i++) {
|
|
214
|
-
expect(centrality[i.toString()]).toBe(1);
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
it("should handle mixed node ID types", () => {
|
|
218
|
-
const graph = new Graph();
|
|
219
|
-
graph.addEdge("string", 123);
|
|
220
|
-
graph.addEdge(123, "another");
|
|
221
|
-
const centrality = degreeCentrality(graph);
|
|
222
|
-
expect(centrality["string"]).toBe(1);
|
|
223
|
-
expect(centrality["123"]).toBe(2);
|
|
224
|
-
expect(centrality["another"]).toBe(1);
|
|
225
|
-
});
|
|
226
|
-
it("should handle normalized centrality edge case with division by zero", () => {
|
|
227
|
-
const graph = new Graph();
|
|
228
|
-
graph.addNode("only");
|
|
229
|
-
const centrality = degreeCentrality(graph, { normalized: true });
|
|
230
|
-
// Should handle division by zero gracefully
|
|
231
|
-
expect(centrality["only"]).toBe(0);
|
|
232
|
-
});
|
|
233
|
-
it("should maintain consistency between undirected and directed default behavior", () => {
|
|
234
|
-
const undirectedGraph = new Graph({ directed: false });
|
|
235
|
-
const directedGraph = new Graph({ directed: true });
|
|
236
|
-
// Same edges added to both
|
|
237
|
-
undirectedGraph.addEdge("a", "b");
|
|
238
|
-
directedGraph.addEdge("a", "b");
|
|
239
|
-
const undirectedCentrality = degreeCentrality(undirectedGraph);
|
|
240
|
-
const directedCentrality = degreeCentrality(directedGraph);
|
|
241
|
-
// In undirected graph, both nodes have degree 1
|
|
242
|
-
expect(undirectedCentrality["a"]).toBe(1);
|
|
243
|
-
expect(undirectedCentrality["b"]).toBe(1);
|
|
244
|
-
// In directed graph, total degree by default
|
|
245
|
-
expect(directedCentrality["a"]).toBe(1); // out-degree: 1
|
|
246
|
-
expect(directedCentrality["b"]).toBe(1); // in-degree: 1
|
|
247
|
-
});
|
|
248
|
-
it("should handle very high degree nodes", () => {
|
|
249
|
-
const graph = new Graph();
|
|
250
|
-
// Create a node with very high degree
|
|
251
|
-
const centerNode = "center";
|
|
252
|
-
for (let i = 0; i < 10000; i++) {
|
|
253
|
-
graph.addEdge(centerNode, `node_${i}`);
|
|
254
|
-
}
|
|
255
|
-
const centrality = nodeDegreeCentrality(graph, centerNode);
|
|
256
|
-
expect(centrality).toBe(10000);
|
|
257
|
-
});
|
|
258
|
-
});
|
|
259
|
-
});
|
|
260
|
-
//# sourceMappingURL=degree-centrality.test.js.map
|