@thi.ng/adjacency 2.2.19 → 2.3.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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2022-12-16T12:52:25Z
3
+ - **Last updated**: 2022-12-22T21:47:07Z
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.
@@ -9,6 +9,13 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ## [2.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/adjacency@2.3.0) (2022-12-22)
13
+
14
+ #### 🚀 Features
15
+
16
+ - add FloydWarshall shortest-path impl ([26fa3ac](https://github.com/thi-ng/umbrella/commit/26fa3ac))
17
+ - update BFS distance array to Float32Array ([3997923](https://github.com/thi-ng/umbrella/commit/3997923))
18
+
12
19
  ### [2.2.12](https://github.com/thi-ng/umbrella/tree/@thi.ng/adjacency@2.2.12) (2022-10-26)
13
20
 
14
21
  #### ♻️ Refactoring
package/README.md CHANGED
@@ -10,6 +10,8 @@ This project is part of the
10
10
  [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo.
11
11
 
12
12
  - [About](#about)
13
+ - [Graph implementations](#graph-implementations)
14
+ - [Traversals](#traversals)
13
15
  - [Status](#status)
14
16
  - [Related packages](#related-packages)
15
17
  - [Installation](#installation)
@@ -21,7 +23,24 @@ This project is part of the
21
23
 
22
24
  ## About
23
25
 
24
- Sparse & bitwise adjacency matrices and related functions for directed & undirected graphs
26
+ Sparse & bitwise adjacency matrices, lists and selected traversal algorithms for directed & undirected graphs.
27
+
28
+ ### Graph implementations
29
+
30
+ The following types all implement the [`IGraph`
31
+ interface](https://docs.thi.ng/umbrella/adjacency/interfaces/IGraph.html) and
32
+ support both directed & undirected graphs:
33
+
34
+ - [AdjacencyBitMatrix (bit matrix based)](https://docs.thi.ng/umbrella/adjacency/classes/AdjacencyBitMatrix.html)
35
+ - [AdjacencyMatrix (sparse matrix based)](https://docs.thi.ng/umbrella/adjacency/classes/AdjacencyMatrix.html)
36
+ - [AdjacencyList](https://docs.thi.ng/umbrella/adjacency/classes/AdjacencyList.html)
37
+
38
+ ### Traversals
39
+
40
+ - [Breadth-First Search](https://docs.thi.ng/umbrella/adjacency/functions/bfs.html)
41
+ - [Depth-First Search](https://docs.thi.ng/umbrella/adjacency/functions/dfs.html)
42
+ - [Floyd-Warshall (global shortest paths search)](https://docs.thi.ng/umbrella/adjacency/functions/floydWarshall.html)
43
+ - [Minimum Spanning Tree](https://docs.thi.ng/umbrella/adjacency/functions/mst.html)
25
44
 
26
45
  ## Status
27
46
 
@@ -53,7 +72,7 @@ For Node.js REPL:
53
72
  const adjacency = await import("@thi.ng/adjacency");
54
73
  ```
55
74
 
56
- Package sizes (brotli'd, pre-treeshake): ESM: 2.28 KB
75
+ Package sizes (brotli'd, pre-treeshake): ESM: 2.54 KB
57
76
 
58
77
  ## Dependencies
59
78
 
package/bfs.d.ts CHANGED
@@ -1,10 +1,22 @@
1
1
  import { BitField } from "@thi.ng/bitfield/bitfield";
2
2
  import type { CostFn, IGraph } from "./api.js";
3
+ /**
4
+ * Breadth-First / shortest path search between `src` and `dest` in `graph`,
5
+ * with optional `cost` function. By default all edges have an uniform cost,
6
+ * i.e. the overall path cost is topological distance.
7
+ *
8
+ * @remarks
9
+ * Also see {@link bfs} for ad hoc queries.
10
+ *
11
+ * Reference:
12
+ * - https://en.wikipedia.org/wiki/Breadth-first_search
13
+ * - https://algs4.cs.princeton.edu/40graphs/
14
+ */
3
15
  export declare class BFS {
4
16
  graph: IGraph;
5
17
  marked: BitField;
6
18
  edges: Uint32Array;
7
- dist: Uint32Array;
19
+ dist: Float32Array;
8
20
  constructor(graph: IGraph, src: number, cost?: CostFn);
9
21
  protected search(id: number, cost: CostFn): void;
10
22
  hasPathTo(id: number): boolean;
package/bfs.js CHANGED
@@ -1,11 +1,23 @@
1
1
  import { BitField } from "@thi.ng/bitfield/bitfield";
2
2
  import { DCons } from "@thi.ng/dcons/dcons";
3
+ /**
4
+ * Breadth-First / shortest path search between `src` and `dest` in `graph`,
5
+ * with optional `cost` function. By default all edges have an uniform cost,
6
+ * i.e. the overall path cost is topological distance.
7
+ *
8
+ * @remarks
9
+ * Also see {@link bfs} for ad hoc queries.
10
+ *
11
+ * Reference:
12
+ * - https://en.wikipedia.org/wiki/Breadth-first_search
13
+ * - https://algs4.cs.princeton.edu/40graphs/
14
+ */
3
15
  export class BFS {
4
16
  constructor(graph, src, cost = () => 1) {
5
17
  this.graph = graph;
6
18
  const numV = graph.numVertices();
7
19
  this.edges = new Uint32Array(numV);
8
- this.dist = new Uint32Array(numV);
20
+ this.dist = new Float32Array(numV);
9
21
  this.marked = new BitField(numV);
10
22
  this.search(src, cost);
11
23
  }
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 {@link @thi.ng/bitfield#BitMatrix}
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
- * (default: false), creates symmetrical adjacencies.
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 {@link @thi.ng/bitfield#BitMatrix}
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
- * (default: false), creates symmetrical adjacencies.
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
- * path compression, after Sedgewick & Wayne.
2
+ * Typed array based Disjoint Set implementation with quick union and path
3
+ * compression, after Sedgewick & Wayne.
4
4
  *
5
5
  * @remarks
6
- * - {@link https://en.wikipedia.org/wiki/Disjoint-set_data_structure}
7
- * - {@link https://algs4.cs.princeton.edu/lectures/15UnionFind-2x2.pdf}
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
- * path compression, after Sedgewick & Wayne.
3
+ * Typed array based Disjoint Set implementation with quick union and path
4
+ * compression, after Sedgewick & Wayne.
5
5
  *
6
6
  * @remarks
7
- * - {@link https://en.wikipedia.org/wiki/Disjoint-set_data_structure}
8
- * - {@link https://algs4.cs.princeton.edu/lectures/15UnionFind-2x2.pdf}
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
  /**
@@ -0,0 +1,61 @@
1
+ import type { CostFn, IGraph } from "./api.js";
2
+ /**
3
+ * Implementation of the Floyd-Warshall algorithm for finding _all_ shortest
4
+ * paths in a directed graph, optionally with positive or negative edge weights.
5
+ * A single execution of the algorithm will find the lengths (summed weights) of
6
+ * shortest paths between all pairs of vertices.
7
+ *
8
+ * @remarks
9
+ * The default cost function is topological distance (i.e. every edge has a
10
+ * length/cost of 1).
11
+ *
12
+ * Paths & accumulated distances can be queried via {@link FloydWarshall.path}
13
+ * and {@link FloydWarshall.distance}.
14
+ *
15
+ * This algorithm is quite memory hungry and requires `|V| * |V| * 8 bytes`,
16
+ * i.e. ~8MB for a graph with 1000 nodes. If possible, use {@link BFS} to
17
+ * perform individual shortest-path queries (rather than this global approach).
18
+ *
19
+ * Reference:
20
+ * - https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm
21
+ */
22
+ export declare class FloydWarshall {
23
+ dist: Float32Array;
24
+ next: Int32Array;
25
+ numV: number;
26
+ /**
27
+ * Instantiates and pre-computes all shortest paths in given `graph`. See
28
+ * class comments for details.
29
+ *
30
+ * @param graph
31
+ * @param cost
32
+ */
33
+ constructor(graph: IGraph<number>, cost?: CostFn);
34
+ /**
35
+ * Returns shortest distance between vertices `a` and `b`, or `undefined` if
36
+ * no connecting path exists. Throws an error if either `a` or `b` are out
37
+ * of bounds.
38
+ *
39
+ * @param a
40
+ * @param b
41
+ */
42
+ distance(a: number, b: number): number | undefined;
43
+ /**
44
+ * Returns iterator of vertex IDs of path between `a` and `b` (if any).
45
+ * Throws an error if either `a` or `b` are out of bounds.
46
+ *
47
+ * @param a
48
+ * @param b
49
+ */
50
+ path(a: number, b: number): Generator<number, void, unknown>;
51
+ protected ensureIndex(id: number): void;
52
+ protected ensurePair(a: number, b: number): void;
53
+ }
54
+ /**
55
+ * Factory function for {@link FloydWarshall}.
56
+ *
57
+ * @param graph
58
+ * @param cost
59
+ */
60
+ export declare const floydWarshall: (graph: IGraph<number>, cost?: CostFn) => FloydWarshall;
61
+ //# sourceMappingURL=floyd-warshall.d.ts.map
@@ -0,0 +1,103 @@
1
+ import { outOfBounds } from "@thi.ng/errors/out-of-bounds";
2
+ /**
3
+ * Implementation of the Floyd-Warshall algorithm for finding _all_ shortest
4
+ * paths in a directed graph, optionally with positive or negative edge weights.
5
+ * A single execution of the algorithm will find the lengths (summed weights) of
6
+ * shortest paths between all pairs of vertices.
7
+ *
8
+ * @remarks
9
+ * The default cost function is topological distance (i.e. every edge has a
10
+ * length/cost of 1).
11
+ *
12
+ * Paths & accumulated distances can be queried via {@link FloydWarshall.path}
13
+ * and {@link FloydWarshall.distance}.
14
+ *
15
+ * This algorithm is quite memory hungry and requires `|V| * |V| * 8 bytes`,
16
+ * i.e. ~8MB for a graph with 1000 nodes. If possible, use {@link BFS} to
17
+ * perform individual shortest-path queries (rather than this global approach).
18
+ *
19
+ * Reference:
20
+ * - https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm
21
+ */
22
+ export class FloydWarshall {
23
+ /**
24
+ * Instantiates and pre-computes all shortest paths in given `graph`. See
25
+ * class comments for details.
26
+ *
27
+ * @param graph
28
+ * @param cost
29
+ */
30
+ constructor(graph, cost = () => 1) {
31
+ const numV = (this.numV = graph.numVertices());
32
+ const dist = (this.dist = new Float32Array(numV * numV).fill(Infinity));
33
+ const next = (this.next = new Int32Array(numV * numV).fill(-1));
34
+ for (let [u, v] of graph.edges()) {
35
+ const idx = u * numV + v;
36
+ dist[idx] = cost(u, v);
37
+ next[idx] = v;
38
+ }
39
+ for (let v = 0; v < numV; v++) {
40
+ const idx = v * numV + v;
41
+ dist[idx] = 0;
42
+ next[idx] = v;
43
+ }
44
+ for (let k = 0; k < numV; k++) {
45
+ for (let i = 0; i < numV; i++) {
46
+ const idxIK = i * numV + k;
47
+ for (let j = 0; j < numV; j++) {
48
+ const idxIJ = i * numV + j;
49
+ const idxKJ = k * numV + j;
50
+ const minD = dist[idxIK] + dist[idxKJ];
51
+ if (dist[idxIJ] > minD) {
52
+ dist[idxIJ] = minD;
53
+ next[idxIJ] = next[idxIK];
54
+ }
55
+ }
56
+ }
57
+ }
58
+ }
59
+ /**
60
+ * Returns shortest distance between vertices `a` and `b`, or `undefined` if
61
+ * no connecting path exists. Throws an error if either `a` or `b` are out
62
+ * of bounds.
63
+ *
64
+ * @param a
65
+ * @param b
66
+ */
67
+ distance(a, b) {
68
+ this.ensurePair(a, b);
69
+ return this.dist[a * this.numV + b];
70
+ }
71
+ /**
72
+ * Returns iterator of vertex IDs of path between `a` and `b` (if any).
73
+ * Throws an error if either `a` or `b` are out of bounds.
74
+ *
75
+ * @param a
76
+ * @param b
77
+ */
78
+ *path(a, b) {
79
+ this.ensurePair(a, b);
80
+ const { next, numV } = this;
81
+ if (next[a * numV + b] === -1)
82
+ return;
83
+ yield a;
84
+ while (a !== b) {
85
+ a = next[a * numV + b];
86
+ yield a;
87
+ }
88
+ }
89
+ ensureIndex(id) {
90
+ !(id >= 0 && id < this.numV) && outOfBounds(id);
91
+ }
92
+ ensurePair(a, b) {
93
+ this.ensureIndex(a);
94
+ this.ensureIndex(b);
95
+ }
96
+ }
97
+ /**
98
+ * Factory function for {@link FloydWarshall}.
99
+ *
100
+ * @param graph
101
+ * @param cost
102
+ */
103
+ export const floydWarshall = (graph, cost) => new FloydWarshall(graph, cost);
package/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from "./api.js";
2
2
  export * from "./binary.js";
3
3
  export * from "./disjoint-set.js";
4
+ export * from "./floyd-warshall.js";
4
5
  export * from "./list.js";
5
6
  export * from "./sparse.js";
6
7
  export * from "./bfs.js";
package/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from "./api.js";
2
2
  export * from "./binary.js";
3
3
  export * from "./disjoint-set.js";
4
+ export * from "./floyd-warshall.js";
4
5
  export * from "./list.js";
5
6
  export * from "./sparse.js";
6
7
  export * from "./bfs.js";
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
- * {@link @thi.ng/arrays#sortByCachedKey} for details).
18
+ * [`sortByCachedKey()`](https://docs.thi.ng/umbrella/arrays/functions/sortByCachedKey.html)
19
+ * for details).
19
20
  *
20
- * Reference: {@link https://en.wikipedia.org/wiki/Kruskal%27s_algorithm}
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
- * {@link @thi.ng/arrays#sortByCachedKey} for details).
19
+ * [`sortByCachedKey()`](https://docs.thi.ng/umbrella/arrays/functions/sortByCachedKey.html)
20
+ * for details).
20
21
  *
21
- * Reference: {@link https://en.wikipedia.org/wiki/Kruskal%27s_algorithm}
22
+ * References:
23
+ * - https://en.wikipedia.org/wiki/Kruskal%27s_algorithm
22
24
  *
23
25
  * @example
24
26
  * ```ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@thi.ng/adjacency",
3
- "version": "2.2.19",
4
- "description": "Sparse & bitwise adjacency matrices and related functions for directed & undirected graphs",
3
+ "version": "2.3.0",
4
+ "description": "Sparse & bitwise adjacency matrices, lists and selected traversal algorithms for directed & undirected graphs",
5
5
  "type": "module",
6
6
  "module": "./index.js",
7
7
  "typings": "./index.d.ts",
@@ -34,17 +34,17 @@
34
34
  "test": "testament test"
35
35
  },
36
36
  "dependencies": {
37
- "@thi.ng/api": "^8.6.0",
38
- "@thi.ng/arrays": "^2.4.5",
39
- "@thi.ng/bitfield": "^2.2.15",
40
- "@thi.ng/dcons": "^3.2.26",
41
- "@thi.ng/errors": "^2.2.6",
42
- "@thi.ng/sparse": "^0.3.31"
37
+ "@thi.ng/api": "^8.6.2",
38
+ "@thi.ng/arrays": "^2.4.7",
39
+ "@thi.ng/bitfield": "^2.2.17",
40
+ "@thi.ng/dcons": "^3.2.28",
41
+ "@thi.ng/errors": "^2.2.7",
42
+ "@thi.ng/sparse": "^0.3.33"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@microsoft/api-extractor": "^7.33.7",
46
- "@thi.ng/testament": "^0.3.7",
47
- "@thi.ng/vectors": "^7.5.27",
46
+ "@thi.ng/testament": "^0.3.8",
47
+ "@thi.ng/vectors": "^7.5.29",
48
48
  "rimraf": "^3.0.2",
49
49
  "tools": "^0.0.1",
50
50
  "typedoc": "^0.23.22",
@@ -103,6 +103,9 @@
103
103
  "./disjoint-set": {
104
104
  "default": "./disjoint-set.js"
105
105
  },
106
+ "./floyd-warshall": {
107
+ "default": "./floyd-warshall.js"
108
+ },
106
109
  "./list": {
107
110
  "default": "./list.js"
108
111
  },
@@ -119,5 +122,5 @@
119
122
  ],
120
123
  "year": 2018
121
124
  },
122
- "gitHead": "f445a9cc8022bcdebbf6ff91fd66ced016d72f01\n"
125
+ "gitHead": "bc6f7f5e2765bb96fe64db804eaf4b2443b47fc6\n"
123
126
  }
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 {@link @thi.ng/sparse#CSR} containing
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
- * the degree matrix and `A` this adjacency matrix.
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
- * - {@link https://en.wikipedia.org/wiki/Laplacian_matrix}
32
- * - {@link https://en.wikipedia.org/wiki/Discrete_Laplace_operator}
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 {@link @thi.ng/sparse#CSR}
54
- * matrix, optionally initialize with given edge pairs. Each edge is a `[src,
55
- * dest]` tuple. If `undirected` is true (default: false), creates symmetrical
56
- * edges (i.e. undirected graph).
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 {@link @thi.ng/sparse#CSR} containing
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
- * the degree matrix and `A` this adjacency matrix.
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
- * - {@link https://en.wikipedia.org/wiki/Laplacian_matrix}
101
- * - {@link https://en.wikipedia.org/wiki/Discrete_Laplace_operator}
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 {@link @thi.ng/sparse#CSR}
148
- * matrix, optionally initialize with given edge pairs. Each edge is a `[src,
149
- * dest]` tuple. If `undirected` is true (default: false), creates symmetrical
150
- * edges (i.e. undirected graph).
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