directed-graph-typed 1.47.7 → 1.47.8

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.
Files changed (29) hide show
  1. package/dist/data-structures/binary-tree/segment-tree.d.ts +6 -6
  2. package/dist/data-structures/binary-tree/segment-tree.js +7 -7
  3. package/dist/data-structures/graph/abstract-graph.d.ts +17 -17
  4. package/dist/data-structures/graph/abstract-graph.js +30 -30
  5. package/dist/data-structures/graph/directed-graph.d.ts +24 -24
  6. package/dist/data-structures/graph/directed-graph.js +28 -28
  7. package/dist/data-structures/graph/undirected-graph.d.ts +14 -14
  8. package/dist/data-structures/graph/undirected-graph.js +18 -18
  9. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +28 -28
  10. package/dist/data-structures/linked-list/doubly-linked-list.js +33 -33
  11. package/dist/data-structures/linked-list/singly-linked-list.d.ts +21 -21
  12. package/dist/data-structures/linked-list/singly-linked-list.js +27 -27
  13. package/dist/data-structures/linked-list/skip-linked-list.js +4 -4
  14. package/dist/data-structures/queue/queue.d.ts +13 -13
  15. package/dist/data-structures/queue/queue.js +13 -13
  16. package/dist/data-structures/stack/stack.d.ts +6 -6
  17. package/dist/data-structures/stack/stack.js +7 -7
  18. package/dist/types/data-structures/graph/abstract-graph.d.ts +2 -2
  19. package/package.json +2 -2
  20. package/src/data-structures/binary-tree/segment-tree.ts +10 -10
  21. package/src/data-structures/graph/abstract-graph.ts +46 -46
  22. package/src/data-structures/graph/directed-graph.ts +40 -40
  23. package/src/data-structures/graph/undirected-graph.ts +26 -26
  24. package/src/data-structures/linked-list/doubly-linked-list.ts +45 -45
  25. package/src/data-structures/linked-list/singly-linked-list.ts +38 -38
  26. package/src/data-structures/linked-list/skip-linked-list.ts +4 -4
  27. package/src/data-structures/queue/queue.ts +13 -13
  28. package/src/data-structures/stack/stack.ts +9 -9
  29. package/src/types/data-structures/graph/abstract-graph.ts +2 -2
@@ -9,11 +9,11 @@ import type { SegmentTreeNodeVal } from '../../types';
9
9
  export declare class SegmentTreeNode {
10
10
  start: number;
11
11
  end: number;
12
- value: SegmentTreeNodeVal | null;
12
+ value: SegmentTreeNodeVal | undefined;
13
13
  sum: number;
14
- left: SegmentTreeNode | null;
15
- right: SegmentTreeNode | null;
16
- constructor(start: number, end: number, sum: number, value?: SegmentTreeNodeVal | null);
14
+ left: SegmentTreeNode | undefined;
15
+ right: SegmentTreeNode | undefined;
16
+ constructor(start: number, end: number, sum: number, value?: SegmentTreeNodeVal | undefined);
17
17
  }
18
18
  export declare class SegmentTree {
19
19
  /**
@@ -32,8 +32,8 @@ export declare class SegmentTree {
32
32
  get start(): number;
33
33
  protected _end: number;
34
34
  get end(): number;
35
- protected _root: SegmentTreeNode | null;
36
- get root(): SegmentTreeNode | null;
35
+ protected _root: SegmentTreeNode | undefined;
36
+ get root(): SegmentTreeNode | undefined;
37
37
  /**
38
38
  * The build function creates a segment tree by recursively dividing the given range into smaller segments and assigning
39
39
  * the sum of values to each segment.
@@ -12,14 +12,14 @@ class SegmentTreeNode {
12
12
  constructor(start, end, sum, value) {
13
13
  this.start = 0;
14
14
  this.end = 0;
15
- this.value = null;
15
+ this.value = undefined;
16
16
  this.sum = 0;
17
- this.left = null;
18
- this.right = null;
17
+ this.left = undefined;
18
+ this.right = undefined;
19
19
  this.start = start;
20
20
  this.end = end;
21
21
  this.sum = sum;
22
- this.value = value || null;
22
+ this.value = value || undefined;
23
23
  }
24
24
  }
25
25
  exports.SegmentTreeNode = SegmentTreeNode;
@@ -45,7 +45,7 @@ class SegmentTree {
45
45
  this._root = this.build(start, end);
46
46
  }
47
47
  else {
48
- this._root = null;
48
+ this._root = undefined;
49
49
  this._values = [];
50
50
  }
51
51
  }
@@ -96,7 +96,7 @@ class SegmentTree {
96
96
  * @returns The function does not return anything.
97
97
  */
98
98
  updateNode(index, sum, value) {
99
- const root = this.root || null;
99
+ const root = this.root || undefined;
100
100
  if (!root) {
101
101
  return;
102
102
  }
@@ -132,7 +132,7 @@ class SegmentTree {
132
132
  * @returns The function `querySumByRange` returns a number.
133
133
  */
134
134
  querySumByRange(indexA, indexB) {
135
- const root = this.root || null;
135
+ const root = this.root || undefined;
136
136
  if (!root) {
137
137
  return 0;
138
138
  }
@@ -47,13 +47,13 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
47
47
  * @param value
48
48
  */
49
49
  abstract createEdge(srcOrV1: VertexKey, destOrV2: VertexKey, weight?: number, value?: E): EO;
50
- abstract deleteEdge(edge: EO): EO | null;
51
- abstract getEdge(srcOrKey: VO | VertexKey, destOrKey: VO | VertexKey): EO | null;
50
+ abstract deleteEdge(edge: EO): EO | undefined;
51
+ abstract getEdge(srcOrKey: VO | VertexKey, destOrKey: VO | VertexKey): EO | undefined;
52
52
  abstract degreeOf(vertexOrKey: VO | VertexKey): number;
53
53
  abstract edgeSet(): EO[];
54
54
  abstract edgesOf(vertexOrKey: VO | VertexKey): EO[];
55
55
  abstract getNeighbors(vertexOrKey: VO | VertexKey): VO[];
56
- abstract getEndsOfEdge(edge: EO): [VO, VO] | null;
56
+ abstract getEndsOfEdge(edge: EO): [VO, VO] | undefined;
57
57
  /**
58
58
  * Time Complexity: O(1) - Constant time for Map lookup.
59
59
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
@@ -62,13 +62,13 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
62
62
  * Time Complexity: O(1) - Constant time for Map lookup.
63
63
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
64
64
  *
65
- * The function "getVertex" returns the vertex with the specified ID or null if it doesn't exist.
65
+ * The function "getVertex" returns the vertex with the specified ID or undefined if it doesn't exist.
66
66
  * @param {VertexKey} vertexKey - The `vertexKey` parameter is the identifier of the vertex that you want to retrieve from
67
67
  * the `_vertices` map.
68
68
  * @returns The method `getVertex` returns the vertex with the specified `vertexKey` if it exists in the `_vertices`
69
- * map. If the vertex does not exist, it returns `null`.
69
+ * map. If the vertex does not exist, it returns `undefined`.
70
70
  */
71
- getVertex(vertexKey: VertexKey): VO | null;
71
+ getVertex(vertexKey: VertexKey): VO | undefined;
72
72
  /**
73
73
  * Time Complexity: O(1) - Constant time for Map lookup.
74
74
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
@@ -201,7 +201,7 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
201
201
  * vertices. If `isWeight` is `false` or not provided, it uses a breadth-first search (BFS) algorithm to calculate the
202
202
  * minimum number of
203
203
  */
204
- getMinCostBetween(v1: VO | VertexKey, v2: VO | VertexKey, isWeight?: boolean): number | null;
204
+ getMinCostBetween(v1: VO | VertexKey, v2: VO | VertexKey, isWeight?: boolean): number | undefined;
205
205
  /**
206
206
  * Time Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm or DFS).
207
207
  * Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm or DFS).
@@ -223,9 +223,9 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
223
223
  * followed by iterative computation of the shortest path. This approach may result in exponential time complexity,
224
224
  * so the default method is to use the Dijkstra algorithm to obtain the shortest weighted path.
225
225
  * @returns The function `getMinPathBetween` returns an array of vertices (`VO[]`) representing the minimum path between
226
- * two vertices (`v1` and `v2`). If there is no path between the vertices, it returns `null`.
226
+ * two vertices (`v1` and `v2`). If there is no path between the vertices, it returns `undefined`.
227
227
  */
228
- getMinPathBetween(v1: VO | VertexKey, v2: VO | VertexKey, isWeight?: boolean, isDFS?: boolean): VO[] | null;
228
+ getMinPathBetween(v1: VO | VertexKey, v2: VO | VertexKey, isWeight?: boolean, isDFS?: boolean): VO[] | undefined;
229
229
  /**
230
230
  * Dijkstra algorithm time: O(VE) space: O(VO + EO)
231
231
  * /
@@ -242,9 +242,9 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
242
242
  * a graph without using a heap data structure.
243
243
  * @param {VO | VertexKey} src - The source vertex from which to start the Dijkstra's algorithm. It can be either a
244
244
  * vertex object or a vertex ID.
245
- * @param {VO | VertexKey | null} [dest] - The `dest` parameter in the `dijkstraWithoutHeap` function is an optional
245
+ * @param {VO | VertexKey | undefined} [dest] - The `dest` parameter in the `dijkstraWithoutHeap` function is an optional
246
246
  * parameter that specifies the destination vertex for the Dijkstra algorithm. It can be either a vertex object or its
247
- * identifier. If no destination is provided, the value is set to `null`.
247
+ * identifier. If no destination is provided, the value is set to `undefined`.
248
248
  * @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum
249
249
  * distance from the source vertex to the destination vertex should be calculated and returned in the result. If
250
250
  * `getMinDist` is set to `true`, the `minDist` property in the result will contain the minimum distance
@@ -253,7 +253,7 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
253
253
  * shortest paths from the source vertex to all other vertices in the graph. If `genPaths
254
254
  * @returns The function `dijkstraWithoutHeap` returns an object of type `DijkstraResult<VO>`.
255
255
  */
256
- dijkstraWithoutHeap(src: VO | VertexKey, dest?: VO | VertexKey | null, getMinDist?: boolean, genPaths?: boolean): DijkstraResult<VO>;
256
+ dijkstraWithoutHeap(src: VO | VertexKey, dest?: VO | VertexKey | undefined, getMinDist?: boolean, genPaths?: boolean): DijkstraResult<VO>;
257
257
  /**
258
258
  * Dijkstra algorithm time: O(logVE) space: O(VO + EO)
259
259
  *
@@ -276,7 +276,7 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
276
276
  * optional destination vertex, and optionally returns the minimum distance, the paths, and other information.
277
277
  * @param {VO | VertexKey} src - The `src` parameter represents the source vertex from which the Dijkstra algorithm will
278
278
  * start. It can be either a vertex object or a vertex ID.
279
- * @param {VO | VertexKey | null} [dest] - The `dest` parameter is the destination vertex or vertex ID. It specifies the
279
+ * @param {VO | VertexKey | undefined} [dest] - The `dest` parameter is the destination vertex or vertex ID. It specifies the
280
280
  * vertex to which the shortest path is calculated from the source vertex. If no destination is provided, the algorithm
281
281
  * will calculate the shortest paths to all other vertices from the source vertex.
282
282
  * @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum
@@ -287,7 +287,7 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
287
287
  * shortest paths from the source vertex to all other vertices in the graph. If `genPaths
288
288
  * @returns The function `dijkstra` returns an object of type `DijkstraResult<VO>`.
289
289
  */
290
- dijkstra(src: VO | VertexKey, dest?: VO | VertexKey | null, getMinDist?: boolean, genPaths?: boolean): DijkstraResult<VO>;
290
+ dijkstra(src: VO | VertexKey, dest?: VO | VertexKey | undefined, getMinDist?: boolean, genPaths?: boolean): DijkstraResult<VO>;
291
291
  /**
292
292
  * Time Complexity: O(V * E) - Quadratic time in the worst case (Bellman-Ford algorithm).
293
293
  * Space Complexity: O(V + E) - Depends on the implementation (Bellman-Ford algorithm).
@@ -353,12 +353,12 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
353
353
  * graph.
354
354
  * @returns The function `floydWarshall()` returns an object with two properties: `costs` and `predecessor`. The `costs`
355
355
  * property is a 2D array of numbers representing the shortest path costs between vertices in a graph. The
356
- * `predecessor` property is a 2D array of vertices (or `null`) representing the predecessor vertices in the shortest
356
+ * `predecessor` property is a 2D array of vertices (or `undefined`) representing the predecessor vertices in the shortest
357
357
  * path between vertices in the
358
358
  */
359
359
  floydWarshall(): {
360
360
  costs: number[][];
361
- predecessor: (VO | null)[][];
361
+ predecessor: (VO | undefined)[][];
362
362
  };
363
363
  /**
364
364
  * Time Complexity: O(V + E) - Linear time (Tarjan's algorithm).
@@ -445,6 +445,6 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
445
445
  getBridges(): EO[];
446
446
  protected abstract _addEdgeOnly(edge: EO): boolean;
447
447
  protected _addVertexOnly(newVertex: VO): boolean;
448
- protected _getVertex(vertexOrKey: VertexKey | VO): VO | null;
448
+ protected _getVertex(vertexOrKey: VertexKey | VO): VO | undefined;
449
449
  protected _getVertexKey(vertexOrKey: VO | VertexKey): VertexKey;
450
450
  }
@@ -60,14 +60,14 @@ class AbstractGraph {
60
60
  * Time Complexity: O(1) - Constant time for Map lookup.
61
61
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
62
62
  *
63
- * The function "getVertex" returns the vertex with the specified ID or null if it doesn't exist.
63
+ * The function "getVertex" returns the vertex with the specified ID or undefined if it doesn't exist.
64
64
  * @param {VertexKey} vertexKey - The `vertexKey` parameter is the identifier of the vertex that you want to retrieve from
65
65
  * the `_vertices` map.
66
66
  * @returns The method `getVertex` returns the vertex with the specified `vertexKey` if it exists in the `_vertices`
67
- * map. If the vertex does not exist, it returns `null`.
67
+ * map. If the vertex does not exist, it returns `undefined`.
68
68
  */
69
69
  getVertex(vertexKey) {
70
- return this._vertices.get(vertexKey) || null;
70
+ return this._vertices.get(vertexKey) || undefined;
71
71
  }
72
72
  /**
73
73
  * Time Complexity: O(1) - Constant time for Map lookup.
@@ -305,7 +305,7 @@ class AbstractGraph {
305
305
  const vertex2 = this._getVertex(v2);
306
306
  const vertex1 = this._getVertex(v1);
307
307
  if (!(vertex1 && vertex2)) {
308
- return null;
308
+ return undefined;
309
309
  }
310
310
  const visited = new Map();
311
311
  const queue = new queue_1.Queue([vertex1]);
@@ -330,7 +330,7 @@ class AbstractGraph {
330
330
  }
331
331
  cost++;
332
332
  }
333
- return null;
333
+ return undefined;
334
334
  }
335
335
  }
336
336
  /**
@@ -354,7 +354,7 @@ class AbstractGraph {
354
354
  * followed by iterative computation of the shortest path. This approach may result in exponential time complexity,
355
355
  * so the default method is to use the Dijkstra algorithm to obtain the shortest weighted path.
356
356
  * @returns The function `getMinPathBetween` returns an array of vertices (`VO[]`) representing the minimum path between
357
- * two vertices (`v1` and `v2`). If there is no path between the vertices, it returns `null`.
357
+ * two vertices (`v1` and `v2`). If there is no path between the vertices, it returns `undefined`.
358
358
  */
359
359
  getMinPathBetween(v1, v2, isWeight, isDFS = false) {
360
360
  var _a, _b;
@@ -374,7 +374,7 @@ class AbstractGraph {
374
374
  }
375
375
  index++;
376
376
  }
377
- return allPaths[minIndex] || null;
377
+ return allPaths[minIndex] || undefined;
378
378
  }
379
379
  else {
380
380
  return (_b = (_a = this.dijkstra(v1, v2, true, true)) === null || _a === void 0 ? void 0 : _a.minPath) !== null && _b !== void 0 ? _b : [];
@@ -423,9 +423,9 @@ class AbstractGraph {
423
423
  * a graph without using a heap data structure.
424
424
  * @param {VO | VertexKey} src - The source vertex from which to start the Dijkstra's algorithm. It can be either a
425
425
  * vertex object or a vertex ID.
426
- * @param {VO | VertexKey | null} [dest] - The `dest` parameter in the `dijkstraWithoutHeap` function is an optional
426
+ * @param {VO | VertexKey | undefined} [dest] - The `dest` parameter in the `dijkstraWithoutHeap` function is an optional
427
427
  * parameter that specifies the destination vertex for the Dijkstra algorithm. It can be either a vertex object or its
428
- * identifier. If no destination is provided, the value is set to `null`.
428
+ * identifier. If no destination is provided, the value is set to `undefined`.
429
429
  * @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum
430
430
  * distance from the source vertex to the destination vertex should be calculated and returned in the result. If
431
431
  * `getMinDist` is set to `true`, the `minDist` property in the result will contain the minimum distance
@@ -440,9 +440,9 @@ class AbstractGraph {
440
440
  if (genPaths === undefined)
441
441
  genPaths = false;
442
442
  if (dest === undefined)
443
- dest = null;
443
+ dest = undefined;
444
444
  let minDist = Infinity;
445
- let minDest = null;
445
+ let minDest = undefined;
446
446
  let minPath = [];
447
447
  const paths = [];
448
448
  const vertices = this._vertices;
@@ -450,9 +450,9 @@ class AbstractGraph {
450
450
  const seen = new Set();
451
451
  const preMap = new Map(); // predecessor
452
452
  const srcVertex = this._getVertex(src);
453
- const destVertex = dest ? this._getVertex(dest) : null;
453
+ const destVertex = dest ? this._getVertex(dest) : undefined;
454
454
  if (!srcVertex) {
455
- return null;
455
+ return undefined;
456
456
  }
457
457
  for (const vertex of vertices) {
458
458
  const vertexOrKey = vertex[1];
@@ -460,10 +460,10 @@ class AbstractGraph {
460
460
  distMap.set(vertexOrKey, Infinity);
461
461
  }
462
462
  distMap.set(srcVertex, 0);
463
- preMap.set(srcVertex, null);
463
+ preMap.set(srcVertex, undefined);
464
464
  const getMinOfNoSeen = () => {
465
465
  let min = Infinity;
466
- let minV = null;
466
+ let minV = undefined;
467
467
  for (const [key, value] of distMap) {
468
468
  if (!seen.has(key)) {
469
469
  if (value < min) {
@@ -511,7 +511,7 @@ class AbstractGraph {
511
511
  if (edge) {
512
512
  const curFromMap = distMap.get(cur);
513
513
  const neighborFromMap = distMap.get(neighbor);
514
- // TODO after no-non-null-assertion not ensure the logic
514
+ // TODO after no-non-undefined-assertion not ensure the logic
515
515
  if (curFromMap !== undefined && neighborFromMap !== undefined) {
516
516
  if (edge.weight + curFromMap < neighborFromMap) {
517
517
  distMap.set(neighbor, edge.weight + curFromMap);
@@ -558,7 +558,7 @@ class AbstractGraph {
558
558
  * optional destination vertex, and optionally returns the minimum distance, the paths, and other information.
559
559
  * @param {VO | VertexKey} src - The `src` parameter represents the source vertex from which the Dijkstra algorithm will
560
560
  * start. It can be either a vertex object or a vertex ID.
561
- * @param {VO | VertexKey | null} [dest] - The `dest` parameter is the destination vertex or vertex ID. It specifies the
561
+ * @param {VO | VertexKey | undefined} [dest] - The `dest` parameter is the destination vertex or vertex ID. It specifies the
562
562
  * vertex to which the shortest path is calculated from the source vertex. If no destination is provided, the algorithm
563
563
  * will calculate the shortest paths to all other vertices from the source vertex.
564
564
  * @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum
@@ -576,9 +576,9 @@ class AbstractGraph {
576
576
  if (genPaths === undefined)
577
577
  genPaths = false;
578
578
  if (dest === undefined)
579
- dest = null;
579
+ dest = undefined;
580
580
  let minDist = Infinity;
581
- let minDest = null;
581
+ let minDest = undefined;
582
582
  let minPath = [];
583
583
  const paths = [];
584
584
  const vertices = this._vertices;
@@ -586,9 +586,9 @@ class AbstractGraph {
586
586
  const seen = new Set();
587
587
  const preMap = new Map(); // predecessor
588
588
  const srcVertex = this._getVertex(src);
589
- const destVertex = dest ? this._getVertex(dest) : null;
589
+ const destVertex = dest ? this._getVertex(dest) : undefined;
590
590
  if (!srcVertex)
591
- return null;
591
+ return undefined;
592
592
  for (const vertex of vertices) {
593
593
  const vertexOrKey = vertex[1];
594
594
  if (vertexOrKey instanceof AbstractVertex)
@@ -597,11 +597,11 @@ class AbstractGraph {
597
597
  const heap = new priority_queue_1.PriorityQueue([], { comparator: (a, b) => a.key - b.key });
598
598
  heap.add({ key: 0, value: srcVertex });
599
599
  distMap.set(srcVertex, 0);
600
- preMap.set(srcVertex, null);
600
+ preMap.set(srcVertex, undefined);
601
601
  /**
602
602
  * The function `getPaths` retrieves all paths from vertices to a specified minimum vertex.
603
- * @param {VO | null} minV - The parameter `minV` is of type `VO | null`. It represents the minimum vertex value or
604
- * null.
603
+ * @param {VO | undefined} minV - The parameter `minV` is of type `VO | undefined`. It represents the minimum vertex value or
604
+ * undefined.
605
605
  */
606
606
  const getPaths = (minV) => {
607
607
  for (const vertex of vertices) {
@@ -737,7 +737,7 @@ class AbstractGraph {
737
737
  }
738
738
  }
739
739
  }
740
- let minDest = null;
740
+ let minDest = undefined;
741
741
  if (getMin) {
742
742
  distMap.forEach((d, v) => {
743
743
  if (v !== srcVertex) {
@@ -813,7 +813,7 @@ class AbstractGraph {
813
813
  * graph.
814
814
  * @returns The function `floydWarshall()` returns an object with two properties: `costs` and `predecessor`. The `costs`
815
815
  * property is a 2D array of numbers representing the shortest path costs between vertices in a graph. The
816
- * `predecessor` property is a 2D array of vertices (or `null`) representing the predecessor vertices in the shortest
816
+ * `predecessor` property is a 2D array of vertices (or `undefined`) representing the predecessor vertices in the shortest
817
817
  * path between vertices in the
818
818
  */
819
819
  floydWarshall() {
@@ -827,7 +827,7 @@ class AbstractGraph {
827
827
  costs[i] = [];
828
828
  predecessor[i] = [];
829
829
  for (let j = 0; j < n; j++) {
830
- predecessor[i][j] = null;
830
+ predecessor[i][j] = undefined;
831
831
  }
832
832
  }
833
833
  for (let i = 0; i < n; i++) {
@@ -919,7 +919,7 @@ class AbstractGraph {
919
919
  }
920
920
  const childLow = lowMap.get(neighbor);
921
921
  const curLow = lowMap.get(cur);
922
- // TODO after no-non-null-assertion not ensure the logic
922
+ // TODO after no-non-undefined-assertion not ensure the logic
923
923
  if (curLow !== undefined && childLow !== undefined) {
924
924
  lowMap.set(cur, Math.min(curLow, childLow));
925
925
  }
@@ -943,7 +943,7 @@ class AbstractGraph {
943
943
  }
944
944
  }
945
945
  };
946
- dfs(root, null);
946
+ dfs(root, undefined);
947
947
  let SCCs = new Map();
948
948
  const getSCCs = () => {
949
949
  const SCCs = new Map();
@@ -1038,7 +1038,7 @@ class AbstractGraph {
1038
1038
  }
1039
1039
  _getVertex(vertexOrKey) {
1040
1040
  const vertexKey = this._getVertexKey(vertexOrKey);
1041
- return this._vertices.get(vertexKey) || null;
1041
+ return this._vertices.get(vertexKey) || undefined;
1042
1042
  }
1043
1043
  _getVertexKey(vertexOrKey) {
1044
1044
  return vertexOrKey instanceof AbstractVertex ? vertexOrKey.key : vertexOrKey;
@@ -74,13 +74,13 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
74
74
  * Space Complexity: O(1)
75
75
  *
76
76
  * The `getEdge` function retrieves an edge between two vertices based on their source and destination IDs.
77
- * @param {VO | VertexKey | null} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
78
- * @param {VO | VertexKey | null} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
79
- * destination vertex of the edge. It can be either a vertex object (`VO`), a vertex ID (`VertexKey`), or `null` if the
77
+ * @param {VO | VertexKey | undefined} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
78
+ * @param {VO | VertexKey | undefined} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
79
+ * destination vertex of the edge. It can be either a vertex object (`VO`), a vertex ID (`VertexKey`), or `undefined` if the
80
80
  * destination is not specified.
81
- * @returns the first edge found between the source and destination vertices, or null if no such edge is found.
81
+ * @returns the first edge found between the source and destination vertices, or undefined if no such edge is found.
82
82
  */
83
- getEdge(srcOrKey: VO | VertexKey | null, destOrKey: VO | VertexKey | null): EO | null;
83
+ getEdge(srcOrKey: VO | VertexKey | undefined, destOrKey: VO | VertexKey | undefined): EO | undefined;
84
84
  /**
85
85
  * Time Complexity: O(|E|) where |E| is the number of edges
86
86
  * Space Complexity: O(1)
@@ -92,9 +92,9 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
92
92
  * The function removes an edge between two vertices in a graph and returns the removed edge.
93
93
  * @param {VO | VertexKey} srcOrKey - The source vertex or its ID.
94
94
  * @param {VO | VertexKey} destOrKey - The `destOrKey` parameter represents the destination vertex or its ID.
95
- * @returns the removed edge (EO) if it exists, or null if either the source or destination vertex does not exist.
95
+ * @returns the removed edge (EO) if it exists, or undefined if either the source or destination vertex does not exist.
96
96
  */
97
- deleteEdgeSrcToDest(srcOrKey: VO | VertexKey, destOrKey: VO | VertexKey): EO | null;
97
+ deleteEdgeSrcToDest(srcOrKey: VO | VertexKey, destOrKey: VO | VertexKey): EO | undefined;
98
98
  /**
99
99
  * Time Complexity: O(|E|) where |E| is the number of edges
100
100
  * Space Complexity: O(1)
@@ -103,12 +103,12 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
103
103
  * Time Complexity: O(|E|) where |E| is the number of edges
104
104
  * Space Complexity: O(1)
105
105
  *
106
- * The function removes an edge from a graph and returns the removed edge, or null if the edge was not found.
106
+ * The function removes an edge from a graph and returns the removed edge, or undefined if the edge was not found.
107
107
  * @param {EO} edge - The `edge` parameter is an object that represents an edge in a graph. It has two properties: `src`
108
108
  * and `dest`, which represent the source and destination vertices of the edge, respectively.
109
- * @returns The method `deleteEdge` returns the removed edge (`EO`) if it exists, or `null` if the edge does not exist.
109
+ * @returns The method `deleteEdge` returns the removed edge (`EO`) if it exists, or `undefined` if the edge does not exist.
110
110
  */
111
- deleteEdge(edge: EO): EO | null;
111
+ deleteEdge(edge: EO): EO | undefined;
112
112
  /**
113
113
  * Time Complexity: O(|E|) where |E| is the number of edges
114
114
  * Space Complexity: O(1)
@@ -213,11 +213,11 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
213
213
  * Time Complexity: O(1)
214
214
  * Space Complexity: O(1)
215
215
  *
216
- * The function "getEdgeSrc" returns the source vertex of an edge, or null if the edge does not exist.
216
+ * The function "getEdgeSrc" returns the source vertex of an edge, or undefined if the edge does not exist.
217
217
  * @param {EO} e - The parameter "e" is of type EO, which represents an edge in a graph.
218
- * @returns either a vertex object (VO) or null.
218
+ * @returns either a vertex object (VO) or undefined.
219
219
  */
220
- getEdgeSrc(e: EO): VO | null;
220
+ getEdgeSrc(e: EO): VO | undefined;
221
221
  /**
222
222
  * Time Complexity: O(1)
223
223
  * Space Complexity: O(1)
@@ -228,9 +228,9 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
228
228
  *
229
229
  * The function "getEdgeDest" returns the destination vertex of an edge.
230
230
  * @param {EO} e - The parameter "e" is of type "EO", which represents an edge in a graph.
231
- * @returns either a vertex object of type VO or null.
231
+ * @returns either a vertex object of type VO or undefined.
232
232
  */
233
- getEdgeDest(e: EO): VO | null;
233
+ getEdgeDest(e: EO): VO | undefined;
234
234
  /**
235
235
  * Time Complexity: O(|E|) where |E| is the number of edges
236
236
  * Space Complexity: O(1)
@@ -240,11 +240,11 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
240
240
  * Space Complexity: O(1)
241
241
  *
242
242
  * The function `getDestinations` returns an array of destination vertices connected to a given vertex.
243
- * @param {VO | VertexKey | null} vertex - The `vertex` parameter represents the starting vertex from which we want to
244
- * find the destinations. It can be either a `VO` object, a `VertexKey` value, or `null`.
243
+ * @param {VO | VertexKey | undefined} vertex - The `vertex` parameter represents the starting vertex from which we want to
244
+ * find the destinations. It can be either a `VO` object, a `VertexKey` value, or `undefined`.
245
245
  * @returns an array of vertices (VO[]).
246
246
  */
247
- getDestinations(vertex: VO | VertexKey | null): VO[];
247
+ getDestinations(vertex: VO | VertexKey | undefined): VO[];
248
248
  /**
249
249
  * Time Complexity: O(|V| + |E|) where |V| is the number of vertices and |E| is the number of edges
250
250
  * Space Complexity: O(|V|)
@@ -254,13 +254,13 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
254
254
  * Space Complexity: O(|V|)
255
255
  *
256
256
  * The `topologicalSort` function performs a topological sort on a graph and returns an array of vertices or vertex IDs
257
- * in the sorted order, or null if the graph contains a cycle.
257
+ * in the sorted order, or undefined if the graph contains a cycle.
258
258
  * @param {'vertex' | 'key'} [propertyName] - The `propertyName` parameter is an optional parameter that specifies the
259
259
  * property to use for sorting the vertices. It can have two possible values: 'vertex' or 'key'. If 'vertex' is
260
260
  * specified, the vertices themselves will be used for sorting. If 'key' is specified, the ids of
261
- * @returns an array of vertices or vertex IDs in topological order. If there is a cycle in the graph, it returns null.
261
+ * @returns an array of vertices or vertex IDs in topological order. If there is a cycle in the graph, it returns undefined.
262
262
  */
263
- topologicalSort(propertyName?: 'vertex' | 'key'): Array<VO | VertexKey> | null;
263
+ topologicalSort(propertyName?: 'vertex' | 'key'): Array<VO | VertexKey> | undefined;
264
264
  /**
265
265
  * Time Complexity: O(|E|) where |E| is the number of edges
266
266
  * Space Complexity: O(|E|)
@@ -296,12 +296,12 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
296
296
  * Space Complexity: O(1)
297
297
  *
298
298
  * The function "getEndsOfEdge" returns the source and destination vertices of an edge if it exists in the graph,
299
- * otherwise it returns null.
299
+ * otherwise it returns undefined.
300
300
  * @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph.
301
301
  * @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
302
- * graph. If the edge does not exist, it returns `null`.
302
+ * graph. If the edge does not exist, it returns `undefined`.
303
303
  */
304
- getEndsOfEdge(edge: EO): [VO, VO] | null;
304
+ getEndsOfEdge(edge: EO): [VO, VO] | undefined;
305
305
  /**
306
306
  * Time Complexity: O(1)
307
307
  * Space Complexity: O(1)