@thi.ng/adjacency 3.0.63 → 3.0.64
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 +1 -1
- package/bfs.js +1 -1
- package/binary.js +1 -1
- package/dfs.js +1 -1
- package/floyd-warshall.js +1 -1
- package/list.js +2 -2
- package/mst.js +1 -1
- package/package.json +10 -10
- package/utils.js +3 -3
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 211 standalone projects, maintained as part
|
|
11
11
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
package/bfs.js
CHANGED
package/binary.js
CHANGED
package/dfs.js
CHANGED
package/floyd-warshall.js
CHANGED
|
@@ -14,7 +14,7 @@ class FloydWarshall {
|
|
|
14
14
|
const numV = this.numV = graph.numVertices();
|
|
15
15
|
const dist = this.dist = new Float32Array(numV * numV).fill(Infinity);
|
|
16
16
|
const next = this.next = new Int32Array(numV * numV).fill(-1);
|
|
17
|
-
for (
|
|
17
|
+
for (const [u, v] of graph.edges()) {
|
|
18
18
|
const idx = u * numV + v;
|
|
19
19
|
dist[idx] = cost(u, v);
|
|
20
20
|
next[idx] = v;
|
package/list.js
CHANGED
|
@@ -24,7 +24,7 @@ class AdjacencyList {
|
|
|
24
24
|
for (let i = 0, n = adjacency.length; i < n; i++) {
|
|
25
25
|
const vertex = adjacency[i];
|
|
26
26
|
if (!vertex) continue;
|
|
27
|
-
for (
|
|
27
|
+
for (const j of vertex) yield [i, j];
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
addVertex(id) {
|
|
@@ -119,7 +119,7 @@ const adjListFromAdjacency = (src) => {
|
|
|
119
119
|
for (let i = 0, n = src.length; i < n; i++) {
|
|
120
120
|
const v = src[i];
|
|
121
121
|
if (!v) continue;
|
|
122
|
-
for (
|
|
122
|
+
for (const w of v) res.addEdge(i, w);
|
|
123
123
|
}
|
|
124
124
|
return res;
|
|
125
125
|
};
|
package/mst.js
CHANGED
|
@@ -3,7 +3,7 @@ import { DisjointSet } from "@thi.ng/disjoint-set";
|
|
|
3
3
|
const mst = (edges, maxID, cost, verts) => {
|
|
4
4
|
const graph = new DisjointSet(maxID + 1);
|
|
5
5
|
const res = [];
|
|
6
|
-
for (
|
|
6
|
+
for (const e of sortByCachedKey(edges, cost)) {
|
|
7
7
|
const v = verts(e);
|
|
8
8
|
if (!graph.unified(v[0], v[1])) {
|
|
9
9
|
graph.union(v[0], v[1]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/adjacency",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.64",
|
|
4
4
|
"description": "Sparse & bitwise adjacency matrices, lists and selected traversal algorithms for directed & undirected graphs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -42,16 +42,16 @@
|
|
|
42
42
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@thi.ng/api": "^8.12.
|
|
46
|
-
"@thi.ng/arrays": "^2.14.
|
|
47
|
-
"@thi.ng/bitfield": "^2.4.
|
|
48
|
-
"@thi.ng/dcons": "^3.2.
|
|
49
|
-
"@thi.ng/disjoint-set": "^1.1.
|
|
50
|
-
"@thi.ng/errors": "^2.5.
|
|
51
|
-
"@thi.ng/sparse": "^1.1.
|
|
45
|
+
"@thi.ng/api": "^8.12.10",
|
|
46
|
+
"@thi.ng/arrays": "^2.14.3",
|
|
47
|
+
"@thi.ng/bitfield": "^2.4.22",
|
|
48
|
+
"@thi.ng/dcons": "^3.2.178",
|
|
49
|
+
"@thi.ng/disjoint-set": "^1.1.37",
|
|
50
|
+
"@thi.ng/errors": "^2.5.50",
|
|
51
|
+
"@thi.ng/sparse": "^1.1.25"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@thi.ng/vectors": "^8.6.
|
|
54
|
+
"@thi.ng/vectors": "^8.6.15",
|
|
55
55
|
"esbuild": "^0.27.0",
|
|
56
56
|
"typedoc": "^0.28.14",
|
|
57
57
|
"typescript": "^5.9.3"
|
|
@@ -125,5 +125,5 @@
|
|
|
125
125
|
],
|
|
126
126
|
"year": 2018
|
|
127
127
|
},
|
|
128
|
-
"gitHead": "
|
|
128
|
+
"gitHead": "824bf9047b5a10f777c5c5b4aeecf0c750a22c75\n"
|
|
129
129
|
}
|
package/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const __toDot = (edges, undirected, ids) => {
|
|
2
2
|
const [type, sep] = undirected ? ["graph", "--"] : ["digraph", "->"];
|
|
3
3
|
const res = [`${type} g {`];
|
|
4
|
-
for (
|
|
4
|
+
for (const e of edges) {
|
|
5
5
|
res.push(
|
|
6
6
|
ids ? `"${ids[e[0]]}"${sep}"${ids[e[1]]}";` : `"${e[0]}"${sep}"${e[1]}";`
|
|
7
7
|
);
|
|
@@ -10,12 +10,12 @@ const __toDot = (edges, undirected, ids) => {
|
|
|
10
10
|
return res.join("\n");
|
|
11
11
|
};
|
|
12
12
|
const __into = (graph, edges) => {
|
|
13
|
-
for (
|
|
13
|
+
for (const e of edges) {
|
|
14
14
|
graph.addEdge(e[0], e[1]);
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
17
|
const __invert = (graph, edges) => {
|
|
18
|
-
for (
|
|
18
|
+
for (const e of edges) {
|
|
19
19
|
graph.addEdge(e[1], e[0]);
|
|
20
20
|
}
|
|
21
21
|
return graph;
|