@thi.ng/adjacency 2.5.50 → 2.5.52

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-04-23T07:02:17Z
3
+ - **Last updated**: 2024-06-21T19:34:38Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)](https://mastodon.thi.ng/@toxi)
8
8
 
9
9
  > [!NOTE]
10
- > This is one of 192 standalone projects, maintained as part
10
+ > This is one of 193 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
@@ -37,8 +37,7 @@ class BFS {
37
37
  return this.marked.at(id) !== 0;
38
38
  }
39
39
  pathTo(id) {
40
- if (!this.marked.at(id))
41
- return;
40
+ if (!this.marked.at(id)) return;
42
41
  const { dist, edges } = this;
43
42
  const path = new DCons();
44
43
  for (; dist[id] > 0; id = edges[id]) {
package/binary.js CHANGED
@@ -73,11 +73,9 @@ class AdjacencyBitMatrix {
73
73
  const query = mat.row(id, true);
74
74
  const acc = [];
75
75
  for (let i = 0, m = mat.m; i < m; i++) {
76
- if (i === id)
77
- continue;
76
+ if (i === id) continue;
78
77
  const sim = query.similarity(mat.row(i, true));
79
- if (sim >= threshold)
80
- acc.push([i, sim]);
78
+ if (sim >= threshold) acc.push([i, sim]);
81
79
  }
82
80
  return acc.sort((a, b) => b[1] - a[1]);
83
81
  }
package/dfs.js CHANGED
@@ -27,8 +27,7 @@ class DFS {
27
27
  return this.marked.at(id) !== 0;
28
28
  }
29
29
  pathTo(id) {
30
- if (!this.marked.at(id))
31
- return;
30
+ if (!this.marked.at(id)) return;
32
31
  const { edges, src } = this;
33
32
  const path = new DCons();
34
33
  for (; id !== src; id = edges[id]) {
package/floyd-warshall.js CHANGED
@@ -61,8 +61,7 @@ class FloydWarshall {
61
61
  *path(a, b) {
62
62
  this.ensurePair(a, b);
63
63
  const { next, numV } = this;
64
- if (next[a * numV + b] === -1)
65
- return;
64
+ if (next[a * numV + b] === -1) return;
66
65
  yield a;
67
66
  while (a !== b) {
68
67
  a = next[a * numV + b];
package/list.js CHANGED
@@ -16,18 +16,15 @@ class AdjacencyList {
16
16
  *vertices() {
17
17
  const { adjacency } = this;
18
18
  for (let i = 0, n = adjacency.length; i < n; i++) {
19
- if (adjacency[i])
20
- yield i;
19
+ if (adjacency[i]) yield i;
21
20
  }
22
21
  }
23
22
  *edges() {
24
23
  const { adjacency } = this;
25
24
  for (let i = 0, n = adjacency.length; i < n; i++) {
26
25
  const vertex = adjacency[i];
27
- if (!vertex)
28
- continue;
29
- for (let j of vertex)
30
- yield [i, j];
26
+ if (!vertex) continue;
27
+ for (let j of vertex) yield [i, j];
31
28
  }
32
29
  }
33
30
  addVertex(id) {
@@ -36,8 +33,7 @@ class AdjacencyList {
36
33
  removeVertex(id) {
37
34
  const { adjacency, indegree } = this;
38
35
  const vertex = adjacency[id];
39
- if (!vertex)
40
- return false;
36
+ if (!vertex) return false;
41
37
  while (vertex.length) {
42
38
  indegree[vertex.pop()]--;
43
39
  this.numE--;
@@ -45,10 +41,8 @@ class AdjacencyList {
45
41
  delete adjacency[id];
46
42
  for (let i = 0, n = adjacency.length; i < n && indegree[id] > 0; i++) {
47
43
  const vertex2 = adjacency[i];
48
- if (!vertex2)
49
- continue;
50
- while (vertex2.includes(id))
51
- this.removeEdge(i, id);
44
+ if (!vertex2) continue;
45
+ while (vertex2.includes(id)) this.removeEdge(i, id);
52
46
  }
53
47
  this.numV--;
54
48
  return true;
@@ -85,10 +79,8 @@ class AdjacencyList {
85
79
  let degree = 0;
86
80
  const vertex = this.adjacency[id];
87
81
  if (vertex) {
88
- if (type !== "in")
89
- degree += vertex.length;
90
- if (type !== "out")
91
- degree += this.indegree[id];
82
+ if (type !== "in") degree += vertex.length;
83
+ if (type !== "out") degree += this.indegree[id];
92
84
  }
93
85
  return degree;
94
86
  }
@@ -115,8 +107,7 @@ class AdjacencyList {
115
107
  }
116
108
  ensureVertexData(id) {
117
109
  const vertex = this.adjacency[id];
118
- if (vertex)
119
- return vertex;
110
+ if (vertex) return vertex;
120
111
  this.numV++;
121
112
  this.indegree[id] = 0;
122
113
  return this.adjacency[id] = [];
@@ -127,10 +118,8 @@ const adjListFromAdjacency = (src) => {
127
118
  const res = new AdjacencyList();
128
119
  for (let i = 0, n = src.length; i < n; i++) {
129
120
  const v = src[i];
130
- if (!v)
131
- continue;
132
- for (let w of v)
133
- res.addEdge(i, w);
121
+ if (!v) continue;
122
+ for (let w of v) res.addEdge(i, w);
134
123
  }
135
124
  return res;
136
125
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/adjacency",
3
- "version": "2.5.50",
3
+ "version": "2.5.52",
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",
@@ -10,7 +10,7 @@
10
10
  "type": "git",
11
11
  "url": "https://github.com/thi-ng/umbrella.git"
12
12
  },
13
- "homepage": "https://github.com/thi-ng/umbrella/tree/develop/packages/adjacency#readme",
13
+ "homepage": "https://thi.ng/adjacency",
14
14
  "funding": [
15
15
  {
16
16
  "type": "github",
@@ -39,19 +39,19 @@
39
39
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@thi.ng/api": "^8.11.1",
43
- "@thi.ng/arrays": "^2.9.5",
44
- "@thi.ng/bitfield": "^2.3.40",
45
- "@thi.ng/dcons": "^3.2.112",
46
- "@thi.ng/errors": "^2.5.6",
47
- "@thi.ng/sparse": "^0.3.117"
42
+ "@thi.ng/api": "^8.11.3",
43
+ "@thi.ng/arrays": "^2.9.7",
44
+ "@thi.ng/bitfield": "^2.3.42",
45
+ "@thi.ng/dcons": "^3.2.114",
46
+ "@thi.ng/errors": "^2.5.8",
47
+ "@thi.ng/sparse": "^0.3.119"
48
48
  },
49
49
  "devDependencies": {
50
- "@microsoft/api-extractor": "^7.43.0",
51
- "@thi.ng/vectors": "^7.10.30",
52
- "esbuild": "^0.20.2",
53
- "typedoc": "^0.25.12",
54
- "typescript": "^5.4.3"
50
+ "@microsoft/api-extractor": "^7.47.0",
51
+ "@thi.ng/vectors": "^7.11.0",
52
+ "esbuild": "^0.21.5",
53
+ "typedoc": "^0.25.13",
54
+ "typescript": "^5.5.2"
55
55
  },
56
56
  "keywords": [
57
57
  "adjacency",
@@ -125,5 +125,5 @@
125
125
  ],
126
126
  "year": 2018
127
127
  },
128
- "gitHead": "aed3421c21044c005fbcb7cc37965ccf85a870d2\n"
128
+ "gitHead": "154c95cf9d6bab32174498ec3b5b5d87e42be7f9\n"
129
129
  }
package/sparse.js CHANGED
@@ -52,10 +52,8 @@ class AdjacencyMatrix extends CSR {
52
52
  degree(id, type = "out") {
53
53
  let degree = 0;
54
54
  ensureIndex2(id, id, this.m, this.n);
55
- if (this.undirected || type !== "in")
56
- degree += this.nnzRow(id);
57
- if (!this.undirected && type !== "out")
58
- degree += this.nnzCol(id);
55
+ if (this.undirected || type !== "in") degree += this.nnzRow(id);
56
+ if (!this.undirected && type !== "out") degree += this.nnzCol(id);
59
57
  return degree;
60
58
  }
61
59
  neighbors(id) {
package/utils.d.ts CHANGED
@@ -5,5 +5,5 @@ export declare const __toDot: (edges: Iterable<Pair<number, number>>, undirected
5
5
  /** @internal */
6
6
  export declare const __into: (graph: IGraph, edges: Iterable<Edge>) => void;
7
7
  /** @internal */
8
- export declare const __invert: <T extends IGraph<number>>(graph: T, edges: Iterable<Edge>) => T;
8
+ export declare const __invert: <T extends IGraph>(graph: T, edges: Iterable<Edge>) => T;
9
9
  //# sourceMappingURL=utils.d.ts.map