data-structure-typed 1.48.3 → 1.48.5

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 (84) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +6 -6
  3. package/dist/cjs/data-structures/base/iterable-base.d.ts +6 -6
  4. package/dist/cjs/data-structures/base/iterable-base.js +3 -3
  5. package/dist/cjs/data-structures/base/iterable-base.js.map +1 -1
  6. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +5 -3
  7. package/dist/cjs/data-structures/binary-tree/avl-tree.js +6 -4
  8. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  9. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +18 -15
  10. package/dist/cjs/data-structures/binary-tree/binary-tree.js +16 -13
  11. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  12. package/dist/cjs/data-structures/binary-tree/bst.d.ts +15 -11
  13. package/dist/cjs/data-structures/binary-tree/bst.js +17 -13
  14. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  15. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +19 -13
  16. package/dist/cjs/data-structures/binary-tree/rb-tree.js +20 -14
  17. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  18. package/dist/cjs/data-structures/binary-tree/tree-multimap.d.ts +21 -14
  19. package/dist/cjs/data-structures/binary-tree/tree-multimap.js +25 -18
  20. package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
  21. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +53 -52
  22. package/dist/cjs/data-structures/graph/abstract-graph.js +82 -78
  23. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  24. package/dist/cjs/data-structures/graph/directed-graph.d.ts +70 -52
  25. package/dist/cjs/data-structures/graph/directed-graph.js +111 -65
  26. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  27. package/dist/cjs/data-structures/graph/map-graph.d.ts +5 -5
  28. package/dist/cjs/data-structures/graph/map-graph.js +8 -8
  29. package/dist/cjs/data-structures/graph/map-graph.js.map +1 -1
  30. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +51 -32
  31. package/dist/cjs/data-structures/graph/undirected-graph.js +117 -54
  32. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  33. package/dist/cjs/data-structures/hash/hash-map.d.ts +8 -8
  34. package/dist/cjs/data-structures/hash/hash-map.js +2 -2
  35. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  36. package/dist/cjs/interfaces/binary-tree.d.ts +1 -1
  37. package/dist/cjs/types/data-structures/base/base.d.ts +3 -3
  38. package/dist/mjs/data-structures/base/iterable-base.d.ts +6 -6
  39. package/dist/mjs/data-structures/base/iterable-base.js +1 -1
  40. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +5 -3
  41. package/dist/mjs/data-structures/binary-tree/avl-tree.js +6 -4
  42. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +18 -15
  43. package/dist/mjs/data-structures/binary-tree/binary-tree.js +17 -14
  44. package/dist/mjs/data-structures/binary-tree/bst.d.ts +15 -11
  45. package/dist/mjs/data-structures/binary-tree/bst.js +17 -13
  46. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +19 -13
  47. package/dist/mjs/data-structures/binary-tree/rb-tree.js +20 -14
  48. package/dist/mjs/data-structures/binary-tree/tree-multimap.d.ts +21 -14
  49. package/dist/mjs/data-structures/binary-tree/tree-multimap.js +25 -18
  50. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +53 -52
  51. package/dist/mjs/data-structures/graph/abstract-graph.js +83 -79
  52. package/dist/mjs/data-structures/graph/directed-graph.d.ts +70 -52
  53. package/dist/mjs/data-structures/graph/directed-graph.js +111 -65
  54. package/dist/mjs/data-structures/graph/map-graph.d.ts +5 -5
  55. package/dist/mjs/data-structures/graph/map-graph.js +8 -8
  56. package/dist/mjs/data-structures/graph/undirected-graph.d.ts +51 -32
  57. package/dist/mjs/data-structures/graph/undirected-graph.js +119 -56
  58. package/dist/mjs/data-structures/hash/hash-map.d.ts +8 -8
  59. package/dist/mjs/data-structures/hash/hash-map.js +3 -3
  60. package/dist/mjs/interfaces/binary-tree.d.ts +1 -1
  61. package/dist/mjs/types/data-structures/base/base.d.ts +3 -3
  62. package/dist/umd/data-structure-typed.js +413 -285
  63. package/dist/umd/data-structure-typed.min.js +2 -2
  64. package/dist/umd/data-structure-typed.min.js.map +1 -1
  65. package/package.json +1 -1
  66. package/src/data-structures/base/iterable-base.ts +6 -6
  67. package/src/data-structures/binary-tree/avl-tree.ts +8 -5
  68. package/src/data-structures/binary-tree/binary-tree.ts +23 -19
  69. package/src/data-structures/binary-tree/bst.ts +19 -14
  70. package/src/data-structures/binary-tree/rb-tree.ts +20 -14
  71. package/src/data-structures/binary-tree/tree-multimap.ts +27 -19
  72. package/src/data-structures/graph/abstract-graph.ts +87 -82
  73. package/src/data-structures/graph/directed-graph.ts +114 -65
  74. package/src/data-structures/graph/map-graph.ts +8 -8
  75. package/src/data-structures/graph/undirected-graph.ts +124 -56
  76. package/src/data-structures/hash/hash-map.ts +8 -8
  77. package/src/interfaces/binary-tree.ts +1 -1
  78. package/src/types/data-structures/base/base.ts +3 -3
  79. package/test/integration/bst.test.ts +1 -1
  80. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +1 -1
  81. package/test/unit/data-structures/binary-tree/tree-multimap.test.ts +3 -3
  82. package/test/unit/data-structures/graph/directed-graph.test.ts +52 -15
  83. package/test/unit/data-structures/graph/map-graph.test.ts +3 -3
  84. package/test/unit/data-structures/graph/undirected-graph.test.ts +42 -5
@@ -128,7 +128,7 @@ var dataStructureTyped = (() => {
128
128
  HashTableNode: () => HashTableNode,
129
129
  Heap: () => Heap,
130
130
  IterableElementBase: () => IterableElementBase,
131
- IterablePairBase: () => IterablePairBase,
131
+ IterableEntryBase: () => IterableEntryBase,
132
132
  IterationType: () => IterationType,
133
133
  LinkedHashMap: () => LinkedHashMap,
134
134
  LinkedListQueue: () => LinkedListQueue,
@@ -520,7 +520,7 @@ var dataStructureTyped = (() => {
520
520
  var calcMinUnitsRequired = (totalQuantity, unitSize) => Math.floor((totalQuantity + unitSize - 1) / unitSize);
521
521
 
522
522
  // src/data-structures/base/iterable-base.ts
523
- var IterablePairBase = class {
523
+ var IterableEntryBase = class {
524
524
  /**
525
525
  * Time Complexity: O(n)
526
526
  * Space Complexity: O(1)
@@ -829,7 +829,7 @@ var dataStructureTyped = (() => {
829
829
  };
830
830
 
831
831
  // src/data-structures/hash/hash-map.ts
832
- var HashMap = class _HashMap extends IterablePairBase {
832
+ var HashMap = class _HashMap extends IterableEntryBase {
833
833
  /**
834
834
  * The constructor function initializes a new instance of a class with optional elements and options.
835
835
  * @param elements - The `elements` parameter is an iterable containing key-value pairs `[K, V]`. It
@@ -1041,7 +1041,7 @@ var dataStructureTyped = (() => {
1041
1041
  return strKey;
1042
1042
  }
1043
1043
  };
1044
- var LinkedHashMap = class _LinkedHashMap extends IterablePairBase {
1044
+ var LinkedHashMap = class _LinkedHashMap extends IterableEntryBase {
1045
1045
  constructor(elements, options = {
1046
1046
  hashFn: (key) => String(key),
1047
1047
  objHashFn: (key) => key
@@ -5420,13 +5420,13 @@ var dataStructureTyped = (() => {
5420
5420
  * This means that using abstract methods in the parent class cannot constrain the grandchild classes. Defining methods within an interface also cannot constrain the descendant classes. When inheriting from this class, developers need to be aware that this method needs to be overridden.
5421
5421
  */
5422
5422
  };
5423
- var AbstractGraph = class extends IterablePairBase {
5423
+ var AbstractGraph = class extends IterableEntryBase {
5424
5424
  constructor() {
5425
5425
  super();
5426
- __publicField(this, "_vertices", /* @__PURE__ */ new Map());
5426
+ __publicField(this, "_vertexMap", /* @__PURE__ */ new Map());
5427
5427
  }
5428
- get vertices() {
5429
- return this._vertices;
5428
+ get vertexMap() {
5429
+ return this._vertexMap;
5430
5430
  }
5431
5431
  /**
5432
5432
  * Time Complexity: O(1) - Constant time for Map lookup.
@@ -5438,12 +5438,12 @@ var dataStructureTyped = (() => {
5438
5438
  *
5439
5439
  * The function "getVertex" returns the vertex with the specified ID or undefined if it doesn't exist.
5440
5440
  * @param {VertexKey} vertexKey - The `vertexKey` parameter is the identifier of the vertex that you want to retrieve from
5441
- * the `_vertices` map.
5442
- * @returns The method `getVertex` returns the vertex with the specified `vertexKey` if it exists in the `_vertices`
5441
+ * the `_vertexMap` map.
5442
+ * @returns The method `getVertex` returns the vertex with the specified `vertexKey` if it exists in the `_vertexMap`
5443
5443
  * map. If the vertex does not exist, it returns `undefined`.
5444
5444
  */
5445
5445
  getVertex(vertexKey) {
5446
- return this._vertices.get(vertexKey) || void 0;
5446
+ return this._vertexMap.get(vertexKey) || void 0;
5447
5447
  }
5448
5448
  /**
5449
5449
  * Time Complexity: O(1) - Constant time for Map lookup.
@@ -5459,7 +5459,7 @@ var dataStructureTyped = (() => {
5459
5459
  * @returns a boolean value.
5460
5460
  */
5461
5461
  hasVertex(vertexOrKey) {
5462
- return this._vertices.has(this._getVertexKey(vertexOrKey));
5462
+ return this._vertexMap.has(this._getVertexKey(vertexOrKey));
5463
5463
  }
5464
5464
  /**
5465
5465
  * Time Complexity: O(1) - Constant time for Map operations.
@@ -5473,6 +5473,10 @@ var dataStructureTyped = (() => {
5473
5473
  return this._addVertexOnly(newVertex);
5474
5474
  }
5475
5475
  }
5476
+ isVertexKey(potentialKey) {
5477
+ const potentialKeyType = typeof potentialKey;
5478
+ return potentialKeyType === "string" || potentialKeyType === "number";
5479
+ }
5476
5480
  /**
5477
5481
  * Time Complexity: O(1) - Constant time for Map operations.
5478
5482
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
@@ -5488,25 +5492,25 @@ var dataStructureTyped = (() => {
5488
5492
  */
5489
5493
  deleteVertex(vertexOrKey) {
5490
5494
  const vertexKey = this._getVertexKey(vertexOrKey);
5491
- return this._vertices.delete(vertexKey);
5495
+ return this._vertexMap.delete(vertexKey);
5492
5496
  }
5493
5497
  /**
5494
- * Time Complexity: O(K), where K is the number of vertices to be removed.
5498
+ * Time Complexity: O(K), where K is the number of vertexMap to be removed.
5495
5499
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
5496
5500
  */
5497
5501
  /**
5498
- * Time Complexity: O(K), where K is the number of vertices to be removed.
5502
+ * Time Complexity: O(K), where K is the number of vertexMap to be removed.
5499
5503
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
5500
5504
  *
5501
- * The function removes all vertices from a graph and returns a boolean indicating if any vertices were removed.
5502
- * @param {VO[] | VertexKey[]} vertices - The `vertices` parameter can be either an array of vertices (`VO[]`) or an array
5505
+ * The function removes all vertexMap from a graph and returns a boolean indicating if any vertexMap were removed.
5506
+ * @param {VO[] | VertexKey[]} vertexMap - The `vertexMap` parameter can be either an array of vertexMap (`VO[]`) or an array
5503
5507
  * of vertex IDs (`VertexKey[]`).
5504
- * @returns a boolean value. It returns true if at least one vertex was successfully removed, and false if no vertices
5508
+ * @returns a boolean value. It returns true if at least one vertex was successfully removed, and false if no vertexMap
5505
5509
  * were removed.
5506
5510
  */
5507
- removeManyVertices(vertices) {
5511
+ removeManyVertices(vertexMap) {
5508
5512
  const removed = [];
5509
- for (const v of vertices) {
5513
+ for (const v of vertexMap) {
5510
5514
  removed.push(this.deleteVertex(v));
5511
5515
  }
5512
5516
  return removed.length > 0;
@@ -5519,7 +5523,7 @@ var dataStructureTyped = (() => {
5519
5523
  * Time Complexity: O(1) - Depends on the implementation in the concrete class.
5520
5524
  * Space Complexity: O(1) - Depends on the implementation in the concrete class.
5521
5525
  *
5522
- * The function checks if there is an edge between two vertices and returns a boolean value indicating the result.
5526
+ * The function checks if there is an edge between two vertexMap and returns a boolean value indicating the result.
5523
5527
  * @param {VertexKey | VO} v1 - The parameter v1 can be either a VertexKey or a VO. A VertexKey represents the unique
5524
5528
  * identifier of a vertex in a graph, while VO represents the type of the vertex object itself.
5525
5529
  * @param {VertexKey | VO} v2 - The parameter `v2` represents the second vertex in the edge. It can be either a
@@ -5560,14 +5564,14 @@ var dataStructureTyped = (() => {
5560
5564
  * Time Complexity: O(1) - Constant time for Map and Edge operations.
5561
5565
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
5562
5566
  *
5563
- * The function sets the weight of an edge between two vertices in a graph.
5567
+ * The function sets the weight of an edge between two vertexMap in a graph.
5564
5568
  * @param {VertexKey | VO} srcOrKey - The `srcOrKey` parameter can be either a `VertexKey` or a `VO` object. It represents
5565
5569
  * the source vertex of the edge.
5566
5570
  * @param {VertexKey | VO} destOrKey - The `destOrKey` parameter represents the destination vertex of the edge. It can be
5567
5571
  * either a `VertexKey` or a vertex object `VO`.
5568
5572
  * @param {number} weight - The weight parameter represents the weight of the edge between the source vertex (srcOrKey)
5569
5573
  * and the destination vertex (destOrKey).
5570
- * @returns a boolean value. If the edge exists between the source and destination vertices, the function will update
5574
+ * @returns a boolean value. If the edge exists between the source and destination vertexMap, the function will update
5571
5575
  * the weight of the edge and return true. If the edge does not exist, the function will return false.
5572
5576
  */
5573
5577
  setEdgeWeight(srcOrKey, destOrKey, weight) {
@@ -5587,12 +5591,12 @@ var dataStructureTyped = (() => {
5587
5591
  * Time Complexity: O(P), where P is the number of paths found (in the worst case, exploring all paths).
5588
5592
  * Space Complexity: O(P) - Linear space, where P is the number of paths found.
5589
5593
  *
5590
- * The function `getAllPathsBetween` finds all paths between two vertices in a graph using depth-first search.
5594
+ * The function `getAllPathsBetween` finds all paths between two vertexMap in a graph using depth-first search.
5591
5595
  * @param {VO | VertexKey} v1 - The parameter `v1` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).
5592
5596
  * It is the starting vertex for finding paths.
5593
5597
  * @param {VO | VertexKey} v2 - The parameter `v2` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).
5594
5598
  * @param limit - The count of limitation of result array.
5595
- * @returns The function `getAllPathsBetween` returns an array of arrays of vertices (`VO[][]`).
5599
+ * @returns The function `getAllPathsBetween` returns an array of arrays of vertexMap (`VO[][]`).
5596
5600
  */
5597
5601
  getAllPathsBetween(v1, v2, limit = 1e3) {
5598
5602
  const paths = [];
@@ -5629,8 +5633,8 @@ var dataStructureTyped = (() => {
5629
5633
  * Space Complexity: O(1) - Constant space.
5630
5634
  *
5631
5635
  * The function calculates the sum of weights along a given path.
5632
- * @param {VO[]} path - An array of vertices (VO) representing a path in a graph.
5633
- * @returns The function `getPathSumWeight` returns the sum of the weights of the edges in the given path.
5636
+ * @param {VO[]} path - An array of vertexMap (VO) representing a path in a graph.
5637
+ * @returns The function `getPathSumWeight` returns the sum of the weights of the edgeMap in the given path.
5634
5638
  */
5635
5639
  getPathSumWeight(path) {
5636
5640
  var _a;
@@ -5648,17 +5652,17 @@ var dataStructureTyped = (() => {
5648
5652
  * Time Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
5649
5653
  * Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
5650
5654
  *
5651
- * The function `getMinCostBetween` calculates the minimum cost between two vertices in a graph, either based on edge
5655
+ * The function `getMinCostBetween` calculates the minimum cost between two vertexMap in a graph, either based on edge
5652
5656
  * weights or using a breadth-first search algorithm.
5653
5657
  * @param {VO | VertexKey} v1 - The parameter `v1` represents the starting vertex or its ID.
5654
5658
  * @param {VO | VertexKey} v2 - The parameter `v2` represents the destination vertex or its ID. It is the vertex to which
5655
5659
  * you want to find the minimum cost or weight from the source vertex `v1`.
5656
- * @param {boolean} [isWeight] - isWeight is an optional parameter that indicates whether the graph edges have weights.
5660
+ * @param {boolean} [isWeight] - isWeight is an optional parameter that indicates whether the graph edgeMap have weights.
5657
5661
  * If isWeight is set to true, the function will calculate the minimum cost between v1 and v2 based on the weights of
5658
- * the edges. If isWeight is set to false or not provided, the function will calculate the
5659
- * @returns The function `getMinCostBetween` returns a number representing the minimum cost between two vertices (`v1`
5662
+ * the edgeMap. If isWeight is set to false or not provided, the function will calculate the
5663
+ * @returns The function `getMinCostBetween` returns a number representing the minimum cost between two vertexMap (`v1`
5660
5664
  * and `v2`). If the `isWeight` parameter is `true`, it calculates the minimum weight among all paths between the
5661
- * vertices. If `isWeight` is `false` or not provided, it uses a breadth-first search (BFS) algorithm to calculate the
5665
+ * vertexMap. If `isWeight` is `false` or not provided, it uses a breadth-first search (BFS) algorithm to calculate the
5662
5666
  * minimum number of
5663
5667
  */
5664
5668
  getMinCostBetween(v1, v2, isWeight) {
@@ -5710,20 +5714,20 @@ var dataStructureTyped = (() => {
5710
5714
  * Time Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm or DFS).
5711
5715
  * Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm or DFS).
5712
5716
  *
5713
- * The function `getMinPathBetween` returns the minimum path between two vertices in a graph, either based on weight or
5717
+ * The function `getMinPathBetween` returns the minimum path between two vertexMap in a graph, either based on weight or
5714
5718
  * using a breadth-first search algorithm.
5715
5719
  * @param {VO | VertexKey} v1 - The parameter `v1` represents the starting vertex of the path. It can be either a vertex
5716
5720
  * object (`VO`) or a vertex ID (`VertexKey`).
5717
5721
  * @param {VO | VertexKey} v2 - VO | VertexKey - The second vertex or vertex ID between which we want to find the minimum
5718
5722
  * path.
5719
- * @param {boolean} [isWeight] - A boolean flag indicating whether to consider the weight of edges in finding the
5723
+ * @param {boolean} [isWeight] - A boolean flag indicating whether to consider the weight of edgeMap in finding the
5720
5724
  * minimum path. If set to true, the function will use Dijkstra's algorithm to find the minimum weighted path. If set
5721
5725
  * to false, the function will use breadth-first search (BFS) to find the minimum path.
5722
5726
  * @param isDFS - If set to true, it enforces the use of getAllPathsBetween to first obtain all possible paths,
5723
5727
  * followed by iterative computation of the shortest path. This approach may result in exponential time complexity,
5724
5728
  * so the default method is to use the Dijkstra algorithm to obtain the shortest weighted path.
5725
- * @returns The function `getMinPathBetween` returns an array of vertices (`VO[]`) representing the minimum path between
5726
- * two vertices (`v1` and `v2`). If there is no path between the vertices, it returns `undefined`.
5729
+ * @returns The function `getMinPathBetween` returns an array of vertexMap (`VO[]`) representing the minimum path between
5730
+ * two vertexMap (`v1` and `v2`). If there is no path between the vertexMap, it returns `undefined`.
5727
5731
  */
5728
5732
  getMinPathBetween(v1, v2, isWeight, isDFS = false) {
5729
5733
  var _a, _b;
@@ -5785,7 +5789,7 @@ var dataStructureTyped = (() => {
5785
5789
  * Time Complexity: O(V^2 + E) - Quadratic time in the worst case (no heap optimization).
5786
5790
  * Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
5787
5791
  *
5788
- * The function `dijkstraWithoutHeap` implements Dijkstra's algorithm to find the shortest path between two vertices in
5792
+ * The function `dijkstraWithoutHeap` implements Dijkstra's algorithm to find the shortest path between two vertexMap in
5789
5793
  * a graph without using a heap data structure.
5790
5794
  * @param {VO | VertexKey} src - The source vertex from which to start the Dijkstra's algorithm. It can be either a
5791
5795
  * vertex object or a vertex ID.
@@ -5797,7 +5801,7 @@ var dataStructureTyped = (() => {
5797
5801
  * `getMinDist` is set to `true`, the `minDist` property in the result will contain the minimum distance
5798
5802
  * @param {boolean} [genPaths] - The `genPaths` parameter is a boolean flag that determines whether or not to generate
5799
5803
  * paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
5800
- * shortest paths from the source vertex to all other vertices in the graph. If `genPaths
5804
+ * shortest paths from the source vertex to all other vertexMap in the graph. If `genPaths
5801
5805
  * @returns The function `dijkstraWithoutHeap` returns an object of type `DijkstraResult<VO>`.
5802
5806
  */
5803
5807
  dijkstraWithoutHeap(src, dest, getMinDist, genPaths) {
@@ -5811,7 +5815,7 @@ var dataStructureTyped = (() => {
5811
5815
  let minDest = void 0;
5812
5816
  let minPath = [];
5813
5817
  const paths = [];
5814
- const vertices = this._vertices;
5818
+ const vertexMap = this._vertexMap;
5815
5819
  const distMap = /* @__PURE__ */ new Map();
5816
5820
  const seen = /* @__PURE__ */ new Set();
5817
5821
  const preMap = /* @__PURE__ */ new Map();
@@ -5820,7 +5824,7 @@ var dataStructureTyped = (() => {
5820
5824
  if (!srcVertex) {
5821
5825
  return void 0;
5822
5826
  }
5823
- for (const vertex of vertices) {
5827
+ for (const vertex of vertexMap) {
5824
5828
  const vertexOrKey = vertex[1];
5825
5829
  if (vertexOrKey instanceof AbstractVertex)
5826
5830
  distMap.set(vertexOrKey, Infinity);
@@ -5841,7 +5845,7 @@ var dataStructureTyped = (() => {
5841
5845
  return minV;
5842
5846
  };
5843
5847
  const getPaths = (minV) => {
5844
- for (const vertex of vertices) {
5848
+ for (const vertex of vertexMap) {
5845
5849
  const vertexOrKey = vertex[1];
5846
5850
  if (vertexOrKey instanceof AbstractVertex) {
5847
5851
  const path = [vertexOrKey];
@@ -5857,7 +5861,7 @@ var dataStructureTyped = (() => {
5857
5861
  }
5858
5862
  }
5859
5863
  };
5860
- for (let i = 1; i < vertices.size; i++) {
5864
+ for (let i = 1; i < vertexMap.size; i++) {
5861
5865
  const cur = getMinOfNoSeen();
5862
5866
  if (cur) {
5863
5867
  seen.add(cur);
@@ -5904,7 +5908,7 @@ var dataStructureTyped = (() => {
5904
5908
  * Dijkstra algorithm time: O(logVE) space: O(VO + EO)
5905
5909
  *
5906
5910
  * Dijkstra's algorithm only solves the single-source shortest path problem, while the Bellman-Ford algorithm and Floyd-Warshall algorithm can address shortest paths between all pairs of nodes.
5907
- * Dijkstra's algorithm is suitable for graphs with non-negative edge weights, whereas the Bellman-Ford algorithm and Floyd-Warshall algorithm can handle negative-weight edges.
5911
+ * Dijkstra's algorithm is suitable for graphs with non-negative edge weights, whereas the Bellman-Ford algorithm and Floyd-Warshall algorithm can handle negative-weight edgeMap.
5908
5912
  * The time complexity of Dijkstra's algorithm and the Bellman-Ford algorithm depends on the size of the graph, while the time complexity of the Floyd-Warshall algorithm is O(VO^3), where VO is the number of nodes. For dense graphs, Floyd-Warshall might become slower.
5909
5913
  *
5910
5914
  * /
@@ -5924,13 +5928,13 @@ var dataStructureTyped = (() => {
5924
5928
  * start. It can be either a vertex object or a vertex ID.
5925
5929
  * @param {VO | VertexKey | undefined} [dest] - The `dest` parameter is the destination vertex or vertex ID. It specifies the
5926
5930
  * vertex to which the shortest path is calculated from the source vertex. If no destination is provided, the algorithm
5927
- * will calculate the shortest paths to all other vertices from the source vertex.
5931
+ * will calculate the shortest paths to all other vertexMap from the source vertex.
5928
5932
  * @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum
5929
5933
  * distance from the source vertex to the destination vertex should be calculated and returned in the result. If
5930
5934
  * `getMinDist` is set to `true`, the `minDist` property in the result will contain the minimum distance
5931
5935
  * @param {boolean} [genPaths] - The `genPaths` parameter is a boolean flag that determines whether or not to generate
5932
5936
  * paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
5933
- * shortest paths from the source vertex to all other vertices in the graph. If `genPaths
5937
+ * shortest paths from the source vertex to all other vertexMap in the graph. If `genPaths
5934
5938
  * @returns The function `dijkstra` returns an object of type `DijkstraResult<VO>`.
5935
5939
  */
5936
5940
  dijkstra(src, dest, getMinDist, genPaths) {
@@ -5945,7 +5949,7 @@ var dataStructureTyped = (() => {
5945
5949
  let minDest = void 0;
5946
5950
  let minPath = [];
5947
5951
  const paths = [];
5948
- const vertices = this._vertices;
5952
+ const vertexMap = this._vertexMap;
5949
5953
  const distMap = /* @__PURE__ */ new Map();
5950
5954
  const seen = /* @__PURE__ */ new Set();
5951
5955
  const preMap = /* @__PURE__ */ new Map();
@@ -5953,7 +5957,7 @@ var dataStructureTyped = (() => {
5953
5957
  const destVertex = dest ? this._getVertex(dest) : void 0;
5954
5958
  if (!srcVertex)
5955
5959
  return void 0;
5956
- for (const vertex of vertices) {
5960
+ for (const vertex of vertexMap) {
5957
5961
  const vertexOrKey = vertex[1];
5958
5962
  if (vertexOrKey instanceof AbstractVertex)
5959
5963
  distMap.set(vertexOrKey, Infinity);
@@ -5963,7 +5967,7 @@ var dataStructureTyped = (() => {
5963
5967
  distMap.set(srcVertex, 0);
5964
5968
  preMap.set(srcVertex, void 0);
5965
5969
  const getPaths = (minV) => {
5966
- for (const vertex of vertices) {
5970
+ for (const vertex of vertexMap) {
5967
5971
  const vertexOrKey = vertex[1];
5968
5972
  if (vertexOrKey instanceof AbstractVertex) {
5969
5973
  const path = [vertexOrKey];
@@ -6041,16 +6045,16 @@ var dataStructureTyped = (() => {
6041
6045
  * Space Complexity: O(V + E) - Depends on the implementation (Bellman-Ford algorithm).
6042
6046
  *
6043
6047
  * one to rest pairs
6044
- * The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edges for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edges, the Bellman-Ford algorithm is more flexible in some scenarios.
6048
+ * The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edgeMap for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edgeMap, the Bellman-Ford algorithm is more flexible in some scenarios.
6045
6049
  * The `bellmanFord` function implements the Bellman-Ford algorithm to find the shortest path from a source vertex to
6046
- * all other vertices in a graph, and optionally detects negative cycles and generates the minimum path.
6050
+ * all other vertexMap in a graph, and optionally detects negative cycles and generates the minimum path.
6047
6051
  * @param {VO | VertexKey} src - The `src` parameter is the source vertex from which the Bellman-Ford algorithm will
6048
6052
  * start calculating the shortest paths. It can be either a vertex object or a vertex ID.
6049
6053
  * @param {boolean} [scanNegativeCycle] - A boolean flag indicating whether to scan for negative cycles in the graph.
6050
6054
  * @param {boolean} [getMin] - The `getMin` parameter is a boolean flag that determines whether the algorithm should
6051
- * calculate the minimum distance from the source vertex to all other vertices in the graph. If `getMin` is set to
6055
+ * calculate the minimum distance from the source vertex to all other vertexMap in the graph. If `getMin` is set to
6052
6056
  * `true`, the algorithm will find the minimum distance and update the `min` variable with the minimum
6053
- * @param {boolean} [genPath] - A boolean flag indicating whether to generate paths for all vertices from the source
6057
+ * @param {boolean} [genPath] - A boolean flag indicating whether to generate paths for all vertexMap from the source
6054
6058
  * vertex.
6055
6059
  * @returns The function `bellmanFord` returns an object with the following properties:
6056
6060
  */
@@ -6070,20 +6074,20 @@ var dataStructureTyped = (() => {
6070
6074
  hasNegativeCycle = false;
6071
6075
  if (!srcVertex)
6072
6076
  return { hasNegativeCycle, distMap, preMap, paths, min, minPath };
6073
- const vertices = this._vertices;
6074
- const numOfVertices = vertices.size;
6075
- const edges = this.edgeSet();
6076
- const numOfEdges = edges.length;
6077
- this._vertices.forEach((vertex) => {
6077
+ const vertexMap = this._vertexMap;
6078
+ const numOfVertices = vertexMap.size;
6079
+ const edgeMap = this.edgeSet();
6080
+ const numOfEdges = edgeMap.length;
6081
+ this._vertexMap.forEach((vertex) => {
6078
6082
  distMap.set(vertex, Infinity);
6079
6083
  });
6080
6084
  distMap.set(srcVertex, 0);
6081
6085
  for (let i = 1; i < numOfVertices; ++i) {
6082
6086
  for (let j = 0; j < numOfEdges; ++j) {
6083
- const ends = this.getEndsOfEdge(edges[j]);
6087
+ const ends = this.getEndsOfEdge(edgeMap[j]);
6084
6088
  if (ends) {
6085
6089
  const [s, d] = ends;
6086
- const weight = edges[j].weight;
6090
+ const weight = edgeMap[j].weight;
6087
6091
  const sWeight = distMap.get(s);
6088
6092
  const dWeight = distMap.get(d);
6089
6093
  if (sWeight !== void 0 && dWeight !== void 0) {
@@ -6108,7 +6112,7 @@ var dataStructureTyped = (() => {
6108
6112
  });
6109
6113
  }
6110
6114
  if (genPath) {
6111
- for (const vertex of vertices) {
6115
+ for (const vertex of vertexMap) {
6112
6116
  const vertexOrKey = vertex[1];
6113
6117
  if (vertexOrKey instanceof AbstractVertex) {
6114
6118
  const path = [vertexOrKey];
@@ -6125,10 +6129,10 @@ var dataStructureTyped = (() => {
6125
6129
  }
6126
6130
  }
6127
6131
  for (let j = 0; j < numOfEdges; ++j) {
6128
- const ends = this.getEndsOfEdge(edges[j]);
6132
+ const ends = this.getEndsOfEdge(edgeMap[j]);
6129
6133
  if (ends) {
6130
6134
  const [s] = ends;
6131
- const weight = edges[j].weight;
6135
+ const weight = edgeMap[j].weight;
6132
6136
  const sWeight = distMap.get(s);
6133
6137
  if (sWeight) {
6134
6138
  if (sWeight !== Infinity && sWeight + weight < sWeight)
@@ -6149,7 +6153,7 @@ var dataStructureTyped = (() => {
6149
6153
  /**
6150
6154
  * BellmanFord time:O(VE) space:O(VO)
6151
6155
  * one to rest pairs
6152
- * The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edges for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edges, the Bellman-Ford algorithm is more flexible in some scenarios.
6156
+ * The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edgeMap for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edgeMap, the Bellman-Ford algorithm is more flexible in some scenarios.
6153
6157
  * The `bellmanFord` function implements the Bellman-Ford algorithm to find the shortest path from a source vertex to
6154
6158
  */
6155
6159
  /**
@@ -6157,7 +6161,7 @@ var dataStructureTyped = (() => {
6157
6161
  * Space Complexity: O(V^2) - Quadratic space (Floyd-Warshall algorithm).
6158
6162
  * Not support graph with negative weight cycle
6159
6163
  * all pairs
6160
- * The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edges, and it can simultaneously compute shortest paths between any two nodes.
6164
+ * The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edgeMap, and it can simultaneously compute shortest paths between any two nodes.
6161
6165
  * /
6162
6166
 
6163
6167
  /**
@@ -6166,17 +6170,17 @@ var dataStructureTyped = (() => {
6166
6170
  *
6167
6171
  * Not support graph with negative weight cycle
6168
6172
  * all pairs
6169
- * The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edges, and it can simultaneously compute shortest paths between any two nodes.
6170
- * The function implements the Floyd-Warshall algorithm to find the shortest path between all pairs of vertices in a
6173
+ * The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edgeMap, and it can simultaneously compute shortest paths between any two nodes.
6174
+ * The function implements the Floyd-Warshall algorithm to find the shortest path between all pairs of vertexMap in a
6171
6175
  * graph.
6172
6176
  * @returns The function `floydWarshall()` returns an object with two properties: `costs` and `predecessor`. The `costs`
6173
- * property is a 2D array of numbers representing the shortest path costs between vertices in a graph. The
6174
- * `predecessor` property is a 2D array of vertices (or `undefined`) representing the predecessor vertices in the shortest
6175
- * path between vertices in the
6177
+ * property is a 2D array of numbers representing the shortest path costs between vertexMap in a graph. The
6178
+ * `predecessor` property is a 2D array of vertexMap (or `undefined`) representing the predecessor vertexMap in the shortest
6179
+ * path between vertexMap in the
6176
6180
  */
6177
6181
  floydWarshall() {
6178
6182
  var _a;
6179
- const idAndVertices = [...this._vertices];
6183
+ const idAndVertices = [...this._vertexMap];
6180
6184
  const n = idAndVertices.length;
6181
6185
  const costs = [];
6182
6186
  const predecessor = [];
@@ -6209,7 +6213,7 @@ var dataStructureTyped = (() => {
6209
6213
  * Space Complexity: O(V) - Linear space (Tarjan's algorithm).
6210
6214
  * Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
6211
6215
  * Tarjan can find cycles in directed or undirected graph
6212
- * Tarjan can find the articulation points and bridges(critical edges) of undirected graphs in linear time,
6216
+ * Tarjan can find the articulation points and bridges(critical edgeMap) of undirected graphs in linear time,
6213
6217
  * Tarjan solve the bi-connected components of undirected graphs;
6214
6218
  * Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs.
6215
6219
  * /
@@ -6220,22 +6224,22 @@ var dataStructureTyped = (() => {
6220
6224
  *
6221
6225
  * Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
6222
6226
  * Tarjan can find cycles in directed or undirected graph
6223
- * Tarjan can find the articulation points and bridges(critical edges) of undirected graphs in linear time,
6227
+ * Tarjan can find the articulation points and bridges(critical edgeMap) of undirected graphs in linear time,
6224
6228
  * Tarjan solve the bi-connected components of undirected graphs;
6225
6229
  * Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs.
6226
6230
  * The `tarjan` function is used to perform various graph analysis tasks such as finding articulation points, bridges,
6227
6231
  * strongly connected components (SCCs), and cycles in a graph.
6228
6232
  * @param {boolean} [needCutVertexes] - A boolean value indicating whether or not to calculate and return the
6229
- * articulation points in the graph. Articulation points are the vertices in a graph whose removal would increase the
6233
+ * articulation points in the graph. Articulation points are the vertexMap in a graph whose removal would increase the
6230
6234
  * number of connected components in the graph.
6231
6235
  * @param {boolean} [needBridges] - A boolean flag indicating whether the algorithm should find and return the bridges
6232
- * (edges whose removal would increase the number of connected components in the graph).
6236
+ * (edgeMap whose removal would increase the number of connected components in the graph).
6233
6237
  * @param {boolean} [needSCCs] - A boolean value indicating whether the Strongly Connected Components (SCCs) of the
6234
6238
  * graph are needed. If set to true, the function will calculate and return the SCCs of the graph. If set to false, the
6235
6239
  * SCCs will not be calculated or returned.
6236
6240
  * @param {boolean} [needCycles] - A boolean flag indicating whether the algorithm should find cycles in the graph. If
6237
6241
  * set to true, the algorithm will return a map of cycles, where the keys are the low values of the SCCs and the values
6238
- * are arrays of vertices that form cycles within the SCCs.
6242
+ * are arrays of vertexMap that form cycles within the SCCs.
6239
6243
  * @returns The function `tarjan` returns an object with the following properties:
6240
6244
  */
6241
6245
  tarjan(needCutVertexes = false, needBridges = false, needSCCs = true, needCycles = false) {
@@ -6250,12 +6254,12 @@ var dataStructureTyped = (() => {
6250
6254
  needCycles = defaultConfig;
6251
6255
  const dfnMap = /* @__PURE__ */ new Map();
6252
6256
  const lowMap = /* @__PURE__ */ new Map();
6253
- const vertices = this._vertices;
6254
- vertices.forEach((v) => {
6257
+ const vertexMap = this._vertexMap;
6258
+ vertexMap.forEach((v) => {
6255
6259
  dfnMap.set(v, -1);
6256
6260
  lowMap.set(v, Infinity);
6257
6261
  });
6258
- const [root] = vertices.values();
6262
+ const [root] = vertexMap.values();
6259
6263
  const cutVertexes = [];
6260
6264
  const bridges = [];
6261
6265
  let dfn = 0;
@@ -6437,7 +6441,7 @@ var dataStructureTyped = (() => {
6437
6441
  return mapped;
6438
6442
  }
6439
6443
  *_getIterator() {
6440
- for (const vertex of this._vertices.values()) {
6444
+ for (const vertex of this._vertexMap.values()) {
6441
6445
  yield [vertex.key, vertex.value];
6442
6446
  }
6443
6447
  }
@@ -6445,12 +6449,12 @@ var dataStructureTyped = (() => {
6445
6449
  if (this.hasVertex(newVertex)) {
6446
6450
  return false;
6447
6451
  }
6448
- this._vertices.set(newVertex.key, newVertex);
6452
+ this._vertexMap.set(newVertex.key, newVertex);
6449
6453
  return true;
6450
6454
  }
6451
6455
  _getVertex(vertexOrKey) {
6452
6456
  const vertexKey = this._getVertexKey(vertexOrKey);
6453
- return this._vertices.get(vertexKey) || void 0;
6457
+ return this._vertexMap.get(vertexKey) || void 0;
6454
6458
  }
6455
6459
  _getVertexKey(vertexOrKey) {
6456
6460
  return vertexOrKey instanceof AbstractVertex ? vertexOrKey.key : vertexOrKey;
@@ -6472,7 +6476,7 @@ var dataStructureTyped = (() => {
6472
6476
  };
6473
6477
  var DirectedEdge = class extends AbstractEdge {
6474
6478
  /**
6475
- * The constructor function initializes the source and destination vertices of an edge, along with an optional weight
6479
+ * The constructor function initializes the source and destination vertexMap of an edge, along with an optional weight
6476
6480
  * and value.
6477
6481
  * @param {VertexKey} src - The `src` parameter is the source vertex ID. It represents the starting point of an edge in
6478
6482
  * a graph.
@@ -6512,7 +6516,7 @@ var dataStructureTyped = (() => {
6512
6516
  /**
6513
6517
  * The function creates a new vertex with an optional value and returns it.
6514
6518
  * @param {VertexKey} key - The `key` parameter is the unique identifier for the vertex. It is of type `VertexKey`, which
6515
- * could be a number or a string depending on how you want to identify your vertices.
6519
+ * could be a number or a string depending on how you want to identify your vertexMap.
6516
6520
  * @param [value] - The 'value' parameter is an optional value that can be assigned to the vertex. If a value is provided,
6517
6521
  * it will be assigned to the 'value' property of the vertex. If no value is provided, the 'value' property will be
6518
6522
  * assigned the same value as the 'key' parameter
@@ -6526,7 +6530,7 @@ var dataStructureTyped = (() => {
6526
6530
  * This means that using abstract methods in the parent class cannot constrain the grandchild classes. Defining methods within an interface also cannot constrain the descendant classes. When inheriting from this class, developers need to be aware that this method needs to be overridden.
6527
6531
  */
6528
6532
  /**
6529
- * The function creates a directed edge between two vertices with an optional weight and value.
6533
+ * The function creates a directed edge between two vertexMap with an optional weight and value.
6530
6534
  * @param {VertexKey} src - The source vertex ID of the edge. It represents the starting point of the edge.
6531
6535
  * @param {VertexKey} dest - The `dest` parameter is the identifier of the destination vertex for the edge.
6532
6536
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge. If no
@@ -6539,43 +6543,43 @@ var dataStructureTyped = (() => {
6539
6543
  return new DirectedEdge(src, dest, weight != null ? weight : 1, value);
6540
6544
  }
6541
6545
  /**
6542
- * Time Complexity: O(|V|) where |V| is the number of vertices
6546
+ * Time Complexity: O(|V|) where |V| is the number of vertexMap
6543
6547
  * Space Complexity: O(1)
6544
6548
  */
6545
6549
  /**
6546
- * Time Complexity: O(|V|) where |V| is the number of vertices
6550
+ * Time Complexity: O(|V|) where |V| is the number of vertexMap
6547
6551
  * Space Complexity: O(1)
6548
6552
  *
6549
- * The `getEdge` function retrieves an edge between two vertices based on their source and destination IDs.
6553
+ * The `getEdge` function retrieves an edge between two vertexMap based on their source and destination IDs.
6550
6554
  * @param {VO | VertexKey | undefined} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
6551
6555
  * @param {VO | VertexKey | undefined} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
6552
6556
  * destination vertex of the edge. It can be either a vertex object (`VO`), a vertex ID (`VertexKey`), or `undefined` if the
6553
6557
  * destination is not specified.
6554
- * @returns the first edge found between the source and destination vertices, or undefined if no such edge is found.
6558
+ * @returns the first edge found between the source and destination vertexMap, or undefined if no such edge is found.
6555
6559
  */
6556
6560
  getEdge(srcOrKey, destOrKey) {
6557
- let edges = [];
6561
+ let edgeMap = [];
6558
6562
  if (srcOrKey !== void 0 && destOrKey !== void 0) {
6559
6563
  const src = this._getVertex(srcOrKey);
6560
6564
  const dest = this._getVertex(destOrKey);
6561
6565
  if (src && dest) {
6562
6566
  const srcOutEdges = this._outEdgeMap.get(src);
6563
6567
  if (srcOutEdges) {
6564
- edges = srcOutEdges.filter((edge) => edge.dest === dest.key);
6568
+ edgeMap = srcOutEdges.filter((edge) => edge.dest === dest.key);
6565
6569
  }
6566
6570
  }
6567
6571
  }
6568
- return edges[0] || void 0;
6572
+ return edgeMap[0] || void 0;
6569
6573
  }
6570
6574
  /**
6571
- * Time Complexity: O(|E|) where |E| is the number of edges
6575
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
6572
6576
  * Space Complexity: O(1)
6573
6577
  */
6574
6578
  /**
6575
- * Time Complexity: O(|E|) where |E| is the number of edges
6579
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
6576
6580
  * Space Complexity: O(1)
6577
6581
  *
6578
- * The function removes an edge between two vertices in a graph and returns the removed edge.
6582
+ * The function removes an edge between two vertexMap in a graph and returns the removed edge.
6579
6583
  * @param {VO | VertexKey} srcOrKey - The source vertex or its ID.
6580
6584
  * @param {VO | VertexKey} destOrKey - The `destOrKey` parameter represents the destination vertex or its ID.
6581
6585
  * @returns the removed edge (EO) if it exists, or undefined if either the source or destination vertex does not exist.
@@ -6598,48 +6602,91 @@ var dataStructureTyped = (() => {
6598
6602
  return removed;
6599
6603
  }
6600
6604
  /**
6601
- * Time Complexity: O(|E|) where |E| is the number of edges
6605
+ * Time Complexity: O(E) where E is the number of edgeMap
6602
6606
  * Space Complexity: O(1)
6603
6607
  */
6604
6608
  /**
6605
- * Time Complexity: O(|E|) where |E| is the number of edges
6609
+ * Time Complexity: O(E) where E is the number of edgeMap
6606
6610
  * Space Complexity: O(1)
6607
6611
  *
6608
- * The function removes an edge from a graph and returns the removed edge, or undefined if the edge was not found.
6609
- * @param {EO} edge - The `edge` parameter is an object that represents an edge in a graph. It has two properties: `src`
6610
- * and `dest`, which represent the source and destination vertices of the edge, respectively.
6611
- * @returns The method `deleteEdge` returns the removed edge (`EO`) if it exists, or `undefined` if the edge does not exist.
6612
+ * The `deleteEdge` function removes an edge from a graph and returns the removed edge.
6613
+ * @param {EO | VertexKey} edgeOrSrcVertexKey - The `edge` parameter can be either an `EO` object (edge object) or
6614
+ * a `VertexKey` (key of a vertex).
6615
+ * @param {VertexKey} [destVertexKey] - The `destVertexKey` parameter is an optional parameter that
6616
+ * represents the key of the destination vertex of the edge. It is used to specify the destination
6617
+ * vertex when the `edge` parameter is a vertex key. If `destVertexKey` is not provided, the function
6618
+ * assumes that the `edge`
6619
+ * @returns the removed edge (EO) or undefined if no edge was removed.
6612
6620
  */
6613
- deleteEdge(edge) {
6621
+ deleteEdge(edgeOrSrcVertexKey, destVertexKey) {
6614
6622
  let removed = void 0;
6615
- const src = this._getVertex(edge.src);
6616
- const dest = this._getVertex(edge.dest);
6623
+ let src, dest;
6624
+ if (this.isVertexKey(edgeOrSrcVertexKey)) {
6625
+ if (this.isVertexKey(destVertexKey)) {
6626
+ src = this._getVertex(edgeOrSrcVertexKey);
6627
+ dest = this._getVertex(destVertexKey);
6628
+ } else {
6629
+ return;
6630
+ }
6631
+ } else {
6632
+ src = this._getVertex(edgeOrSrcVertexKey.src);
6633
+ dest = this._getVertex(edgeOrSrcVertexKey.dest);
6634
+ }
6617
6635
  if (src && dest) {
6618
6636
  const srcOutEdges = this._outEdgeMap.get(src);
6619
6637
  if (srcOutEdges && srcOutEdges.length > 0) {
6620
- arrayRemove(srcOutEdges, (edge2) => edge2.src === src.key);
6638
+ arrayRemove(srcOutEdges, (edge) => edge.src === src.key && edge.dest === (dest == null ? void 0 : dest.key));
6621
6639
  }
6622
6640
  const destInEdges = this._inEdgeMap.get(dest);
6623
6641
  if (destInEdges && destInEdges.length > 0) {
6624
- removed = arrayRemove(destInEdges, (edge2) => edge2.dest === dest.key)[0];
6642
+ removed = arrayRemove(destInEdges, (edge) => edge.src === src.key && edge.dest === dest.key)[0];
6625
6643
  }
6626
6644
  }
6627
6645
  return removed;
6628
6646
  }
6629
6647
  /**
6630
- * Time Complexity: O(|E|) where |E| is the number of edges
6648
+ * Time Complexity: O(1) - Constant time for Map operations.
6649
+ * Space Complexity: O(1) - Constant space, as it creates only a few variables.
6650
+ */
6651
+ /**
6652
+ * Time Complexity: O(1) - Constant time for Map operations.
6653
+ * Space Complexity: O(1) - Constant space, as it creates only a few variables.
6654
+ *
6655
+ * The `deleteVertex` function removes a vertex from a graph by its ID or by the vertex object itself.
6656
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
6657
+ * (`VertexKey`).
6658
+ * @returns The method is returning a boolean value.
6659
+ */
6660
+ deleteVertex(vertexOrKey) {
6661
+ let vertexKey;
6662
+ let vertex;
6663
+ if (this.isVertexKey(vertexOrKey)) {
6664
+ vertex = this.getVertex(vertexOrKey);
6665
+ vertexKey = vertexOrKey;
6666
+ } else {
6667
+ vertex = vertexOrKey;
6668
+ vertexKey = this._getVertexKey(vertexOrKey);
6669
+ }
6670
+ if (vertex) {
6671
+ this._outEdgeMap.delete(vertex);
6672
+ this._inEdgeMap.delete(vertex);
6673
+ }
6674
+ return this._vertexMap.delete(vertexKey);
6675
+ }
6676
+ /**
6677
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
6631
6678
  * Space Complexity: O(1)
6632
6679
  */
6633
6680
  /**
6634
- * Time Complexity: O(|E|) where |E| is the number of edges
6681
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
6635
6682
  * Space Complexity: O(1)
6636
6683
  *
6637
- * The function removes edges between two vertices and returns the removed edges.
6684
+ * The function removes edgeMap between two vertexMap and returns the removed edgeMap.
6638
6685
  * @param {VertexKey | VO} v1 - The parameter `v1` can be either a `VertexKey` or a `VO`. A `VertexKey` represents the
6639
6686
  * unique identifier of a vertex in a graph, while `VO` represents the actual vertex object.
6640
6687
  * @param {VertexKey | VO} v2 - The parameter `v2` represents either a `VertexKey` or a `VO` object. It is used to specify
6641
6688
  * the second vertex in the edge that needs to be removed.
6642
- * @returns an array of removed edges (EO[]).
6689
+ * @returns an array of removed edgeMap (EO[]).
6643
6690
  */
6644
6691
  deleteEdgesBetween(v1, v2) {
6645
6692
  const removed = [];
@@ -6659,10 +6706,10 @@ var dataStructureTyped = (() => {
6659
6706
  * Time Complexity: O(1)
6660
6707
  * Space Complexity: O(1)
6661
6708
  *
6662
- * The function `incomingEdgesOf` returns an array of incoming edges for a given vertex or vertex ID.
6709
+ * The function `incomingEdgesOf` returns an array of incoming edgeMap for a given vertex or vertex ID.
6663
6710
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
6664
6711
  * (`VertexKey`).
6665
- * @returns The method `incomingEdgesOf` returns an array of edges (`EO[]`).
6712
+ * @returns The method `incomingEdgesOf` returns an array of edgeMap (`EO[]`).
6666
6713
  */
6667
6714
  incomingEdgesOf(vertexOrKey) {
6668
6715
  const target = this._getVertex(vertexOrKey);
@@ -6679,10 +6726,10 @@ var dataStructureTyped = (() => {
6679
6726
  * Time Complexity: O(1)
6680
6727
  * Space Complexity: O(1)
6681
6728
  *
6682
- * The function `outgoingEdgesOf` returns an array of outgoing edges from a given vertex or vertex ID.
6729
+ * The function `outgoingEdgesOf` returns an array of outgoing edgeMap from a given vertex or vertex ID.
6683
6730
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can accept either a vertex object (`VO`) or a vertex ID
6684
6731
  * (`VertexKey`).
6685
- * @returns The method `outgoingEdgesOf` returns an array of edges (`EO[]`).
6732
+ * @returns The method `outgoingEdgesOf` returns an array of edgeMap (`EO[]`).
6686
6733
  */
6687
6734
  outgoingEdgesOf(vertexOrKey) {
6688
6735
  const target = this._getVertex(vertexOrKey);
@@ -6714,9 +6761,9 @@ var dataStructureTyped = (() => {
6714
6761
  * Time Complexity: O(1)
6715
6762
  * Space Complexity: O(1)
6716
6763
  *
6717
- * The function "inDegreeOf" returns the number of incoming edges for a given vertex.
6764
+ * The function "inDegreeOf" returns the number of incoming edgeMap for a given vertex.
6718
6765
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
6719
- * @returns The number of incoming edges of the specified vertex or vertex ID.
6766
+ * @returns The number of incoming edgeMap of the specified vertex or vertex ID.
6720
6767
  */
6721
6768
  inDegreeOf(vertexOrKey) {
6722
6769
  return this.incomingEdgesOf(vertexOrKey).length;
@@ -6729,9 +6776,9 @@ var dataStructureTyped = (() => {
6729
6776
  * Time Complexity: O(1)
6730
6777
  * Space Complexity: O(1)
6731
6778
  *
6732
- * The function `outDegreeOf` returns the number of outgoing edges from a given vertex.
6779
+ * The function `outDegreeOf` returns the number of outgoing edgeMap from a given vertex.
6733
6780
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
6734
- * @returns The number of outgoing edges from the specified vertex or vertex ID.
6781
+ * @returns The number of outgoing edgeMap from the specified vertex or vertex ID.
6735
6782
  */
6736
6783
  outDegreeOf(vertexOrKey) {
6737
6784
  return this.outgoingEdgesOf(vertexOrKey).length;
@@ -6744,9 +6791,9 @@ var dataStructureTyped = (() => {
6744
6791
  * Time Complexity: O(1)
6745
6792
  * Space Complexity: O(1)
6746
6793
  *
6747
- * The function "edgesOf" returns an array of both outgoing and incoming edges of a given vertex or vertex ID.
6794
+ * The function "edgesOf" returns an array of both outgoing and incoming edgeMap of a given vertex or vertex ID.
6748
6795
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
6749
- * @returns The function `edgesOf` returns an array of edges.
6796
+ * @returns The function `edgesOf` returns an array of edgeMap.
6750
6797
  */
6751
6798
  edgesOf(vertexOrKey) {
6752
6799
  return [...this.outgoingEdgesOf(vertexOrKey), ...this.incomingEdgesOf(vertexOrKey)];
@@ -6782,17 +6829,17 @@ var dataStructureTyped = (() => {
6782
6829
  return this._getVertex(e.dest);
6783
6830
  }
6784
6831
  /**
6785
- * Time Complexity: O(|E|) where |E| is the number of edges
6832
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
6786
6833
  * Space Complexity: O(1)
6787
6834
  */
6788
6835
  /**
6789
- * Time Complexity: O(|E|) where |E| is the number of edges
6836
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
6790
6837
  * Space Complexity: O(1)
6791
6838
  *
6792
- * The function `getDestinations` returns an array of destination vertices connected to a given vertex.
6839
+ * The function `getDestinations` returns an array of destination vertexMap connected to a given vertex.
6793
6840
  * @param {VO | VertexKey | undefined} vertex - The `vertex` parameter represents the starting vertex from which we want to
6794
6841
  * find the destinations. It can be either a `VO` object, a `VertexKey` value, or `undefined`.
6795
- * @returns an array of vertices (VO[]).
6842
+ * @returns an array of vertexMap (VO[]).
6796
6843
  */
6797
6844
  getDestinations(vertex) {
6798
6845
  if (vertex === void 0) {
@@ -6809,24 +6856,24 @@ var dataStructureTyped = (() => {
6809
6856
  return destinations;
6810
6857
  }
6811
6858
  /**
6812
- * Time Complexity: O(|V| + |E|) where |V| is the number of vertices and |E| is the number of edges
6859
+ * Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
6813
6860
  * Space Complexity: O(|V|)
6814
6861
  */
6815
6862
  /**
6816
- * Time Complexity: O(|V| + |E|) where |V| is the number of vertices and |E| is the number of edges
6863
+ * Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
6817
6864
  * Space Complexity: O(|V|)
6818
6865
  *
6819
- * The `topologicalSort` function performs a topological sort on a graph and returns an array of vertices or vertex IDs
6866
+ * The `topologicalSort` function performs a topological sort on a graph and returns an array of vertexMap or vertex IDs
6820
6867
  * in the sorted order, or undefined if the graph contains a cycle.
6821
6868
  * @param {'vertex' | 'key'} [propertyName] - The `propertyName` parameter is an optional parameter that specifies the
6822
- * property to use for sorting the vertices. It can have two possible values: 'vertex' or 'key'. If 'vertex' is
6823
- * specified, the vertices themselves will be used for sorting. If 'key' is specified, the ids of
6824
- * @returns an array of vertices or vertex IDs in topological order. If there is a cycle in the graph, it returns undefined.
6869
+ * property to use for sorting the vertexMap. It can have two possible values: 'vertex' or 'key'. If 'vertex' is
6870
+ * specified, the vertexMap themselves will be used for sorting. If 'key' is specified, the ids of
6871
+ * @returns an array of vertexMap or vertex IDs in topological order. If there is a cycle in the graph, it returns undefined.
6825
6872
  */
6826
6873
  topologicalSort(propertyName) {
6827
6874
  propertyName = propertyName != null ? propertyName : "key";
6828
6875
  const statusMap = /* @__PURE__ */ new Map();
6829
- for (const entry of this.vertices) {
6876
+ for (const entry of this.vertexMap) {
6830
6877
  statusMap.set(entry[1], 0);
6831
6878
  }
6832
6879
  let sorted = [];
@@ -6845,7 +6892,7 @@ var dataStructureTyped = (() => {
6845
6892
  statusMap.set(cur, 2);
6846
6893
  sorted.push(cur);
6847
6894
  };
6848
- for (const entry of this.vertices) {
6895
+ for (const entry of this.vertexMap) {
6849
6896
  if (statusMap.get(entry[1]) === 0) {
6850
6897
  dfs(entry[1]);
6851
6898
  }
@@ -6857,35 +6904,35 @@ var dataStructureTyped = (() => {
6857
6904
  return sorted.reverse();
6858
6905
  }
6859
6906
  /**
6860
- * Time Complexity: O(|E|) where |E| is the number of edges
6907
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
6861
6908
  * Space Complexity: O(|E|)
6862
6909
  */
6863
6910
  /**
6864
- * Time Complexity: O(|E|) where |E| is the number of edges
6911
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
6865
6912
  * Space Complexity: O(|E|)
6866
6913
  *
6867
- * The `edgeSet` function returns an array of all the edges in the graph.
6868
- * @returns The `edgeSet()` method returns an array of edges (`EO[]`).
6914
+ * The `edgeSet` function returns an array of all the edgeMap in the graph.
6915
+ * @returns The `edgeSet()` method returns an array of edgeMap (`EO[]`).
6869
6916
  */
6870
6917
  edgeSet() {
6871
- let edges = [];
6918
+ let edgeMap = [];
6872
6919
  this._outEdgeMap.forEach((outEdges) => {
6873
- edges = [...edges, ...outEdges];
6920
+ edgeMap = [...edgeMap, ...outEdges];
6874
6921
  });
6875
- return edges;
6922
+ return edgeMap;
6876
6923
  }
6877
6924
  /**
6878
- * Time Complexity: O(|E|) where |E| is the number of edges
6925
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
6879
6926
  * Space Complexity: O(1)
6880
6927
  */
6881
6928
  /**
6882
- * Time Complexity: O(|E|) where |E| is the number of edges
6929
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
6883
6930
  * Space Complexity: O(1)
6884
6931
  *
6885
- * The function `getNeighbors` returns an array of neighboring vertices of a given vertex or vertex ID in a graph.
6932
+ * The function `getNeighbors` returns an array of neighboring vertexMap of a given vertex or vertex ID in a graph.
6886
6933
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
6887
6934
  * (`VertexKey`).
6888
- * @returns an array of vertices (VO[]).
6935
+ * @returns an array of vertexMap (VO[]).
6889
6936
  */
6890
6937
  getNeighbors(vertexOrKey) {
6891
6938
  const neighbors = [];
@@ -6909,10 +6956,10 @@ var dataStructureTyped = (() => {
6909
6956
  * Time Complexity: O(1)
6910
6957
  * Space Complexity: O(1)
6911
6958
  *
6912
- * The function "getEndsOfEdge" returns the source and destination vertices of an edge if it exists in the graph,
6959
+ * The function "getEndsOfEdge" returns the source and destination vertexMap of an edge if it exists in the graph,
6913
6960
  * otherwise it returns undefined.
6914
6961
  * @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph.
6915
- * @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
6962
+ * @returns The function `getEndsOfEdge` returns an array containing two vertexMap `[VO, VO]` if the edge exists in the
6916
6963
  * graph. If the edge does not exist, it returns `undefined`.
6917
6964
  */
6918
6965
  getEndsOfEdge(edge) {
@@ -6935,7 +6982,7 @@ var dataStructureTyped = (() => {
6935
6982
  * Time Complexity: O(1)
6936
6983
  * Space Complexity: O(1)
6937
6984
  *
6938
- * The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertices exist.
6985
+ * The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertexMap exist.
6939
6986
  * @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph. It is the edge that
6940
6987
  * needs to be added to the graph.
6941
6988
  * @returns a boolean value. It returns true if the edge was successfully added to the graph, and false if either the
@@ -6993,21 +7040,21 @@ var dataStructureTyped = (() => {
6993
7040
  */
6994
7041
  constructor(v1, v2, weight, value) {
6995
7042
  super(weight, value);
6996
- __publicField(this, "vertices");
6997
- this.vertices = [v1, v2];
7043
+ __publicField(this, "vertexMap");
7044
+ this.vertexMap = [v1, v2];
6998
7045
  }
6999
7046
  };
7000
7047
  var UndirectedGraph = class extends AbstractGraph {
7001
7048
  /**
7002
- * The constructor initializes a new Map object to store edges.
7049
+ * The constructor initializes a new Map object to store edgeMap.
7003
7050
  */
7004
7051
  constructor() {
7005
7052
  super();
7006
- __publicField(this, "_edges");
7007
- this._edges = /* @__PURE__ */ new Map();
7053
+ __publicField(this, "_edgeMap");
7054
+ this._edgeMap = /* @__PURE__ */ new Map();
7008
7055
  }
7009
- get edges() {
7010
- return this._edges;
7056
+ get edgeMap() {
7057
+ return this._edgeMap;
7011
7058
  }
7012
7059
  /**
7013
7060
  * The function creates a new vertex with an optional value and returns it.
@@ -7022,7 +7069,7 @@ var dataStructureTyped = (() => {
7022
7069
  return new UndirectedVertex(key, value != null ? value : key);
7023
7070
  }
7024
7071
  /**
7025
- * The function creates an undirected edge between two vertices with an optional weight and value.
7072
+ * The function creates an undirected edge between two vertexMap with an optional weight and value.
7026
7073
  * @param {VertexKey} v1 - The parameter `v1` represents the first vertex of the edge.
7027
7074
  * @param {VertexKey} v2 - The parameter `v2` represents the second vertex of the edge.
7028
7075
  * @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the edge. If
@@ -7035,14 +7082,14 @@ var dataStructureTyped = (() => {
7035
7082
  return new UndirectedEdge(v1, v2, weight != null ? weight : 1, value);
7036
7083
  }
7037
7084
  /**
7038
- * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
7085
+ * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
7039
7086
  * Space Complexity: O(1)
7040
7087
  */
7041
7088
  /**
7042
- * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
7089
+ * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
7043
7090
  * Space Complexity: O(1)
7044
7091
  *
7045
- * The function `getEdge` returns the first edge that connects two vertices, or undefined if no such edge exists.
7092
+ * The function `getEdge` returns the first edge that connects two vertexMap, or undefined if no such edge exists.
7046
7093
  * @param {VO | VertexKey | undefined} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `VO` (vertex
7047
7094
  * object), `undefined`, or `VertexKey` (a string or number representing the ID of a vertex).
7048
7095
  * @param {VO | VertexKey | undefined} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `VO` (vertex
@@ -7051,29 +7098,29 @@ var dataStructureTyped = (() => {
7051
7098
  */
7052
7099
  getEdge(v1, v2) {
7053
7100
  var _a;
7054
- let edges = [];
7101
+ let edgeMap = [];
7055
7102
  if (v1 !== void 0 && v2 !== void 0) {
7056
7103
  const vertex1 = this._getVertex(v1);
7057
7104
  const vertex2 = this._getVertex(v2);
7058
7105
  if (vertex1 && vertex2) {
7059
- edges = (_a = this._edges.get(vertex1)) == null ? void 0 : _a.filter((e) => e.vertices.includes(vertex2.key));
7106
+ edgeMap = (_a = this._edgeMap.get(vertex1)) == null ? void 0 : _a.filter((e) => e.vertexMap.includes(vertex2.key));
7060
7107
  }
7061
7108
  }
7062
- return edges ? edges[0] || void 0 : void 0;
7109
+ return edgeMap ? edgeMap[0] || void 0 : void 0;
7063
7110
  }
7064
7111
  /**
7065
- * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
7112
+ * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
7066
7113
  * Space Complexity: O(1)
7067
7114
  */
7068
7115
  /**
7069
- * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
7116
+ * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
7070
7117
  * Space Complexity: O(1)
7071
7118
  *
7072
- * The function removes an edge between two vertices in a graph and returns the removed edge.
7119
+ * The function removes an edge between two vertexMap in a graph and returns the removed edge.
7073
7120
  * @param {VO | VertexKey} v1 - The parameter `v1` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).
7074
7121
  * @param {VO | VertexKey} v2 - VO | VertexKey - This parameter can be either a vertex object (VO) or a vertex ID
7075
7122
  * (VertexKey). It represents the second vertex of the edge that needs to be removed.
7076
- * @returns the removed edge (EO) if it exists, or undefined if either of the vertices (VO) does not exist.
7123
+ * @returns the removed edge (EO) if it exists, or undefined if either of the vertexMap (VO) does not exist.
7077
7124
  */
7078
7125
  deleteEdgeBetween(v1, v2) {
7079
7126
  const vertex1 = this._getVertex(v1);
@@ -7081,31 +7128,90 @@ var dataStructureTyped = (() => {
7081
7128
  if (!vertex1 || !vertex2) {
7082
7129
  return void 0;
7083
7130
  }
7084
- const v1Edges = this._edges.get(vertex1);
7131
+ const v1Edges = this._edgeMap.get(vertex1);
7085
7132
  let removed = void 0;
7086
7133
  if (v1Edges) {
7087
- removed = arrayRemove(v1Edges, (e) => e.vertices.includes(vertex2.key))[0] || void 0;
7134
+ removed = arrayRemove(v1Edges, (e) => e.vertexMap.includes(vertex2.key))[0] || void 0;
7088
7135
  }
7089
- const v2Edges = this._edges.get(vertex2);
7136
+ const v2Edges = this._edgeMap.get(vertex2);
7090
7137
  if (v2Edges) {
7091
- arrayRemove(v2Edges, (e) => e.vertices.includes(vertex1.key));
7138
+ arrayRemove(v2Edges, (e) => e.vertexMap.includes(vertex1.key));
7092
7139
  }
7093
7140
  return removed;
7094
7141
  }
7095
7142
  /**
7096
- * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
7143
+ * Time Complexity: O(E), where E is the number of edgeMap incident to the given vertex.
7097
7144
  * Space Complexity: O(1)
7098
7145
  */
7099
7146
  /**
7100
- * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
7147
+ * Time Complexity: O(E), where E is the number of edgeMap incident to the given vertex.
7101
7148
  * Space Complexity: O(1)
7102
7149
  *
7103
- * The deleteEdge function removes an edge between two vertices in a graph.
7104
- * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
7105
- * @returns The method is returning either the removed edge (of type EO) or undefined if the edge was not found.
7150
+ * The function `deleteEdge` deletes an edge between two vertexMap in a graph.
7151
+ * @param {EO | VertexKey} edgeOrOneSideVertexKey - The parameter `edgeOrOneSideVertexKey` can be
7152
+ * either an edge object or a vertex key.
7153
+ * @param {VertexKey} [otherSideVertexKey] - The parameter `otherSideVertexKey` is an optional
7154
+ * parameter that represents the key of the vertex on the other side of the edge. It is used when the
7155
+ * `edgeOrOneSideVertexKey` parameter is a vertex key, and it specifies the key of the vertex on the
7156
+ * other side of the
7157
+ * @returns The `deleteEdge` function returns either the deleted edge object (EO) or `undefined`.
7106
7158
  */
7107
- deleteEdge(edge) {
7108
- return this.deleteEdgeBetween(edge.vertices[0], edge.vertices[1]);
7159
+ deleteEdge(edgeOrOneSideVertexKey, otherSideVertexKey) {
7160
+ let oneSide, otherSide;
7161
+ if (this.isVertexKey(edgeOrOneSideVertexKey)) {
7162
+ if (this.isVertexKey(otherSideVertexKey)) {
7163
+ oneSide = this._getVertex(edgeOrOneSideVertexKey);
7164
+ otherSide = this._getVertex(otherSideVertexKey);
7165
+ } else {
7166
+ return;
7167
+ }
7168
+ } else {
7169
+ oneSide = this._getVertex(edgeOrOneSideVertexKey.vertexMap[0]);
7170
+ otherSide = this._getVertex(edgeOrOneSideVertexKey.vertexMap[1]);
7171
+ }
7172
+ if (oneSide && otherSide) {
7173
+ return this.deleteEdgeBetween(oneSide, otherSide);
7174
+ } else {
7175
+ return;
7176
+ }
7177
+ }
7178
+ /**
7179
+ * Time Complexity: O(1) - Constant time for Map operations.
7180
+ * Space Complexity: O(1) - Constant space, as it creates only a few variables.
7181
+ */
7182
+ /**
7183
+ * Time Complexity: O(1) - Constant time for Map operations.
7184
+ * Space Complexity: O(1) - Constant space, as it creates only a few variables.
7185
+ *
7186
+ * The `deleteVertex` function removes a vertex from a graph by its ID or by the vertex object itself.
7187
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
7188
+ * (`VertexKey`).
7189
+ * @returns The method is returning a boolean value.
7190
+ */
7191
+ deleteVertex(vertexOrKey) {
7192
+ let vertexKey;
7193
+ let vertex;
7194
+ if (this.isVertexKey(vertexOrKey)) {
7195
+ vertex = this.getVertex(vertexOrKey);
7196
+ vertexKey = vertexOrKey;
7197
+ } else {
7198
+ vertex = vertexOrKey;
7199
+ vertexKey = this._getVertexKey(vertexOrKey);
7200
+ }
7201
+ const neighbors = this.getNeighbors(vertexOrKey);
7202
+ if (vertex) {
7203
+ neighbors.forEach((neighbor) => {
7204
+ const neighborEdges = this._edgeMap.get(neighbor);
7205
+ if (neighborEdges) {
7206
+ const restEdges = neighborEdges.filter((edge) => {
7207
+ return !edge.vertexMap.includes(vertexKey);
7208
+ });
7209
+ this._edgeMap.set(neighbor, restEdges);
7210
+ }
7211
+ });
7212
+ this._edgeMap.delete(vertex);
7213
+ }
7214
+ return this._vertexMap.delete(vertexKey);
7109
7215
  }
7110
7216
  /**
7111
7217
  * Time Complexity: O(1)
@@ -7115,17 +7221,17 @@ var dataStructureTyped = (() => {
7115
7221
  * Time Complexity: O(1)
7116
7222
  * Space Complexity: O(1)
7117
7223
  *
7118
- * The function `degreeOf` returns the degree of a vertex in a graph, which is the number of edges connected to that
7224
+ * The function `degreeOf` returns the degree of a vertex in a graph, which is the number of edgeMap connected to that
7119
7225
  * vertex.
7120
7226
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
7121
7227
  * @returns The function `degreeOf` returns the degree of a vertex in a graph. The degree of a vertex is the number of
7122
- * edges connected to that vertex.
7228
+ * edgeMap connected to that vertex.
7123
7229
  */
7124
7230
  degreeOf(vertexOrKey) {
7125
7231
  var _a;
7126
7232
  const vertex = this._getVertex(vertexOrKey);
7127
7233
  if (vertex) {
7128
- return ((_a = this._edges.get(vertex)) == null ? void 0 : _a.length) || 0;
7234
+ return ((_a = this._edgeMap.get(vertex)) == null ? void 0 : _a.length) || 0;
7129
7235
  } else {
7130
7236
  return 0;
7131
7237
  }
@@ -7138,51 +7244,51 @@ var dataStructureTyped = (() => {
7138
7244
  * Time Complexity: O(1)
7139
7245
  * Space Complexity: O(1)
7140
7246
  *
7141
- * The function returns the edges of a given vertex or vertex ID.
7247
+ * The function returns the edgeMap of a given vertex or vertex ID.
7142
7248
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`. A `VertexKey` is a
7143
7249
  * unique identifier for a vertex in a graph, while `VO` represents the type of the vertex.
7144
- * @returns an array of edges.
7250
+ * @returns an array of edgeMap.
7145
7251
  */
7146
7252
  edgesOf(vertexOrKey) {
7147
7253
  const vertex = this._getVertex(vertexOrKey);
7148
7254
  if (vertex) {
7149
- return this._edges.get(vertex) || [];
7255
+ return this._edgeMap.get(vertex) || [];
7150
7256
  } else {
7151
7257
  return [];
7152
7258
  }
7153
7259
  }
7154
7260
  /**
7155
- * Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
7261
+ * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
7156
7262
  * Space Complexity: O(|E|)
7157
7263
  */
7158
7264
  /**
7159
- * Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
7265
+ * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
7160
7266
  * Space Complexity: O(|E|)
7161
7267
  *
7162
- * The function "edgeSet" returns an array of unique edges from a set of edges.
7268
+ * The function "edgeSet" returns an array of unique edgeMap from a set of edgeMap.
7163
7269
  * @returns The method `edgeSet()` returns an array of type `EO[]`.
7164
7270
  */
7165
7271
  edgeSet() {
7166
7272
  const edgeSet = /* @__PURE__ */ new Set();
7167
- this._edges.forEach((edges) => {
7168
- edges.forEach((edge) => {
7273
+ this._edgeMap.forEach((edgeMap) => {
7274
+ edgeMap.forEach((edge) => {
7169
7275
  edgeSet.add(edge);
7170
7276
  });
7171
7277
  });
7172
7278
  return [...edgeSet];
7173
7279
  }
7174
7280
  /**
7175
- * Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
7281
+ * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
7176
7282
  * Space Complexity: O(|E|)
7177
7283
  */
7178
7284
  /**
7179
- * Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
7285
+ * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
7180
7286
  * Space Complexity: O(|E|)
7181
7287
  *
7182
- * The function "getNeighbors" returns an array of neighboring vertices for a given vertex or vertex ID.
7288
+ * The function "getNeighbors" returns an array of neighboring vertexMap for a given vertex or vertex ID.
7183
7289
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
7184
7290
  * (`VertexKey`).
7185
- * @returns an array of vertices (VO[]).
7291
+ * @returns an array of vertexMap (VO[]).
7186
7292
  */
7187
7293
  getNeighbors(vertexOrKey) {
7188
7294
  const neighbors = [];
@@ -7190,7 +7296,7 @@ var dataStructureTyped = (() => {
7190
7296
  if (vertex) {
7191
7297
  const neighborEdges = this.edgesOf(vertex);
7192
7298
  for (const edge of neighborEdges) {
7193
- const neighbor = this._getVertex(edge.vertices.filter((e) => e !== vertex.key)[0]);
7299
+ const neighbor = this._getVertex(edge.vertexMap.filter((e) => e !== vertex.key)[0]);
7194
7300
  if (neighbor) {
7195
7301
  neighbors.push(neighbor);
7196
7302
  }
@@ -7206,18 +7312,18 @@ var dataStructureTyped = (() => {
7206
7312
  * Time Complexity: O(1)
7207
7313
  * Space Complexity: O(1)
7208
7314
  *
7209
- * The function "getEndsOfEdge" returns the vertices at the ends of an edge if the edge exists in the graph, otherwise
7315
+ * The function "getEndsOfEdge" returns the vertexMap at the ends of an edge if the edge exists in the graph, otherwise
7210
7316
  * it returns undefined.
7211
7317
  * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
7212
- * @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
7318
+ * @returns The function `getEndsOfEdge` returns an array containing two vertexMap `[VO, VO]` if the edge exists in the
7213
7319
  * graph. If the edge does not exist, it returns `undefined`.
7214
7320
  */
7215
7321
  getEndsOfEdge(edge) {
7216
- if (!this.hasEdge(edge.vertices[0], edge.vertices[1])) {
7322
+ if (!this.hasEdge(edge.vertexMap[0], edge.vertexMap[1])) {
7217
7323
  return void 0;
7218
7324
  }
7219
- const v1 = this._getVertex(edge.vertices[0]);
7220
- const v2 = this._getVertex(edge.vertices[1]);
7325
+ const v1 = this._getVertex(edge.vertexMap[0]);
7326
+ const v2 = this._getVertex(edge.vertexMap[1]);
7221
7327
  if (v1 && v2) {
7222
7328
  return [v1, v2];
7223
7329
  } else {
@@ -7232,21 +7338,21 @@ var dataStructureTyped = (() => {
7232
7338
  * Time Complexity: O(1)
7233
7339
  * Space Complexity: O(1)
7234
7340
  *
7235
- * The function adds an edge to the graph by updating the adjacency list with the vertices of the edge.
7341
+ * The function adds an edge to the graph by updating the adjacency list with the vertexMap of the edge.
7236
7342
  * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
7237
7343
  * @returns a boolean value.
7238
7344
  */
7239
7345
  _addEdgeOnly(edge) {
7240
- for (const end of edge.vertices) {
7346
+ for (const end of edge.vertexMap) {
7241
7347
  const endVertex = this._getVertex(end);
7242
7348
  if (endVertex === void 0)
7243
7349
  return false;
7244
7350
  if (endVertex) {
7245
- const edges = this._edges.get(endVertex);
7246
- if (edges) {
7247
- edges.push(edge);
7351
+ const edgeMap = this._edgeMap.get(endVertex);
7352
+ if (edgeMap) {
7353
+ edgeMap.push(edge);
7248
7354
  } else {
7249
- this._edges.set(endVertex, [edge]);
7355
+ this._edgeMap.set(endVertex, [edge]);
7250
7356
  }
7251
7357
  }
7252
7358
  }
@@ -7293,23 +7399,23 @@ var dataStructureTyped = (() => {
7293
7399
  };
7294
7400
  var MapGraph = class extends DirectedGraph {
7295
7401
  /**
7296
- * The constructor function initializes the origin and bottomRight properties of a MapGraphCoordinate object.
7297
- * @param {MapGraphCoordinate} origin - The `origin` parameter is a `MapGraphCoordinate` object that represents the
7402
+ * The constructor function initializes the originCoord and bottomRight properties of a MapGraphCoordinate object.
7403
+ * @param {MapGraphCoordinate} originCoord - The `originCoord` parameter is a `MapGraphCoordinate` object that represents the
7298
7404
  * starting point or reference point of the map graph. It defines the coordinates of the top-left corner of the map
7299
7405
  * graph.
7300
7406
  * @param {MapGraphCoordinate} [bottomRight] - The `bottomRight` parameter is an optional parameter of type
7301
7407
  * `MapGraphCoordinate`. It represents the bottom right coordinate of a map graph. If this parameter is not provided,
7302
7408
  * it will default to `undefined`.
7303
7409
  */
7304
- constructor(origin, bottomRight) {
7410
+ constructor(originCoord, bottomRight) {
7305
7411
  super();
7306
- __publicField(this, "_origin", [0, 0]);
7412
+ __publicField(this, "_originCoord", [0, 0]);
7307
7413
  __publicField(this, "_bottomRight");
7308
- this._origin = origin;
7414
+ this._originCoord = originCoord;
7309
7415
  this._bottomRight = bottomRight;
7310
7416
  }
7311
- get origin() {
7312
- return this._origin;
7417
+ get originCoord() {
7418
+ return this._originCoord;
7313
7419
  }
7314
7420
  get bottomRight() {
7315
7421
  return this._bottomRight;
@@ -7325,7 +7431,7 @@ var dataStructureTyped = (() => {
7325
7431
  * @param {number} long - The `long` parameter represents the longitude coordinate of the vertex.
7326
7432
  * @returns The method is returning a new instance of the `MapVertex` class, casted as type `VO`.
7327
7433
  */
7328
- createVertex(key, value, lat = this.origin[0], long = this.origin[1]) {
7434
+ createVertex(key, value, lat = this.originCoord[0], long = this.originCoord[1]) {
7329
7435
  return new MapVertex(key, value, lat, long);
7330
7436
  }
7331
7437
  /**
@@ -7428,7 +7534,7 @@ var dataStructureTyped = (() => {
7428
7534
  return "MAL_NODE" /* MAL_NODE */;
7429
7535
  }
7430
7536
  };
7431
- var BinaryTree = class _BinaryTree extends IterablePairBase {
7537
+ var BinaryTree = class _BinaryTree extends IterableEntryBase {
7432
7538
  /**
7433
7539
  * The constructor function initializes a binary tree object with optional elements and options.
7434
7540
  * @param [elements] - An optional iterable of BTNodeExemplar objects. These objects represent the
@@ -7495,31 +7601,32 @@ var dataStructureTyped = (() => {
7495
7601
  return exemplar instanceof BinaryTreeNode;
7496
7602
  }
7497
7603
  /**
7498
- * The function `exemplarToNode` converts an exemplar of a binary tree node into an actual node
7499
- * object.
7500
- * @param exemplar - BTNodeExemplar<K, V,N> - A generic type representing the exemplar parameter of the
7501
- * function. It can be any type.
7502
- * @returns a value of type `N` (which represents a node), or `null`, or `undefined`.
7604
+ * The function `exemplarToNode` converts an exemplar object into a node object.
7605
+ * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
7606
+ * @param {V} [value] - The `value` parameter is an optional value that can be passed to the
7607
+ * `exemplarToNode` function. It represents the value associated with the exemplar node. If no value
7608
+ * is provided, it will be `undefined`.
7609
+ * @returns a value of type N (node), or null, or undefined.
7503
7610
  */
7504
- exemplarToNode(exemplar) {
7611
+ exemplarToNode(exemplar, value) {
7505
7612
  if (exemplar === void 0)
7506
7613
  return;
7507
7614
  let node;
7508
7615
  if (exemplar === null) {
7509
7616
  node = null;
7510
7617
  } else if (this.isEntry(exemplar)) {
7511
- const [key, value] = exemplar;
7618
+ const [key, value2] = exemplar;
7512
7619
  if (key === void 0) {
7513
7620
  return;
7514
7621
  } else if (key === null) {
7515
7622
  node = null;
7516
7623
  } else {
7517
- node = this.createNode(key, value);
7624
+ node = this.createNode(key, value2);
7518
7625
  }
7519
7626
  } else if (this.isNode(exemplar)) {
7520
7627
  node = exemplar;
7521
7628
  } else if (this.isNotNodeInstance(exemplar)) {
7522
- node = this.createNode(exemplar);
7629
+ node = this.createNode(exemplar, value);
7523
7630
  } else {
7524
7631
  return;
7525
7632
  }
@@ -7541,14 +7648,16 @@ var dataStructureTyped = (() => {
7541
7648
  /**
7542
7649
  * Time Complexity O(log n) - O(n)
7543
7650
  * Space Complexity O(1)
7544
- *
7545
- * The `add` function adds a new node to a binary tree, either by key or by providing a node object.
7546
- * @param keyOrNodeOrEntry - The parameter `keyOrNodeOrEntry` can be one of the following:
7547
- * @returns The function `add` returns the inserted node (`N`), `null`, or `undefined`.
7651
+ *
7652
+ * The `add` function adds a new node to a binary tree, either by creating a new node or replacing an
7653
+ * existing node with the same key.
7654
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be one of the following:
7655
+ * @param {V} [value] - The value to be inserted into the binary tree.
7656
+ * @returns The function `add` returns either a node (`N`), `null`, or `undefined`.
7548
7657
  */
7549
- add(keyOrNodeOrEntry) {
7658
+ add(keyOrNodeOrEntry, value) {
7550
7659
  let inserted;
7551
- const newNode = this.exemplarToNode(keyOrNodeOrEntry);
7660
+ const newNode = this.exemplarToNode(keyOrNodeOrEntry, value);
7552
7661
  if (newNode === void 0)
7553
7662
  return;
7554
7663
  const _bfs = (root, newNode2) => {
@@ -9093,26 +9202,28 @@ var dataStructureTyped = (() => {
9093
9202
  return exemplar instanceof BSTNode;
9094
9203
  }
9095
9204
  /**
9096
- * The function `exemplarToNode` takes an exemplar and returns a corresponding node if the exemplar
9097
- * is valid, otherwise it returns undefined.
9098
- * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
9099
- * @returns a variable `node` which is of type `N` or `undefined`.
9205
+ * The function `exemplarToNode` takes an exemplar and returns a node if the exemplar is valid,
9206
+ * otherwise it returns undefined.
9207
+ * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where:
9208
+ * @param {V} [value] - The `value` parameter is an optional value that can be passed to the
9209
+ * `exemplarToNode` function. It represents the value associated with the exemplar node.
9210
+ * @returns a node of type N or undefined.
9100
9211
  */
9101
- exemplarToNode(exemplar) {
9212
+ exemplarToNode(exemplar, value) {
9102
9213
  let node;
9103
9214
  if (exemplar === null || exemplar === void 0) {
9104
9215
  return;
9105
9216
  } else if (this.isNode(exemplar)) {
9106
9217
  node = exemplar;
9107
9218
  } else if (this.isEntry(exemplar)) {
9108
- const [key, value] = exemplar;
9219
+ const [key, value2] = exemplar;
9109
9220
  if (key === void 0 || key === null) {
9110
9221
  return;
9111
9222
  } else {
9112
- node = this.createNode(key, value);
9223
+ node = this.createNode(key, value2);
9113
9224
  }
9114
9225
  } else if (this.isNotNodeInstance(exemplar)) {
9115
- node = this.createNode(exemplar);
9226
+ node = this.createNode(exemplar, value);
9116
9227
  } else {
9117
9228
  return;
9118
9229
  }
@@ -9125,15 +9236,17 @@ var dataStructureTyped = (() => {
9125
9236
  /**
9126
9237
  * Time Complexity: O(log n) - Average case for a balanced tree. In the worst case (unbalanced tree), it can be O(n).
9127
9238
  * Space Complexity: O(1) - Constant space is used.
9128
- *
9129
- * The `add` function adds a new node to a binary search tree, either by key or by providing a node
9130
- * object.
9131
- * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be one of the following:
9132
- * @returns The method returns either the newly added node (`newNode`) or `undefined` if the input
9133
- * (`keyOrNodeOrEntry`) is null, undefined, or does not match any of the expected types.
9134
- */
9135
- add(keyOrNodeOrEntry) {
9136
- const newNode = this.exemplarToNode(keyOrNodeOrEntry);
9239
+ *
9240
+ * The `add` function adds a new node to a binary tree, updating the value if the key already exists
9241
+ * or inserting a new node if the key is unique.
9242
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can accept three types of values:
9243
+ * @param {V} [value] - The `value` parameter represents the value associated with the key that is
9244
+ * being added to the binary tree.
9245
+ * @returns The method `add` returns either the newly added node (`newNode`) or `undefined` if the
9246
+ * node was not added.
9247
+ */
9248
+ add(keyOrNodeOrEntry, value) {
9249
+ const newNode = this.exemplarToNode(keyOrNodeOrEntry, value);
9137
9250
  if (newNode === void 0)
9138
9251
  return;
9139
9252
  if (this.root === void 0) {
@@ -10108,17 +10221,19 @@ var dataStructureTyped = (() => {
10108
10221
  /**
10109
10222
  * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (BST) has logarithmic time complexity.
10110
10223
  * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
10111
- *
10224
+ *
10112
10225
  * The function overrides the add method of a binary tree node and balances the tree after inserting
10113
10226
  * a new node.
10114
- * @param keyOrNodeOrEntry - The parameter `keyOrNodeOrEntry` can be either a key, a node, or an
10227
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be either a key, a node, or an
10115
10228
  * entry.
10116
- * @returns The method is returning either the inserted node or `undefined`.
10229
+ * @param {V} [value] - The `value` parameter represents the value associated with the key that is
10230
+ * being added to the binary tree.
10231
+ * @returns The method is returning either the inserted node or undefined.
10117
10232
  */
10118
- add(keyOrNodeOrEntry) {
10233
+ add(keyOrNodeOrEntry, value) {
10119
10234
  if (keyOrNodeOrEntry === null)
10120
10235
  return void 0;
10121
- const inserted = super.add(keyOrNodeOrEntry);
10236
+ const inserted = super.add(keyOrNodeOrEntry, value);
10122
10237
  if (inserted)
10123
10238
  this._balancePath(inserted);
10124
10239
  return inserted;
@@ -10531,28 +10646,28 @@ var dataStructureTyped = (() => {
10531
10646
  return exemplar instanceof RedBlackTreeNode;
10532
10647
  }
10533
10648
  /**
10534
- * The function `exemplarToNode` takes an exemplar and returns a node if the exemplar is valid,
10535
- * otherwise it returns undefined.
10536
- * @param exemplar - BTNodeExemplar<K, V, N> - A generic type representing an exemplar of a binary tree
10537
- * node. It can be either a node itself, an entry (key-value pair), a node key, or any other value
10538
- * that is not a valid exemplar.
10539
- * @returns a variable `node` which is of type `N | undefined`.
10649
+ * The function `exemplarToNode` takes an exemplar and converts it into a node object if possible.
10650
+ * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where:
10651
+ * @param {V} [value] - The `value` parameter is an optional value that can be passed to the
10652
+ * `exemplarToNode` function. It represents the value associated with the exemplar node. If a value
10653
+ * is provided, it will be used when creating the new node. If no value is provided, the new node
10654
+ * @returns a node of type N or undefined.
10540
10655
  */
10541
- exemplarToNode(exemplar) {
10656
+ exemplarToNode(exemplar, value) {
10542
10657
  let node;
10543
10658
  if (exemplar === null || exemplar === void 0) {
10544
10659
  return;
10545
10660
  } else if (this.isNode(exemplar)) {
10546
10661
  node = exemplar;
10547
10662
  } else if (this.isEntry(exemplar)) {
10548
- const [key, value] = exemplar;
10663
+ const [key, value2] = exemplar;
10549
10664
  if (key === void 0 || key === null) {
10550
10665
  return;
10551
10666
  } else {
10552
- node = this.createNode(key, value, 1 /* RED */);
10667
+ node = this.createNode(key, value2, 1 /* RED */);
10553
10668
  }
10554
10669
  } else if (this.isNotNodeInstance(exemplar)) {
10555
- node = this.createNode(exemplar, void 0, 1 /* RED */);
10670
+ node = this.createNode(exemplar, value, 1 /* RED */);
10556
10671
  } else {
10557
10672
  return;
10558
10673
  }
@@ -10563,13 +10678,19 @@ var dataStructureTyped = (() => {
10563
10678
  * Space Complexity: O(1)
10564
10679
  */
10565
10680
  /**
10566
- * The function adds a node to a Red-Black Tree data structure.
10567
- * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be one of the following:
10568
- * @returns The method `add` returns either an instance of `N` (the node that was added) or
10569
- * `undefined`.
10681
+ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
10682
+ * Space Complexity: O(1)
10683
+ *
10684
+ * The `add` function adds a new node to a binary search tree and performs necessary rotations and
10685
+ * color changes to maintain the red-black tree properties.
10686
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be either a key, a node, or an
10687
+ * entry.
10688
+ * @param {V} [value] - The `value` parameter represents the value associated with the key that is
10689
+ * being added to the binary search tree.
10690
+ * @returns The method `add` returns either the newly added node (`N`) or `undefined`.
10570
10691
  */
10571
- add(keyOrNodeOrEntry) {
10572
- const newNode = this.exemplarToNode(keyOrNodeOrEntry);
10692
+ add(keyOrNodeOrEntry, value) {
10693
+ const newNode = this.exemplarToNode(keyOrNodeOrEntry, value);
10573
10694
  if (newNode === void 0)
10574
10695
  return;
10575
10696
  newNode.left = this.Sentinel;
@@ -11070,27 +11191,30 @@ var dataStructureTyped = (() => {
11070
11191
  }
11071
11192
  /**
11072
11193
  * The function `exemplarToNode` converts an exemplar object into a node object.
11073
- * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where `V` represents
11074
- * the value type and `N` represents the node type.
11194
+ * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, which means it
11195
+ * can be one of the following:
11196
+ * @param {V} [value] - The `value` parameter is an optional argument that represents the value
11197
+ * associated with the node. It is of type `V`, which can be any data type. If no value is provided,
11198
+ * it defaults to `undefined`.
11075
11199
  * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
11076
- * times the node should be created. If not provided, it defaults to 1.
11077
- * @returns a value of type `N` (the generic type parameter) or `undefined`.
11200
+ * times the value should be added to the node. If not provided, it defaults to 1.
11201
+ * @returns a node of type `N` or `undefined`.
11078
11202
  */
11079
- exemplarToNode(exemplar, count = 1) {
11203
+ exemplarToNode(exemplar, value, count = 1) {
11080
11204
  let node;
11081
11205
  if (exemplar === void 0 || exemplar === null) {
11082
11206
  return;
11083
11207
  } else if (this.isNode(exemplar)) {
11084
11208
  node = exemplar;
11085
11209
  } else if (this.isEntry(exemplar)) {
11086
- const [key, value] = exemplar;
11210
+ const [key, value2] = exemplar;
11087
11211
  if (key === void 0 || key === null) {
11088
11212
  return;
11089
11213
  } else {
11090
- node = this.createNode(key, value, count);
11214
+ node = this.createNode(key, value2, count);
11091
11215
  }
11092
11216
  } else if (this.isNotNodeInstance(exemplar)) {
11093
- node = this.createNode(exemplar, void 0, count);
11217
+ node = this.createNode(exemplar, value, count);
11094
11218
  } else {
11095
11219
  return;
11096
11220
  }
@@ -11103,17 +11227,21 @@ var dataStructureTyped = (() => {
11103
11227
  /**
11104
11228
  * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (AVLTree) has logarithmic time complexity.
11105
11229
  * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
11106
- *
11107
- * The `add` function overrides the base class `add` function to add a new node to the tree multimap
11108
- * and update the count.
11109
- * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be one of the following:
11110
- * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
11111
- * times the key or node or entry should be added to the multimap. If not provided, the default value
11112
- * is 1.
11113
- * @returns either a node (`N`) or `undefined`.
11114
- */
11115
- add(keyOrNodeOrEntry, count = 1) {
11116
- const newNode = this.exemplarToNode(keyOrNodeOrEntry, count);
11230
+ *
11231
+ * The function overrides the add method of a binary tree node and adds a new node to the tree.
11232
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be either a key, a node, or an
11233
+ * entry. It represents the key, node, or entry that you want to add to the binary tree.
11234
+ * @param {V} [value] - The `value` parameter represents the value associated with the key in the
11235
+ * binary tree node. It is an optional parameter, meaning it can be omitted when calling the `add`
11236
+ * method.
11237
+ * @param [count=1] - The `count` parameter represents the number of times the key-value pair should
11238
+ * be added to the binary tree. By default, it is set to 1, meaning that the key-value pair will be
11239
+ * added once. However, you can specify a different value for `count` if you want to add
11240
+ * @returns The method is returning either the newly inserted node or `undefined` if the insertion
11241
+ * was not successful.
11242
+ */
11243
+ add(keyOrNodeOrEntry, value, count = 1) {
11244
+ const newNode = this.exemplarToNode(keyOrNodeOrEntry, value, count);
11117
11245
  if (newNode === void 0)
11118
11246
  return;
11119
11247
  const orgNodeCount = (newNode == null ? void 0 : newNode.count) || 0;
@@ -11166,7 +11294,7 @@ var dataStructureTyped = (() => {
11166
11294
  return;
11167
11295
  const m = l + Math.floor((r - l) / 2);
11168
11296
  const midNode = sorted[m];
11169
- this.add([midNode.key, midNode.value], midNode.count);
11297
+ this.add(midNode.key, midNode.value, midNode.count);
11170
11298
  buildBalanceBST(l, m - 1);
11171
11299
  buildBalanceBST(m + 1, r);
11172
11300
  };
@@ -11181,7 +11309,7 @@ var dataStructureTyped = (() => {
11181
11309
  if (l <= r) {
11182
11310
  const m = l + Math.floor((r - l) / 2);
11183
11311
  const midNode = sorted[m];
11184
- this.add([midNode.key, midNode.value], midNode.count);
11312
+ this.add(midNode.key, midNode.value, midNode.count);
11185
11313
  stack.push([m + 1, r]);
11186
11314
  stack.push([l, m - 1]);
11187
11315
  }
@@ -11289,7 +11417,7 @@ var dataStructureTyped = (() => {
11289
11417
  */
11290
11418
  clone() {
11291
11419
  const cloned = this.createTree();
11292
- this.bfs((node) => cloned.add([node.key, node.value], node.count));
11420
+ this.bfs((node) => cloned.add(node.key, node.value, node.count));
11293
11421
  return cloned;
11294
11422
  }
11295
11423
  /**