queue-typed 1.48.4 → 1.48.6

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 (38) hide show
  1. package/dist/data-structures/base/iterable-base.d.ts +6 -6
  2. package/dist/data-structures/base/iterable-base.js +3 -3
  3. package/dist/data-structures/binary-tree/avl-tree.d.ts +5 -3
  4. package/dist/data-structures/binary-tree/avl-tree.js +6 -4
  5. package/dist/data-structures/binary-tree/binary-tree.d.ts +24 -22
  6. package/dist/data-structures/binary-tree/binary-tree.js +35 -22
  7. package/dist/data-structures/binary-tree/bst.d.ts +30 -22
  8. package/dist/data-structures/binary-tree/bst.js +38 -26
  9. package/dist/data-structures/binary-tree/rb-tree.d.ts +19 -13
  10. package/dist/data-structures/binary-tree/rb-tree.js +20 -14
  11. package/dist/data-structures/binary-tree/tree-multimap.d.ts +21 -14
  12. package/dist/data-structures/binary-tree/tree-multimap.js +25 -18
  13. package/dist/data-structures/graph/abstract-graph.d.ts +52 -52
  14. package/dist/data-structures/graph/abstract-graph.js +78 -78
  15. package/dist/data-structures/graph/directed-graph.d.ts +47 -47
  16. package/dist/data-structures/graph/directed-graph.js +56 -56
  17. package/dist/data-structures/graph/map-graph.d.ts +5 -5
  18. package/dist/data-structures/graph/map-graph.js +8 -8
  19. package/dist/data-structures/graph/undirected-graph.d.ts +29 -29
  20. package/dist/data-structures/graph/undirected-graph.js +57 -57
  21. package/dist/data-structures/hash/hash-map.d.ts +8 -8
  22. package/dist/data-structures/hash/hash-map.js +2 -2
  23. package/dist/interfaces/binary-tree.d.ts +2 -2
  24. package/dist/types/data-structures/base/base.d.ts +3 -3
  25. package/package.json +2 -2
  26. package/src/data-structures/base/iterable-base.ts +6 -6
  27. package/src/data-structures/binary-tree/avl-tree.ts +7 -4
  28. package/src/data-structures/binary-tree/binary-tree.ts +47 -27
  29. package/src/data-structures/binary-tree/bst.ts +52 -32
  30. package/src/data-structures/binary-tree/rb-tree.ts +20 -14
  31. package/src/data-structures/binary-tree/tree-multimap.ts +26 -18
  32. package/src/data-structures/graph/abstract-graph.ts +82 -82
  33. package/src/data-structures/graph/directed-graph.ts +56 -56
  34. package/src/data-structures/graph/map-graph.ts +8 -8
  35. package/src/data-structures/graph/undirected-graph.ts +59 -59
  36. package/src/data-structures/hash/hash-map.ts +8 -8
  37. package/src/interfaces/binary-tree.ts +2 -2
  38. package/src/types/data-structures/base/base.ts +3 -3
@@ -50,13 +50,16 @@ export declare class TreeMultimap<K = any, V = any, N extends TreeMultimapNode<K
50
50
  isNode(exemplar: BTNodeExemplar<K, V, N>): exemplar is N;
51
51
  /**
52
52
  * The function `exemplarToNode` converts an exemplar object into a node object.
53
- * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where `V` represents
54
- * the value type and `N` represents the node type.
53
+ * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, which means it
54
+ * can be one of the following:
55
+ * @param {V} [value] - The `value` parameter is an optional argument that represents the value
56
+ * associated with the node. It is of type `V`, which can be any data type. If no value is provided,
57
+ * it defaults to `undefined`.
55
58
  * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
56
- * times the node should be created. If not provided, it defaults to 1.
57
- * @returns a value of type `N` (the generic type parameter) or `undefined`.
59
+ * times the value should be added to the node. If not provided, it defaults to 1.
60
+ * @returns a node of type `N` or `undefined`.
58
61
  */
59
- exemplarToNode(exemplar: BTNodeExemplar<K, V, N>, count?: number): N | undefined;
62
+ exemplarToNode(exemplar: BTNodeExemplar<K, V, N>, value?: V, count?: number): N | undefined;
60
63
  /**
61
64
  * 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.
62
65
  * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
@@ -65,15 +68,19 @@ export declare class TreeMultimap<K = any, V = any, N extends TreeMultimapNode<K
65
68
  * 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.
66
69
  * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
67
70
  *
68
- * The `add` function overrides the base class `add` function to add a new node to the tree multimap
69
- * and update the count.
70
- * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be one of the following:
71
- * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
72
- * times the key or node or entry should be added to the multimap. If not provided, the default value
73
- * is 1.
74
- * @returns either a node (`N`) or `undefined`.
75
- */
76
- add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, count?: number): N | undefined;
71
+ * The function overrides the add method of a binary tree node and adds a new node to the tree.
72
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be either a key, a node, or an
73
+ * entry. It represents the key, node, or entry that you want to add to the binary tree.
74
+ * @param {V} [value] - The `value` parameter represents the value associated with the key in the
75
+ * binary tree node. It is an optional parameter, meaning it can be omitted when calling the `add`
76
+ * method.
77
+ * @param [count=1] - The `count` parameter represents the number of times the key-value pair should
78
+ * be added to the binary tree. By default, it is set to 1, meaning that the key-value pair will be
79
+ * added once. However, you can specify a different value for `count` if you want to add
80
+ * @returns The method is returning either the newly inserted node or `undefined` if the insertion
81
+ * was not successful.
82
+ */
83
+ add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, value?: V, count?: number): N | undefined;
77
84
  /**
78
85
  * Time Complexity: O(k 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.
79
86
  * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
@@ -62,13 +62,16 @@ class TreeMultimap extends avl_tree_1.AVLTree {
62
62
  }
63
63
  /**
64
64
  * The function `exemplarToNode` converts an exemplar object into a node object.
65
- * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where `V` represents
66
- * the value type and `N` represents the node type.
65
+ * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, which means it
66
+ * can be one of the following:
67
+ * @param {V} [value] - The `value` parameter is an optional argument that represents the value
68
+ * associated with the node. It is of type `V`, which can be any data type. If no value is provided,
69
+ * it defaults to `undefined`.
67
70
  * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
68
- * times the node should be created. If not provided, it defaults to 1.
69
- * @returns a value of type `N` (the generic type parameter) or `undefined`.
71
+ * times the value should be added to the node. If not provided, it defaults to 1.
72
+ * @returns a node of type `N` or `undefined`.
70
73
  */
71
- exemplarToNode(exemplar, count = 1) {
74
+ exemplarToNode(exemplar, value, count = 1) {
72
75
  let node;
73
76
  if (exemplar === undefined || exemplar === null) {
74
77
  return;
@@ -86,7 +89,7 @@ class TreeMultimap extends avl_tree_1.AVLTree {
86
89
  }
87
90
  }
88
91
  else if (this.isNotNodeInstance(exemplar)) {
89
- node = this.createNode(exemplar, undefined, count);
92
+ node = this.createNode(exemplar, value, count);
90
93
  }
91
94
  else {
92
95
  return;
@@ -101,16 +104,20 @@ class TreeMultimap extends avl_tree_1.AVLTree {
101
104
  * 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.
102
105
  * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
103
106
  *
104
- * The `add` function overrides the base class `add` function to add a new node to the tree multimap
105
- * and update the count.
106
- * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be one of the following:
107
- * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
108
- * times the key or node or entry should be added to the multimap. If not provided, the default value
109
- * is 1.
110
- * @returns either a node (`N`) or `undefined`.
107
+ * The function overrides the add method of a binary tree node and adds a new node to the tree.
108
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be either a key, a node, or an
109
+ * entry. It represents the key, node, or entry that you want to add to the binary tree.
110
+ * @param {V} [value] - The `value` parameter represents the value associated with the key in the
111
+ * binary tree node. It is an optional parameter, meaning it can be omitted when calling the `add`
112
+ * method.
113
+ * @param [count=1] - The `count` parameter represents the number of times the key-value pair should
114
+ * be added to the binary tree. By default, it is set to 1, meaning that the key-value pair will be
115
+ * added once. However, you can specify a different value for `count` if you want to add
116
+ * @returns The method is returning either the newly inserted node or `undefined` if the insertion
117
+ * was not successful.
111
118
  */
112
- add(keyOrNodeOrEntry, count = 1) {
113
- const newNode = this.exemplarToNode(keyOrNodeOrEntry, count);
119
+ add(keyOrNodeOrEntry, value, count = 1) {
120
+ const newNode = this.exemplarToNode(keyOrNodeOrEntry, value, count);
114
121
  if (newNode === undefined)
115
122
  return;
116
123
  const orgNodeCount = (newNode === null || newNode === void 0 ? void 0 : newNode.count) || 0;
@@ -163,7 +170,7 @@ class TreeMultimap extends avl_tree_1.AVLTree {
163
170
  return;
164
171
  const m = l + Math.floor((r - l) / 2);
165
172
  const midNode = sorted[m];
166
- this.add([midNode.key, midNode.value], midNode.count);
173
+ this.add(midNode.key, midNode.value, midNode.count);
167
174
  buildBalanceBST(l, m - 1);
168
175
  buildBalanceBST(m + 1, r);
169
176
  };
@@ -179,7 +186,7 @@ class TreeMultimap extends avl_tree_1.AVLTree {
179
186
  if (l <= r) {
180
187
  const m = l + Math.floor((r - l) / 2);
181
188
  const midNode = sorted[m];
182
- this.add([midNode.key, midNode.value], midNode.count);
189
+ this.add(midNode.key, midNode.value, midNode.count);
183
190
  stack.push([m + 1, r]);
184
191
  stack.push([l, m - 1]);
185
192
  }
@@ -293,7 +300,7 @@ class TreeMultimap extends avl_tree_1.AVLTree {
293
300
  */
294
301
  clone() {
295
302
  const cloned = this.createTree();
296
- this.bfs(node => cloned.add([node.key, node.value], node.count));
303
+ this.bfs(node => cloned.add(node.key, node.value, node.count));
297
304
  return cloned;
298
305
  }
299
306
  /**
@@ -1,7 +1,7 @@
1
1
  import type { DijkstraResult, VertexKey } from '../../types';
2
- import { PairCallback } from "../../types";
2
+ import { EntryCallback } from "../../types";
3
3
  import { IGraph } from '../../interfaces';
4
- import { IterablePairBase } from "../base";
4
+ import { IterableEntryBase } from "../base";
5
5
  export declare abstract class AbstractVertex<V = any> {
6
6
  key: VertexKey;
7
7
  value: V | undefined;
@@ -30,10 +30,10 @@ export declare abstract class AbstractEdge<E = any> {
30
30
  protected _hashCode: string;
31
31
  get hashCode(): string;
32
32
  }
33
- export declare abstract class AbstractGraph<V = any, E = any, VO extends AbstractVertex<V> = AbstractVertex<V>, EO extends AbstractEdge<E> = AbstractEdge<E>> extends IterablePairBase<VertexKey, V | undefined> implements IGraph<V, E, VO, EO> {
33
+ export declare abstract class AbstractGraph<V = any, E = any, VO extends AbstractVertex<V> = AbstractVertex<V>, EO extends AbstractEdge<E> = AbstractEdge<E>> extends IterableEntryBase<VertexKey, V | undefined> implements IGraph<V, E, VO, EO> {
34
34
  constructor();
35
- protected _vertices: Map<VertexKey, VO>;
36
- get vertices(): Map<VertexKey, VO>;
35
+ protected _vertexMap: Map<VertexKey, VO>;
36
+ get vertexMap(): Map<VertexKey, VO>;
37
37
  /**
38
38
  * In TypeScript, a subclass inherits the interface implementation of its parent class, without needing to implement the same interface again in the subclass. This behavior differs from Java's approach. In Java, if a parent class implements an interface, the subclass needs to explicitly implement the same interface, even if the parent class has already implemented it.
39
39
  * 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.
@@ -67,8 +67,8 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
67
67
  *
68
68
  * The function "getVertex" returns the vertex with the specified ID or undefined if it doesn't exist.
69
69
  * @param {VertexKey} vertexKey - The `vertexKey` parameter is the identifier of the vertex that you want to retrieve from
70
- * the `_vertices` map.
71
- * @returns The method `getVertex` returns the vertex with the specified `vertexKey` if it exists in the `_vertices`
70
+ * the `_vertexMap` map.
71
+ * @returns The method `getVertex` returns the vertex with the specified `vertexKey` if it exists in the `_vertexMap`
72
72
  * map. If the vertex does not exist, it returns `undefined`.
73
73
  */
74
74
  getVertex(vertexKey: VertexKey): VO | undefined;
@@ -104,20 +104,20 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
104
104
  */
105
105
  deleteVertex(vertexOrKey: VO | VertexKey): boolean;
106
106
  /**
107
- * Time Complexity: O(K), where K is the number of vertices to be removed.
107
+ * Time Complexity: O(K), where K is the number of vertexMap to be removed.
108
108
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
109
109
  */
110
110
  /**
111
- * Time Complexity: O(K), where K is the number of vertices to be removed.
111
+ * Time Complexity: O(K), where K is the number of vertexMap to be removed.
112
112
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
113
113
  *
114
- * The function removes all vertices from a graph and returns a boolean indicating if any vertices were removed.
115
- * @param {VO[] | VertexKey[]} vertices - The `vertices` parameter can be either an array of vertices (`VO[]`) or an array
114
+ * The function removes all vertexMap from a graph and returns a boolean indicating if any vertexMap were removed.
115
+ * @param {VO[] | VertexKey[]} vertexMap - The `vertexMap` parameter can be either an array of vertexMap (`VO[]`) or an array
116
116
  * of vertex IDs (`VertexKey[]`).
117
- * @returns a boolean value. It returns true if at least one vertex was successfully removed, and false if no vertices
117
+ * @returns a boolean value. It returns true if at least one vertex was successfully removed, and false if no vertexMap
118
118
  * were removed.
119
119
  */
120
- removeManyVertices(vertices: VO[] | VertexKey[]): boolean;
120
+ removeManyVertices(vertexMap: VO[] | VertexKey[]): boolean;
121
121
  /**
122
122
  * Time Complexity: O(1) - Depends on the implementation in the concrete class.
123
123
  * Space Complexity: O(1) - Depends on the implementation in the concrete class.
@@ -126,7 +126,7 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
126
126
  * Time Complexity: O(1) - Depends on the implementation in the concrete class.
127
127
  * Space Complexity: O(1) - Depends on the implementation in the concrete class.
128
128
  *
129
- * The function checks if there is an edge between two vertices and returns a boolean value indicating the result.
129
+ * The function checks if there is an edge between two vertexMap and returns a boolean value indicating the result.
130
130
  * @param {VertexKey | VO} v1 - The parameter v1 can be either a VertexKey or a VO. A VertexKey represents the unique
131
131
  * identifier of a vertex in a graph, while VO represents the type of the vertex object itself.
132
132
  * @param {VertexKey | VO} v2 - The parameter `v2` represents the second vertex in the edge. It can be either a
@@ -144,14 +144,14 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
144
144
  * Time Complexity: O(1) - Constant time for Map and Edge operations.
145
145
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
146
146
  *
147
- * The function sets the weight of an edge between two vertices in a graph.
147
+ * The function sets the weight of an edge between two vertexMap in a graph.
148
148
  * @param {VertexKey | VO} srcOrKey - The `srcOrKey` parameter can be either a `VertexKey` or a `VO` object. It represents
149
149
  * the source vertex of the edge.
150
150
  * @param {VertexKey | VO} destOrKey - The `destOrKey` parameter represents the destination vertex of the edge. It can be
151
151
  * either a `VertexKey` or a vertex object `VO`.
152
152
  * @param {number} weight - The weight parameter represents the weight of the edge between the source vertex (srcOrKey)
153
153
  * and the destination vertex (destOrKey).
154
- * @returns a boolean value. If the edge exists between the source and destination vertices, the function will update
154
+ * @returns a boolean value. If the edge exists between the source and destination vertexMap, the function will update
155
155
  * the weight of the edge and return true. If the edge does not exist, the function will return false.
156
156
  */
157
157
  setEdgeWeight(srcOrKey: VertexKey | VO, destOrKey: VertexKey | VO, weight: number): boolean;
@@ -163,12 +163,12 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
163
163
  * Time Complexity: O(P), where P is the number of paths found (in the worst case, exploring all paths).
164
164
  * Space Complexity: O(P) - Linear space, where P is the number of paths found.
165
165
  *
166
- * The function `getAllPathsBetween` finds all paths between two vertices in a graph using depth-first search.
166
+ * The function `getAllPathsBetween` finds all paths between two vertexMap in a graph using depth-first search.
167
167
  * @param {VO | VertexKey} v1 - The parameter `v1` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).
168
168
  * It is the starting vertex for finding paths.
169
169
  * @param {VO | VertexKey} v2 - The parameter `v2` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).
170
170
  * @param limit - The count of limitation of result array.
171
- * @returns The function `getAllPathsBetween` returns an array of arrays of vertices (`VO[][]`).
171
+ * @returns The function `getAllPathsBetween` returns an array of arrays of vertexMap (`VO[][]`).
172
172
  */
173
173
  getAllPathsBetween(v1: VO | VertexKey, v2: VO | VertexKey, limit?: number): VO[][];
174
174
  /**
@@ -180,8 +180,8 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
180
180
  * Space Complexity: O(1) - Constant space.
181
181
  *
182
182
  * The function calculates the sum of weights along a given path.
183
- * @param {VO[]} path - An array of vertices (VO) representing a path in a graph.
184
- * @returns The function `getPathSumWeight` returns the sum of the weights of the edges in the given path.
183
+ * @param {VO[]} path - An array of vertexMap (VO) representing a path in a graph.
184
+ * @returns The function `getPathSumWeight` returns the sum of the weights of the edgeMap in the given path.
185
185
  */
186
186
  getPathSumWeight(path: VO[]): number;
187
187
  /**
@@ -192,17 +192,17 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
192
192
  * Time Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
193
193
  * Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
194
194
  *
195
- * The function `getMinCostBetween` calculates the minimum cost between two vertices in a graph, either based on edge
195
+ * The function `getMinCostBetween` calculates the minimum cost between two vertexMap in a graph, either based on edge
196
196
  * weights or using a breadth-first search algorithm.
197
197
  * @param {VO | VertexKey} v1 - The parameter `v1` represents the starting vertex or its ID.
198
198
  * @param {VO | VertexKey} v2 - The parameter `v2` represents the destination vertex or its ID. It is the vertex to which
199
199
  * you want to find the minimum cost or weight from the source vertex `v1`.
200
- * @param {boolean} [isWeight] - isWeight is an optional parameter that indicates whether the graph edges have weights.
200
+ * @param {boolean} [isWeight] - isWeight is an optional parameter that indicates whether the graph edgeMap have weights.
201
201
  * If isWeight is set to true, the function will calculate the minimum cost between v1 and v2 based on the weights of
202
- * the edges. If isWeight is set to false or not provided, the function will calculate the
203
- * @returns The function `getMinCostBetween` returns a number representing the minimum cost between two vertices (`v1`
202
+ * the edgeMap. If isWeight is set to false or not provided, the function will calculate the
203
+ * @returns The function `getMinCostBetween` returns a number representing the minimum cost between two vertexMap (`v1`
204
204
  * and `v2`). If the `isWeight` parameter is `true`, it calculates the minimum weight among all paths between the
205
- * vertices. If `isWeight` is `false` or not provided, it uses a breadth-first search (BFS) algorithm to calculate the
205
+ * vertexMap. If `isWeight` is `false` or not provided, it uses a breadth-first search (BFS) algorithm to calculate the
206
206
  * minimum number of
207
207
  */
208
208
  getMinCostBetween(v1: VO | VertexKey, v2: VO | VertexKey, isWeight?: boolean): number | undefined;
@@ -214,20 +214,20 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
214
214
  * Time Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm or DFS).
215
215
  * Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm or DFS).
216
216
  *
217
- * The function `getMinPathBetween` returns the minimum path between two vertices in a graph, either based on weight or
217
+ * The function `getMinPathBetween` returns the minimum path between two vertexMap in a graph, either based on weight or
218
218
  * using a breadth-first search algorithm.
219
219
  * @param {VO | VertexKey} v1 - The parameter `v1` represents the starting vertex of the path. It can be either a vertex
220
220
  * object (`VO`) or a vertex ID (`VertexKey`).
221
221
  * @param {VO | VertexKey} v2 - VO | VertexKey - The second vertex or vertex ID between which we want to find the minimum
222
222
  * path.
223
- * @param {boolean} [isWeight] - A boolean flag indicating whether to consider the weight of edges in finding the
223
+ * @param {boolean} [isWeight] - A boolean flag indicating whether to consider the weight of edgeMap in finding the
224
224
  * minimum path. If set to true, the function will use Dijkstra's algorithm to find the minimum weighted path. If set
225
225
  * to false, the function will use breadth-first search (BFS) to find the minimum path.
226
226
  * @param isDFS - If set to true, it enforces the use of getAllPathsBetween to first obtain all possible paths,
227
227
  * followed by iterative computation of the shortest path. This approach may result in exponential time complexity,
228
228
  * so the default method is to use the Dijkstra algorithm to obtain the shortest weighted path.
229
- * @returns The function `getMinPathBetween` returns an array of vertices (`VO[]`) representing the minimum path between
230
- * two vertices (`v1` and `v2`). If there is no path between the vertices, it returns `undefined`.
229
+ * @returns The function `getMinPathBetween` returns an array of vertexMap (`VO[]`) representing the minimum path between
230
+ * two vertexMap (`v1` and `v2`). If there is no path between the vertexMap, it returns `undefined`.
231
231
  */
232
232
  getMinPathBetween(v1: VO | VertexKey, v2: VO | VertexKey, isWeight?: boolean, isDFS?: boolean): VO[] | undefined;
233
233
  /**
@@ -242,7 +242,7 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
242
242
  * Time Complexity: O(V^2 + E) - Quadratic time in the worst case (no heap optimization).
243
243
  * Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
244
244
  *
245
- * The function `dijkstraWithoutHeap` implements Dijkstra's algorithm to find the shortest path between two vertices in
245
+ * The function `dijkstraWithoutHeap` implements Dijkstra's algorithm to find the shortest path between two vertexMap in
246
246
  * a graph without using a heap data structure.
247
247
  * @param {VO | VertexKey} src - The source vertex from which to start the Dijkstra's algorithm. It can be either a
248
248
  * vertex object or a vertex ID.
@@ -254,7 +254,7 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
254
254
  * `getMinDist` is set to `true`, the `minDist` property in the result will contain the minimum distance
255
255
  * @param {boolean} [genPaths] - The `genPaths` parameter is a boolean flag that determines whether or not to generate
256
256
  * paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
257
- * shortest paths from the source vertex to all other vertices in the graph. If `genPaths
257
+ * shortest paths from the source vertex to all other vertexMap in the graph. If `genPaths
258
258
  * @returns The function `dijkstraWithoutHeap` returns an object of type `DijkstraResult<VO>`.
259
259
  */
260
260
  dijkstraWithoutHeap(src: VO | VertexKey, dest?: VO | VertexKey | undefined, getMinDist?: boolean, genPaths?: boolean): DijkstraResult<VO>;
@@ -262,7 +262,7 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
262
262
  * Dijkstra algorithm time: O(logVE) space: O(VO + EO)
263
263
  *
264
264
  * 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.
265
- * 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.
265
+ * 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.
266
266
  * 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.
267
267
  *
268
268
  * /
@@ -282,13 +282,13 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
282
282
  * start. It can be either a vertex object or a vertex ID.
283
283
  * @param {VO | VertexKey | undefined} [dest] - The `dest` parameter is the destination vertex or vertex ID. It specifies the
284
284
  * vertex to which the shortest path is calculated from the source vertex. If no destination is provided, the algorithm
285
- * will calculate the shortest paths to all other vertices from the source vertex.
285
+ * will calculate the shortest paths to all other vertexMap from the source vertex.
286
286
  * @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum
287
287
  * distance from the source vertex to the destination vertex should be calculated and returned in the result. If
288
288
  * `getMinDist` is set to `true`, the `minDist` property in the result will contain the minimum distance
289
289
  * @param {boolean} [genPaths] - The `genPaths` parameter is a boolean flag that determines whether or not to generate
290
290
  * paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
291
- * shortest paths from the source vertex to all other vertices in the graph. If `genPaths
291
+ * shortest paths from the source vertex to all other vertexMap in the graph. If `genPaths
292
292
  * @returns The function `dijkstra` returns an object of type `DijkstraResult<VO>`.
293
293
  */
294
294
  dijkstra(src: VO | VertexKey, dest?: VO | VertexKey | undefined, getMinDist?: boolean, genPaths?: boolean): DijkstraResult<VO>;
@@ -303,16 +303,16 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
303
303
  * Space Complexity: O(V + E) - Depends on the implementation (Bellman-Ford algorithm).
304
304
  *
305
305
  * one to rest pairs
306
- * 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.
306
+ * 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.
307
307
  * The `bellmanFord` function implements the Bellman-Ford algorithm to find the shortest path from a source vertex to
308
- * all other vertices in a graph, and optionally detects negative cycles and generates the minimum path.
308
+ * all other vertexMap in a graph, and optionally detects negative cycles and generates the minimum path.
309
309
  * @param {VO | VertexKey} src - The `src` parameter is the source vertex from which the Bellman-Ford algorithm will
310
310
  * start calculating the shortest paths. It can be either a vertex object or a vertex ID.
311
311
  * @param {boolean} [scanNegativeCycle] - A boolean flag indicating whether to scan for negative cycles in the graph.
312
312
  * @param {boolean} [getMin] - The `getMin` parameter is a boolean flag that determines whether the algorithm should
313
- * calculate the minimum distance from the source vertex to all other vertices in the graph. If `getMin` is set to
313
+ * calculate the minimum distance from the source vertex to all other vertexMap in the graph. If `getMin` is set to
314
314
  * `true`, the algorithm will find the minimum distance and update the `min` variable with the minimum
315
- * @param {boolean} [genPath] - A boolean flag indicating whether to generate paths for all vertices from the source
315
+ * @param {boolean} [genPath] - A boolean flag indicating whether to generate paths for all vertexMap from the source
316
316
  * vertex.
317
317
  * @returns The function `bellmanFord` returns an object with the following properties:
318
318
  */
@@ -335,7 +335,7 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
335
335
  /**
336
336
  * BellmanFord time:O(VE) space:O(VO)
337
337
  * one to rest pairs
338
- * 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.
338
+ * 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.
339
339
  * The `bellmanFord` function implements the Bellman-Ford algorithm to find the shortest path from a source vertex to
340
340
  */
341
341
  /**
@@ -343,7 +343,7 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
343
343
  * Space Complexity: O(V^2) - Quadratic space (Floyd-Warshall algorithm).
344
344
  * Not support graph with negative weight cycle
345
345
  * all pairs
346
- * 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.
346
+ * 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.
347
347
  * /
348
348
 
349
349
  /**
@@ -352,13 +352,13 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
352
352
  *
353
353
  * Not support graph with negative weight cycle
354
354
  * all pairs
355
- * 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.
356
- * The function implements the Floyd-Warshall algorithm to find the shortest path between all pairs of vertices in a
355
+ * 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.
356
+ * The function implements the Floyd-Warshall algorithm to find the shortest path between all pairs of vertexMap in a
357
357
  * graph.
358
358
  * @returns The function `floydWarshall()` returns an object with two properties: `costs` and `predecessor`. The `costs`
359
- * property is a 2D array of numbers representing the shortest path costs between vertices in a graph. The
360
- * `predecessor` property is a 2D array of vertices (or `undefined`) representing the predecessor vertices in the shortest
361
- * path between vertices in the
359
+ * property is a 2D array of numbers representing the shortest path costs between vertexMap in a graph. The
360
+ * `predecessor` property is a 2D array of vertexMap (or `undefined`) representing the predecessor vertexMap in the shortest
361
+ * path between vertexMap in the
362
362
  */
363
363
  floydWarshall(): {
364
364
  costs: number[][];
@@ -369,7 +369,7 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
369
369
  * Space Complexity: O(V) - Linear space (Tarjan's algorithm).
370
370
  * Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
371
371
  * Tarjan can find cycles in directed or undirected graph
372
- * Tarjan can find the articulation points and bridges(critical edges) of undirected graphs in linear time,
372
+ * Tarjan can find the articulation points and bridges(critical edgeMap) of undirected graphs in linear time,
373
373
  * Tarjan solve the bi-connected components of undirected graphs;
374
374
  * Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs.
375
375
  * /
@@ -380,22 +380,22 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
380
380
  *
381
381
  * Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
382
382
  * Tarjan can find cycles in directed or undirected graph
383
- * Tarjan can find the articulation points and bridges(critical edges) of undirected graphs in linear time,
383
+ * Tarjan can find the articulation points and bridges(critical edgeMap) of undirected graphs in linear time,
384
384
  * Tarjan solve the bi-connected components of undirected graphs;
385
385
  * Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs.
386
386
  * The `tarjan` function is used to perform various graph analysis tasks such as finding articulation points, bridges,
387
387
  * strongly connected components (SCCs), and cycles in a graph.
388
388
  * @param {boolean} [needCutVertexes] - A boolean value indicating whether or not to calculate and return the
389
- * articulation points in the graph. Articulation points are the vertices in a graph whose removal would increase the
389
+ * articulation points in the graph. Articulation points are the vertexMap in a graph whose removal would increase the
390
390
  * number of connected components in the graph.
391
391
  * @param {boolean} [needBridges] - A boolean flag indicating whether the algorithm should find and return the bridges
392
- * (edges whose removal would increase the number of connected components in the graph).
392
+ * (edgeMap whose removal would increase the number of connected components in the graph).
393
393
  * @param {boolean} [needSCCs] - A boolean value indicating whether the Strongly Connected Components (SCCs) of the
394
394
  * graph are needed. If set to true, the function will calculate and return the SCCs of the graph. If set to false, the
395
395
  * SCCs will not be calculated or returned.
396
396
  * @param {boolean} [needCycles] - A boolean flag indicating whether the algorithm should find cycles in the graph. If
397
397
  * set to true, the algorithm will return a map of cycles, where the keys are the low values of the SCCs and the values
398
- * are arrays of vertices that form cycles within the SCCs.
398
+ * are arrays of vertexMap that form cycles within the SCCs.
399
399
  * @returns The function `tarjan` returns an object with the following properties:
400
400
  */
401
401
  tarjan(needCutVertexes?: boolean, needBridges?: boolean, needSCCs?: boolean, needCycles?: boolean): {
@@ -467,7 +467,7 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
467
467
  * @returns The `filter` method returns an array of key-value pairs `[VertexKey, V | undefined][]`
468
468
  * that satisfy the given predicate function.
469
469
  */
470
- filter(predicate: PairCallback<VertexKey, V | undefined, boolean>, thisArg?: any): [VertexKey, V | undefined][];
470
+ filter(predicate: EntryCallback<VertexKey, V | undefined, boolean>, thisArg?: any): [VertexKey, V | undefined][];
471
471
  /**
472
472
  * Time Complexity: O(n)
473
473
  * Space Complexity: O(n)
@@ -485,7 +485,7 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
485
485
  * used as the `this` value when calling the callback function. If `thisArg` is not provided, `
486
486
  * @returns The `map` function is returning an array of type `T[]`.
487
487
  */
488
- map<T>(callback: PairCallback<VertexKey, V | undefined, T>, thisArg?: any): T[];
488
+ map<T>(callback: EntryCallback<VertexKey, V | undefined, T>, thisArg?: any): T[];
489
489
  protected _getIterator(): IterableIterator<[VertexKey, V | undefined]>;
490
490
  protected abstract _addEdgeOnly(edge: EO): boolean;
491
491
  protected _addVertexOnly(newVertex: VO): boolean;