@thi.ng/adjacency 2.4.0 → 2.4.1
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 +4 -3
- package/api.d.ts +6 -0
- package/binary.d.ts +1 -0
- package/binary.js +3 -0
- package/list.d.ts +1 -0
- package/list.js +3 -0
- package/package.json +5 -2
- package/sparse.d.ts +1 -0
- package/sparse.js +3 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -73,7 +73,7 @@ For Node.js REPL:
|
|
|
73
73
|
const adjacency = await import("@thi.ng/adjacency");
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 2.
|
|
76
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 2.57 KB
|
|
77
77
|
|
|
78
78
|
## Dependencies
|
|
79
79
|
|
|
@@ -104,14 +104,15 @@ TODO
|
|
|
104
104
|
|
|
105
105
|
## Authors
|
|
106
106
|
|
|
107
|
-
- [Karsten Schmidt](https://thi.ng)
|
|
107
|
+
- [Karsten Schmidt](https://thi.ng) (Main author)
|
|
108
|
+
- [Igor Loskutov](https://github.com/Firfi)
|
|
108
109
|
|
|
109
110
|
If this project contributes to an academic publication, please cite it as:
|
|
110
111
|
|
|
111
112
|
```bibtex
|
|
112
113
|
@misc{thing-adjacency,
|
|
113
114
|
title = "@thi.ng/adjacency",
|
|
114
|
-
author = "Karsten Schmidt",
|
|
115
|
+
author = "Karsten Schmidt and others",
|
|
115
116
|
note = "https://thi.ng/adjacency",
|
|
116
117
|
year = 2018
|
|
117
118
|
}
|
package/api.d.ts
CHANGED
|
@@ -38,6 +38,12 @@ export interface IGraph<T = number> {
|
|
|
38
38
|
* @param to -
|
|
39
39
|
*/
|
|
40
40
|
hasEdge(from: T, to: T): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Returns true if a vertex exists for the given id.
|
|
43
|
+
*
|
|
44
|
+
* @param id -
|
|
45
|
+
*/
|
|
46
|
+
hasVertex(id: T): boolean;
|
|
41
47
|
/**
|
|
42
48
|
* Returns number of edges for given vertex. By default only outgoing edges
|
|
43
49
|
* are counted, but can be customized via given {@link DegreeType}. Note: In
|
package/binary.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export declare class AdjacencyBitMatrix implements IGraph<number> {
|
|
|
23
23
|
addEdge(from: number, to: number): boolean;
|
|
24
24
|
removeEdge(from: number, to: number): boolean;
|
|
25
25
|
hasEdge(from: number, to: number): boolean;
|
|
26
|
+
hasVertex(id: number): boolean;
|
|
26
27
|
degree(id: number, type?: DegreeType): number;
|
|
27
28
|
neighbors(id: number): number[];
|
|
28
29
|
similarity(id: number, threshold?: number): number[][];
|
package/binary.js
CHANGED
|
@@ -57,6 +57,9 @@ export class AdjacencyBitMatrix {
|
|
|
57
57
|
hasEdge(from, to) {
|
|
58
58
|
return this.mat.at(from, to) !== 0;
|
|
59
59
|
}
|
|
60
|
+
hasVertex(id) {
|
|
61
|
+
return (this.mat.popCountRow(id) !== 0 || this.mat.popCountColumn(id) !== 0);
|
|
62
|
+
}
|
|
60
63
|
degree(id, type = "out") {
|
|
61
64
|
let degree = 0;
|
|
62
65
|
if (this.undirected || type !== "in")
|
package/list.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare class AdjacencyList implements IGraph<number> {
|
|
|
12
12
|
edges(): Generator<Edge, void, unknown>;
|
|
13
13
|
addVertex(id: number): void;
|
|
14
14
|
removeVertex(id: number): boolean;
|
|
15
|
+
hasVertex(id: number): boolean;
|
|
15
16
|
addEdge(from: number, to: number): boolean;
|
|
16
17
|
removeEdge(from: number, to: number): boolean;
|
|
17
18
|
hasEdge(from: number, to: number): boolean;
|
package/list.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/adjacency",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.1",
|
|
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",
|
|
@@ -22,6 +22,9 @@
|
|
|
22
22
|
}
|
|
23
23
|
],
|
|
24
24
|
"author": "Karsten Schmidt (https://thi.ng)",
|
|
25
|
+
"contributors": [
|
|
26
|
+
"Igor Loskutov (https://github.com/Firfi)"
|
|
27
|
+
],
|
|
25
28
|
"license": "Apache-2.0",
|
|
26
29
|
"scripts": {
|
|
27
30
|
"build": "yarn clean && tsc --declaration",
|
|
@@ -122,5 +125,5 @@
|
|
|
122
125
|
],
|
|
123
126
|
"year": 2018
|
|
124
127
|
},
|
|
125
|
-
"gitHead": "
|
|
128
|
+
"gitHead": "ae301a8a5f13f518dec04a975479c6e779a8ca9e\n"
|
|
126
129
|
}
|
package/sparse.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare class AdjacencyMatrix extends CSR implements IGraph<number> {
|
|
|
7
7
|
addEdge(from: number, to: number): boolean;
|
|
8
8
|
removeEdge(from: number, to: number): boolean;
|
|
9
9
|
hasEdge(from: number, to: number): boolean;
|
|
10
|
+
hasVertex(id: number): boolean;
|
|
10
11
|
numEdges(): number;
|
|
11
12
|
numVertices(): number;
|
|
12
13
|
degree(id: number, type?: DegreeType): number;
|
package/sparse.js
CHANGED