@thi.ng/adjacency 2.2.18 → 2.2.20
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 +1 -1
- package/README.md +7 -10
- package/api.d.ts +3 -3
- package/binary.d.ts +4 -3
- package/binary.js +4 -3
- package/disjoint-set.d.ts +4 -4
- package/disjoint-set.js +4 -4
- package/mst.d.ts +4 -2
- package/mst.js +4 -2
- package/package.json +14 -14
- package/sparse.d.ts +12 -9
- package/sparse.js +12 -9
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<!-- This file is generated - DO NOT EDIT! -->
|
|
2
2
|
|
|
3
|
-
# 
|
|
3
|
+
# 
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@thi.ng/adjacency)
|
|
6
6
|

|
|
7
|
-
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
This project is part of the
|
|
10
10
|
[@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo.
|
|
@@ -21,7 +21,7 @@ This project is part of the
|
|
|
21
21
|
|
|
22
22
|
## About
|
|
23
23
|
|
|
24
|
-
Sparse & bitwise adjacency matrices and related functions for directed & undirected graphs
|
|
24
|
+
Sparse & bitwise adjacency matrices and related functions for directed & undirected graphs
|
|
25
25
|
|
|
26
26
|
## Status
|
|
27
27
|
|
|
@@ -49,11 +49,8 @@ ES module import:
|
|
|
49
49
|
|
|
50
50
|
For Node.js REPL:
|
|
51
51
|
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
node --experimental-repl-await
|
|
55
|
-
|
|
56
|
-
> const adjacency = await import("@thi.ng/adjacency");
|
|
52
|
+
```js
|
|
53
|
+
const adjacency = await import("@thi.ng/adjacency");
|
|
57
54
|
```
|
|
58
55
|
|
|
59
56
|
Package sizes (brotli'd, pre-treeshake): ESM: 2.28 KB
|
|
@@ -87,7 +84,7 @@ TODO
|
|
|
87
84
|
|
|
88
85
|
## Authors
|
|
89
86
|
|
|
90
|
-
Karsten Schmidt
|
|
87
|
+
- [Karsten Schmidt](https://thi.ng)
|
|
91
88
|
|
|
92
89
|
If this project contributes to an academic publication, please cite it as:
|
|
93
90
|
|
|
@@ -102,4 +99,4 @@ If this project contributes to an academic publication, please cite it as:
|
|
|
102
99
|
|
|
103
100
|
## License
|
|
104
101
|
|
|
105
|
-
© 2018 - 2022 Karsten Schmidt // Apache
|
|
102
|
+
© 2018 - 2022 Karsten Schmidt // Apache License 2.0
|
package/api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Fn2, Pair } from "@thi.ng/api";
|
|
2
|
-
export
|
|
2
|
+
export type DegreeType = "in" | "out" | "inout";
|
|
3
3
|
/**
|
|
4
4
|
* @typeParam T - vertex type (default: `number`)
|
|
5
5
|
*/
|
|
@@ -63,6 +63,6 @@ export interface IGraph<T = number> {
|
|
|
63
63
|
*/
|
|
64
64
|
invert(): IGraph<T>;
|
|
65
65
|
}
|
|
66
|
-
export
|
|
67
|
-
export
|
|
66
|
+
export type Edge<T = number> = Pair<T, T>;
|
|
67
|
+
export type CostFn<T = number> = Fn2<T, T, number>;
|
|
68
68
|
//# sourceMappingURL=api.d.ts.map
|
package/binary.d.ts
CHANGED
|
@@ -30,10 +30,11 @@ export declare class AdjacencyBitMatrix implements IGraph<number> {
|
|
|
30
30
|
toDot(ids?: string[]): string;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
* Creates adjacency matrix backed by a
|
|
33
|
+
* Creates adjacency matrix backed by a
|
|
34
|
+
* [`BitMatrix`](https://docs.thi.ng/umbrella/bitfield/classes/BitMatrix.html)
|
|
34
35
|
* with capacity `n` (max vertices), optionally initialized with given edge
|
|
35
|
-
* pairs. Each edge is `[src-node dest-node]`. If `undirected` is true
|
|
36
|
-
*
|
|
36
|
+
* pairs. Each edge is `[src-node dest-node]`. If `undirected` is true (default:
|
|
37
|
+
* false), creates symmetrical adjacencies.
|
|
37
38
|
*
|
|
38
39
|
* @param n - max vertices
|
|
39
40
|
* @param edges - edge pairs
|
package/binary.js
CHANGED
|
@@ -90,10 +90,11 @@ export class AdjacencyBitMatrix {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
|
-
* Creates adjacency matrix backed by a
|
|
93
|
+
* Creates adjacency matrix backed by a
|
|
94
|
+
* [`BitMatrix`](https://docs.thi.ng/umbrella/bitfield/classes/BitMatrix.html)
|
|
94
95
|
* with capacity `n` (max vertices), optionally initialized with given edge
|
|
95
|
-
* pairs. Each edge is `[src-node dest-node]`. If `undirected` is true
|
|
96
|
-
*
|
|
96
|
+
* pairs. Each edge is `[src-node dest-node]`. If `undirected` is true (default:
|
|
97
|
+
* false), creates symmetrical adjacencies.
|
|
97
98
|
*
|
|
98
99
|
* @param n - max vertices
|
|
99
100
|
* @param edges - edge pairs
|
package/disjoint-set.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Typed array based Disjoint Set implementation with quick union and
|
|
3
|
-
*
|
|
2
|
+
* Typed array based Disjoint Set implementation with quick union and path
|
|
3
|
+
* compression, after Sedgewick & Wayne.
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
6
|
+
* - https://en.wikipedia.org/wiki/Disjoint-set_data_structure
|
|
7
|
+
* - https://algs4.cs.princeton.edu/lectures/15UnionFind-2x2.pdf
|
|
8
8
|
*/
|
|
9
9
|
export declare class DisjointSet {
|
|
10
10
|
roots: Uint32Array;
|
package/disjoint-set.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { fillRange } from "@thi.ng/arrays/fill-range";
|
|
2
2
|
/**
|
|
3
|
-
* Typed array based Disjoint Set implementation with quick union and
|
|
4
|
-
*
|
|
3
|
+
* Typed array based Disjoint Set implementation with quick union and path
|
|
4
|
+
* compression, after Sedgewick & Wayne.
|
|
5
5
|
*
|
|
6
6
|
* @remarks
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
7
|
+
* - https://en.wikipedia.org/wiki/Disjoint-set_data_structure
|
|
8
|
+
* - https://algs4.cs.princeton.edu/lectures/15UnionFind-2x2.pdf
|
|
9
9
|
*/
|
|
10
10
|
export class DisjointSet {
|
|
11
11
|
/**
|
package/mst.d.ts
CHANGED
|
@@ -15,9 +15,11 @@ import type { Fn } from "@thi.ng/api";
|
|
|
15
15
|
* criteria. The result edges will be in ascending order, based on the supplied
|
|
16
16
|
* cost function. The cost function is called once for each edge and return
|
|
17
17
|
* values will be cached prior to sorting (see
|
|
18
|
-
*
|
|
18
|
+
* [`sortByCachedKey()`](https://docs.thi.ng/umbrella/arrays/functions/sortByCachedKey.html)
|
|
19
|
+
* for details).
|
|
19
20
|
*
|
|
20
|
-
*
|
|
21
|
+
* References:
|
|
22
|
+
* - https://en.wikipedia.org/wiki/Kruskal%27s_algorithm
|
|
21
23
|
*
|
|
22
24
|
* @example
|
|
23
25
|
* ```ts
|
package/mst.js
CHANGED
|
@@ -16,9 +16,11 @@ import { DisjointSet } from "./disjoint-set.js";
|
|
|
16
16
|
* criteria. The result edges will be in ascending order, based on the supplied
|
|
17
17
|
* cost function. The cost function is called once for each edge and return
|
|
18
18
|
* values will be cached prior to sorting (see
|
|
19
|
-
*
|
|
19
|
+
* [`sortByCachedKey()`](https://docs.thi.ng/umbrella/arrays/functions/sortByCachedKey.html)
|
|
20
|
+
* for details).
|
|
20
21
|
*
|
|
21
|
-
*
|
|
22
|
+
* References:
|
|
23
|
+
* - https://en.wikipedia.org/wiki/Kruskal%27s_algorithm
|
|
22
24
|
*
|
|
23
25
|
* @example
|
|
24
26
|
* ```ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/adjacency",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.20",
|
|
4
4
|
"description": "Sparse & bitwise adjacency matrices and related functions for directed & undirected graphs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"url": "https://patreon.com/thing_umbrella"
|
|
22
22
|
}
|
|
23
23
|
],
|
|
24
|
-
"author": "Karsten Schmidt
|
|
24
|
+
"author": "Karsten Schmidt (https://thi.ng)",
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "yarn clean && tsc --declaration",
|
|
@@ -34,21 +34,21 @@
|
|
|
34
34
|
"test": "testament test"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thi.ng/api": "^8.
|
|
38
|
-
"@thi.ng/arrays": "^2.4.
|
|
39
|
-
"@thi.ng/bitfield": "^2.2.
|
|
40
|
-
"@thi.ng/dcons": "^3.2.
|
|
41
|
-
"@thi.ng/errors": "^2.2.
|
|
42
|
-
"@thi.ng/sparse": "^0.3.
|
|
37
|
+
"@thi.ng/api": "^8.6.1",
|
|
38
|
+
"@thi.ng/arrays": "^2.4.6",
|
|
39
|
+
"@thi.ng/bitfield": "^2.2.16",
|
|
40
|
+
"@thi.ng/dcons": "^3.2.27",
|
|
41
|
+
"@thi.ng/errors": "^2.2.6",
|
|
42
|
+
"@thi.ng/sparse": "^0.3.32"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@microsoft/api-extractor": "^7.33.
|
|
46
|
-
"@thi.ng/testament": "^0.3.
|
|
47
|
-
"@thi.ng/vectors": "^7.5.
|
|
45
|
+
"@microsoft/api-extractor": "^7.33.7",
|
|
46
|
+
"@thi.ng/testament": "^0.3.7",
|
|
47
|
+
"@thi.ng/vectors": "^7.5.28",
|
|
48
48
|
"rimraf": "^3.0.2",
|
|
49
49
|
"tools": "^0.0.1",
|
|
50
|
-
"typedoc": "^0.23.
|
|
51
|
-
"typescript": "^4.
|
|
50
|
+
"typedoc": "^0.23.22",
|
|
51
|
+
"typescript": "^4.9.4"
|
|
52
52
|
},
|
|
53
53
|
"keywords": [
|
|
54
54
|
"adjacency",
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
],
|
|
120
120
|
"year": 2018
|
|
121
121
|
},
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "7b2af448da8a63fb21704a79cc4cdf1f3d7d7a64\n"
|
|
123
123
|
}
|
package/sparse.d.ts
CHANGED
|
@@ -13,7 +13,8 @@ export declare class AdjacencyMatrix extends CSR implements IGraph<number> {
|
|
|
13
13
|
neighbors(id: number): number[];
|
|
14
14
|
invert(): AdjacencyMatrix;
|
|
15
15
|
/**
|
|
16
|
-
* Returns a diagonal sparse matrix
|
|
16
|
+
* Returns a diagonal sparse matrix
|
|
17
|
+
* [`CSR`](https://docs.thi.ng/umbrella/sparse/classes/CSR.html) containing
|
|
17
18
|
* information about the degree of each vertex, i.e. the number of edges
|
|
18
19
|
* attached to each vertex.
|
|
19
20
|
*
|
|
@@ -24,12 +25,13 @@ export declare class AdjacencyMatrix extends CSR implements IGraph<number> {
|
|
|
24
25
|
*/
|
|
25
26
|
degreeMat(deg?: DegreeType): CSR;
|
|
26
27
|
/**
|
|
27
|
-
* Returns this graph's Laplacian matrix: `L = D - A` Where `D` is
|
|
28
|
-
*
|
|
28
|
+
* Returns this graph's Laplacian matrix: `L = D - A` Where `D` is the
|
|
29
|
+
* degree matrix and `A` this adjacency matrix.
|
|
29
30
|
*
|
|
30
31
|
* @remarks
|
|
31
|
-
*
|
|
32
|
-
* -
|
|
32
|
+
* References:
|
|
33
|
+
* - https://en.wikipedia.org/wiki/Laplacian_matrix
|
|
34
|
+
* - https://en.wikipedia.org/wiki/Discrete_Laplace_operator
|
|
33
35
|
*
|
|
34
36
|
* @param deg - degree type for {@link AdjacencyMatrix.degreeMat}
|
|
35
37
|
*/
|
|
@@ -50,10 +52,11 @@ export declare class AdjacencyMatrix extends CSR implements IGraph<number> {
|
|
|
50
52
|
toDot(ids?: string[]): string;
|
|
51
53
|
}
|
|
52
54
|
/**
|
|
53
|
-
* Creates an adjacency matrix backed by a sparse
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
55
|
+
* Creates an adjacency matrix backed by a sparse
|
|
56
|
+
* [`CSR`](https://docs.thi.ng/umbrella/sparse/classes/CSR.html) matrix,
|
|
57
|
+
* optionally initialize with given edge pairs. Each edge is a `[src, dest]`
|
|
58
|
+
* tuple. If `undirected` is true (default: false), creates symmetrical edges
|
|
59
|
+
* (i.e. undirected graph).
|
|
57
60
|
*
|
|
58
61
|
* @param n - max number of vertices
|
|
59
62
|
* @param edges - edge pairs
|
package/sparse.js
CHANGED
|
@@ -61,7 +61,8 @@ export class AdjacencyMatrix extends CSR {
|
|
|
61
61
|
return __invert(defAdjMatrix(this.m, undefined, this.undirected), this.edges());
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
|
-
* Returns a diagonal sparse matrix
|
|
64
|
+
* Returns a diagonal sparse matrix
|
|
65
|
+
* [`CSR`](https://docs.thi.ng/umbrella/sparse/classes/CSR.html) containing
|
|
65
66
|
* information about the degree of each vertex, i.e. the number of edges
|
|
66
67
|
* attached to each vertex.
|
|
67
68
|
*
|
|
@@ -93,12 +94,13 @@ export class AdjacencyMatrix extends CSR {
|
|
|
93
94
|
return res;
|
|
94
95
|
}
|
|
95
96
|
/**
|
|
96
|
-
* Returns this graph's Laplacian matrix: `L = D - A` Where `D` is
|
|
97
|
-
*
|
|
97
|
+
* Returns this graph's Laplacian matrix: `L = D - A` Where `D` is the
|
|
98
|
+
* degree matrix and `A` this adjacency matrix.
|
|
98
99
|
*
|
|
99
100
|
* @remarks
|
|
100
|
-
*
|
|
101
|
-
* -
|
|
101
|
+
* References:
|
|
102
|
+
* - https://en.wikipedia.org/wiki/Laplacian_matrix
|
|
103
|
+
* - https://en.wikipedia.org/wiki/Discrete_Laplace_operator
|
|
102
104
|
*
|
|
103
105
|
* @param deg - degree type for {@link AdjacencyMatrix.degreeMat}
|
|
104
106
|
*/
|
|
@@ -144,10 +146,11 @@ export class AdjacencyMatrix extends CSR {
|
|
|
144
146
|
}
|
|
145
147
|
}
|
|
146
148
|
/**
|
|
147
|
-
* Creates an adjacency matrix backed by a sparse
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
149
|
+
* Creates an adjacency matrix backed by a sparse
|
|
150
|
+
* [`CSR`](https://docs.thi.ng/umbrella/sparse/classes/CSR.html) matrix,
|
|
151
|
+
* optionally initialize with given edge pairs. Each edge is a `[src, dest]`
|
|
152
|
+
* tuple. If `undirected` is true (default: false), creates symmetrical edges
|
|
153
|
+
* (i.e. undirected graph).
|
|
151
154
|
*
|
|
152
155
|
* @param n - max number of vertices
|
|
153
156
|
* @param edges - edge pairs
|