data-structure-typed 1.39.4 → 1.39.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 (111) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +6 -6
  3. package/dist/cjs/data-structures/binary-tree/avl-tree.js +13 -13
  4. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  5. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +7 -7
  6. package/dist/cjs/data-structures/binary-tree/binary-tree.js +17 -17
  7. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  8. package/dist/cjs/data-structures/binary-tree/bst.d.ts +6 -6
  9. package/dist/cjs/data-structures/binary-tree/bst.js +13 -13
  10. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  11. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +2 -2
  12. package/dist/cjs/data-structures/binary-tree/rb-tree.js +4 -4
  13. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  14. package/dist/cjs/data-structures/binary-tree/segment-tree.d.ts +7 -7
  15. package/dist/cjs/data-structures/binary-tree/segment-tree.js +16 -16
  16. package/dist/cjs/data-structures/binary-tree/segment-tree.js.map +1 -1
  17. package/dist/cjs/data-structures/binary-tree/tree-multiset.d.ts +6 -6
  18. package/dist/cjs/data-structures/binary-tree/tree-multiset.js +18 -18
  19. package/dist/cjs/data-structures/binary-tree/tree-multiset.js.map +1 -1
  20. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +96 -96
  21. package/dist/cjs/data-structures/graph/abstract-graph.js +64 -64
  22. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  23. package/dist/cjs/data-structures/graph/directed-graph.d.ts +68 -68
  24. package/dist/cjs/data-structures/graph/directed-graph.js +48 -48
  25. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  26. package/dist/cjs/data-structures/graph/map-graph.d.ts +13 -13
  27. package/dist/cjs/data-structures/graph/map-graph.js +15 -15
  28. package/dist/cjs/data-structures/graph/map-graph.js.map +1 -1
  29. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +42 -42
  30. package/dist/cjs/data-structures/graph/undirected-graph.js +32 -32
  31. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  32. package/dist/cjs/data-structures/hash/hash-table.d.ts +4 -4
  33. package/dist/cjs/data-structures/hash/hash-table.js +8 -8
  34. package/dist/cjs/data-structures/hash/hash-table.js.map +1 -1
  35. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +31 -31
  36. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +54 -54
  37. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  38. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +24 -24
  39. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +52 -52
  40. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  41. package/dist/cjs/data-structures/queue/queue.d.ts +1 -1
  42. package/dist/cjs/data-structures/queue/queue.js +4 -4
  43. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  44. package/dist/cjs/interfaces/binary-tree.d.ts +2 -2
  45. package/dist/cjs/interfaces/graph.d.ts +3 -3
  46. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +6 -6
  47. package/dist/mjs/data-structures/binary-tree/avl-tree.js +13 -13
  48. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +7 -7
  49. package/dist/mjs/data-structures/binary-tree/binary-tree.js +18 -18
  50. package/dist/mjs/data-structures/binary-tree/bst.d.ts +6 -6
  51. package/dist/mjs/data-structures/binary-tree/bst.js +13 -13
  52. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +2 -2
  53. package/dist/mjs/data-structures/binary-tree/rb-tree.js +4 -4
  54. package/dist/mjs/data-structures/binary-tree/segment-tree.d.ts +7 -7
  55. package/dist/mjs/data-structures/binary-tree/segment-tree.js +16 -16
  56. package/dist/mjs/data-structures/binary-tree/tree-multiset.d.ts +6 -6
  57. package/dist/mjs/data-structures/binary-tree/tree-multiset.js +18 -18
  58. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +96 -96
  59. package/dist/mjs/data-structures/graph/abstract-graph.js +66 -66
  60. package/dist/mjs/data-structures/graph/directed-graph.d.ts +68 -68
  61. package/dist/mjs/data-structures/graph/directed-graph.js +48 -48
  62. package/dist/mjs/data-structures/graph/map-graph.d.ts +13 -13
  63. package/dist/mjs/data-structures/graph/map-graph.js +15 -15
  64. package/dist/mjs/data-structures/graph/undirected-graph.d.ts +42 -42
  65. package/dist/mjs/data-structures/graph/undirected-graph.js +32 -32
  66. package/dist/mjs/data-structures/hash/hash-table.d.ts +4 -4
  67. package/dist/mjs/data-structures/hash/hash-table.js +9 -9
  68. package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +31 -31
  69. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +55 -55
  70. package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +24 -24
  71. package/dist/mjs/data-structures/linked-list/singly-linked-list.js +53 -53
  72. package/dist/mjs/data-structures/queue/queue.d.ts +1 -1
  73. package/dist/mjs/data-structures/queue/queue.js +4 -4
  74. package/dist/mjs/interfaces/binary-tree.d.ts +2 -2
  75. package/dist/mjs/interfaces/graph.d.ts +3 -3
  76. package/dist/umd/data-structure-typed.min.js +1 -1
  77. package/dist/umd/data-structure-typed.min.js.map +1 -1
  78. package/package.json +5 -5
  79. package/src/data-structures/binary-tree/avl-tree.ts +13 -13
  80. package/src/data-structures/binary-tree/binary-tree.ts +18 -18
  81. package/src/data-structures/binary-tree/bst.ts +16 -16
  82. package/src/data-structures/binary-tree/rb-tree.ts +6 -6
  83. package/src/data-structures/binary-tree/segment-tree.ts +15 -15
  84. package/src/data-structures/binary-tree/tree-multiset.ts +18 -18
  85. package/src/data-structures/graph/abstract-graph.ts +156 -154
  86. package/src/data-structures/graph/directed-graph.ts +99 -94
  87. package/src/data-structures/graph/map-graph.ts +22 -25
  88. package/src/data-structures/graph/undirected-graph.ts +62 -60
  89. package/src/data-structures/hash/hash-table.ts +9 -9
  90. package/src/data-structures/linked-list/doubly-linked-list.ts +61 -61
  91. package/src/data-structures/linked-list/singly-linked-list.ts +58 -58
  92. package/src/data-structures/queue/queue.ts +2 -2
  93. package/src/interfaces/binary-tree.ts +2 -2
  94. package/src/interfaces/graph.ts +3 -3
  95. package/test/integration/bst.test.ts +2 -2
  96. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +2 -2
  97. package/test/unit/data-structures/binary-tree/binary-index-tree.test.ts +3 -3
  98. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +8 -8
  99. package/test/unit/data-structures/binary-tree/bst.test.ts +4 -4
  100. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +3 -3
  101. package/test/unit/data-structures/binary-tree/tree-multiset.test.ts +2 -2
  102. package/test/unit/data-structures/graph/abstract-graph.test.ts +99 -2
  103. package/test/unit/data-structures/graph/directed-graph.test.ts +38 -23
  104. package/test/unit/data-structures/graph/map-graph.test.ts +23 -23
  105. package/test/unit/data-structures/graph/undirected-graph.test.ts +10 -2
  106. package/test/unit/data-structures/hash/hash-table.test.ts +1 -1
  107. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +30 -30
  108. package/test/unit/data-structures/linked-list/linked-list.test.ts +1 -1
  109. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +15 -15
  110. package/test/unit/data-structures/queue/queue.test.ts +8 -8
  111. package/test/utils/big-o.ts +7 -7
@@ -16,12 +16,12 @@ class AbstractVertex {
16
16
  * The function is a protected constructor that takes an key and an optional value as parameters.
17
17
  * @param {VertexKey} key - The `key` parameter is of type `VertexKey` and represents the identifier of the vertex. It is
18
18
  * used to uniquely identify the vertex object.
19
- * @param {V} [val] - The parameter "val" is an optional parameter of type V. It is used to assign a value to the
19
+ * @param {V} [value] - The parameter "value" is an optional parameter of type V. It is used to assign a value to the
20
20
  * vertex. If no value is provided, it will be set to undefined.
21
21
  */
22
- constructor(key, val) {
22
+ constructor(key, value) {
23
23
  this._key = key;
24
- this._val = val;
24
+ this._value = value;
25
25
  }
26
26
  _key;
27
27
  get key() {
@@ -30,12 +30,12 @@ class AbstractVertex {
30
30
  set key(v) {
31
31
  this._key = v;
32
32
  }
33
- _val;
34
- get val() {
35
- return this._val;
33
+ _value;
34
+ get value() {
35
+ return this._value;
36
36
  }
37
- set val(value) {
38
- this._val = value;
37
+ set value(value) {
38
+ this._value = value;
39
39
  }
40
40
  }
41
41
  exports.AbstractVertex = AbstractVertex;
@@ -46,20 +46,20 @@ class AbstractEdge {
46
46
  * @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the object. If
47
47
  * a value is provided, it will be assigned to the `_weight` property. If no value is provided, the default value of 1
48
48
  * will be assigned.
49
- * @param {V} [val] - The `val` parameter is of type `V`, which means it can be any type. It is an optional parameter,
49
+ * @param {VO} [value] - The `value` parameter is of type `VO`, which means it can be any type. It is an optional parameter,
50
50
  * meaning it can be omitted when creating an instance of the class.
51
51
  */
52
- constructor(weight, val) {
52
+ constructor(weight, value) {
53
53
  this._weight = weight !== undefined ? weight : 1;
54
- this._val = val;
54
+ this._value = value;
55
55
  this._hashCode = (0, utils_1.uuidV4)();
56
56
  }
57
- _val;
58
- get val() {
59
- return this._val;
57
+ _value;
58
+ get value() {
59
+ return this._value;
60
60
  }
61
- set val(value) {
62
- this._val = value;
61
+ set value(value) {
62
+ this._value = value;
63
63
  }
64
64
  _weight;
65
65
  get weight() {
@@ -103,25 +103,25 @@ class AbstractGraph {
103
103
  }
104
104
  /**
105
105
  * The function checks if a vertex exists in a graph.
106
- * @param {V | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`V`) or a vertex ID
106
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
107
107
  * (`VertexKey`).
108
108
  * @returns a boolean value.
109
109
  */
110
110
  hasVertex(vertexOrKey) {
111
111
  return this._vertices.has(this._getVertexKey(vertexOrKey));
112
112
  }
113
- addVertex(keyOrVertex, val) {
113
+ addVertex(keyOrVertex, value) {
114
114
  if (keyOrVertex instanceof AbstractVertex) {
115
115
  return this._addVertexOnly(keyOrVertex);
116
116
  }
117
117
  else {
118
- const newVertex = this.createVertex(keyOrVertex, val);
118
+ const newVertex = this.createVertex(keyOrVertex, value);
119
119
  return this._addVertexOnly(newVertex);
120
120
  }
121
121
  }
122
122
  /**
123
123
  * The `deleteVertex` function removes a vertex from a graph by its ID or by the vertex object itself.
124
- * @param {V | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`V`) or a vertex ID
124
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
125
125
  * (`VertexKey`).
126
126
  * @returns The method is returning a boolean value.
127
127
  */
@@ -131,7 +131,7 @@ class AbstractGraph {
131
131
  }
132
132
  /**
133
133
  * The function removes all vertices from a graph and returns a boolean indicating if any vertices were removed.
134
- * @param {V[] | VertexKey[]} vertices - The `vertices` parameter can be either an array of vertices (`V[]`) or an array
134
+ * @param {VO[] | VertexKey[]} vertices - The `vertices` parameter can be either an array of vertices (`VO[]`) or an array
135
135
  * of vertex IDs (`VertexKey[]`).
136
136
  * @returns a boolean value. It returns true if at least one vertex was successfully removed, and false if no vertices
137
137
  * were removed.
@@ -145,17 +145,17 @@ class AbstractGraph {
145
145
  }
146
146
  /**
147
147
  * The function checks if there is an edge between two vertices and returns a boolean value indicating the result.
148
- * @param {VertexKey | V} v1 - The parameter v1 can be either a VertexKey or a V. A VertexKey represents the unique
149
- * identifier of a vertex in a graph, while V represents the type of the vertex object itself.
150
- * @param {VertexKey | V} v2 - The parameter `v2` represents the second vertex in the edge. It can be either a
151
- * `VertexKey` or a `V` type, which represents the type of the vertex.
148
+ * @param {VertexKey | VO} v1 - The parameter v1 can be either a VertexKey or a VO. A VertexKey represents the unique
149
+ * identifier of a vertex in a graph, while VO represents the type of the vertex object itself.
150
+ * @param {VertexKey | VO} v2 - The parameter `v2` represents the second vertex in the edge. It can be either a
151
+ * `VertexKey` or a `VO` type, which represents the type of the vertex.
152
152
  * @returns A boolean value is being returned.
153
153
  */
154
154
  hasEdge(v1, v2) {
155
155
  const edge = this.getEdge(v1, v2);
156
156
  return !!edge;
157
157
  }
158
- addEdge(srcOrEdge, dest, weight, val) {
158
+ addEdge(srcOrEdge, dest, weight, value) {
159
159
  if (srcOrEdge instanceof AbstractEdge) {
160
160
  return this._addEdgeOnly(srcOrEdge);
161
161
  }
@@ -167,7 +167,7 @@ class AbstractGraph {
167
167
  srcOrEdge = srcOrEdge.key;
168
168
  if (dest instanceof AbstractVertex)
169
169
  dest = dest.key;
170
- const newEdge = this.createEdge(srcOrEdge, dest, weight, val);
170
+ const newEdge = this.createEdge(srcOrEdge, dest, weight, value);
171
171
  return this._addEdgeOnly(newEdge);
172
172
  }
173
173
  else {
@@ -177,10 +177,10 @@ class AbstractGraph {
177
177
  }
178
178
  /**
179
179
  * The function sets the weight of an edge between two vertices in a graph.
180
- * @param {VertexKey | V} srcOrKey - The `srcOrKey` parameter can be either a `VertexKey` or a `V` object. It represents
180
+ * @param {VertexKey | VO} srcOrKey - The `srcOrKey` parameter can be either a `VertexKey` or a `VO` object. It represents
181
181
  * the source vertex of the edge.
182
- * @param {VertexKey | V} destOrKey - The `destOrKey` parameter represents the destination vertex of the edge. It can be
183
- * either a `VertexKey` or a vertex object `V`.
182
+ * @param {VertexKey | VO} destOrKey - The `destOrKey` parameter represents the destination vertex of the edge. It can be
183
+ * either a `VertexKey` or a vertex object `VO`.
184
184
  * @param {number} weight - The weight parameter represents the weight of the edge between the source vertex (srcOrKey)
185
185
  * and the destination vertex (destOrKey).
186
186
  * @returns a boolean value. If the edge exists between the source and destination vertices, the function will update
@@ -198,10 +198,10 @@ class AbstractGraph {
198
198
  }
199
199
  /**
200
200
  * The function `getAllPathsBetween` finds all paths between two vertices in a graph using depth-first search.
201
- * @param {V | VertexKey} v1 - The parameter `v1` represents either a vertex object (`V`) or a vertex ID (`VertexKey`).
201
+ * @param {VO | VertexKey} v1 - The parameter `v1` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).
202
202
  * It is the starting vertex for finding paths.
203
- * @param {V | VertexKey} v2 - The parameter `v2` represents either a vertex object (`V`) or a vertex ID (`VertexKey`).
204
- * @returns The function `getAllPathsBetween` returns an array of arrays of vertices (`V[][]`).
203
+ * @param {VO | VertexKey} v2 - The parameter `v2` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).
204
+ * @returns The function `getAllPathsBetween` returns an array of arrays of vertices (`VO[][]`).
205
205
  */
206
206
  getAllPathsBetween(v1, v2) {
207
207
  const paths = [];
@@ -230,7 +230,7 @@ class AbstractGraph {
230
230
  }
231
231
  /**
232
232
  * The function calculates the sum of weights along a given path.
233
- * @param {V[]} path - An array of vertices (V) representing a path in a graph.
233
+ * @param {VO[]} path - An array of vertices (VO) representing a path in a graph.
234
234
  * @returns The function `getPathSumWeight` returns the sum of the weights of the edges in the given path.
235
235
  */
236
236
  getPathSumWeight(path) {
@@ -243,8 +243,8 @@ class AbstractGraph {
243
243
  /**
244
244
  * The function `getMinCostBetween` calculates the minimum cost between two vertices in a graph, either based on edge
245
245
  * weights or using a breadth-first search algorithm.
246
- * @param {V | VertexKey} v1 - The parameter `v1` represents the starting vertex or its ID.
247
- * @param {V | VertexKey} v2 - The parameter `v2` represents the destination vertex or its ID. It is the vertex to which
246
+ * @param {VO | VertexKey} v1 - The parameter `v1` represents the starting vertex or its ID.
247
+ * @param {VO | VertexKey} v2 - The parameter `v2` represents the destination vertex or its ID. It is the vertex to which
248
248
  * you want to find the minimum cost or weight from the source vertex `v1`.
249
249
  * @param {boolean} [isWeight] - isWeight is an optional parameter that indicates whether the graph edges have weights.
250
250
  * If isWeight is set to true, the function will calculate the minimum cost between v1 and v2 based on the weights of
@@ -301,14 +301,14 @@ class AbstractGraph {
301
301
  /**
302
302
  * The function `getMinPathBetween` returns the minimum path between two vertices in a graph, either based on weight or
303
303
  * using a breadth-first search algorithm.
304
- * @param {V | VertexKey} v1 - The parameter `v1` represents the starting vertex of the path. It can be either a vertex
305
- * object (`V`) or a vertex ID (`VertexKey`).
306
- * @param {V | VertexKey} v2 - V | VertexKey - The second vertex or vertex ID between which we want to find the minimum
304
+ * @param {VO | VertexKey} v1 - The parameter `v1` represents the starting vertex of the path. It can be either a vertex
305
+ * object (`VO`) or a vertex ID (`VertexKey`).
306
+ * @param {VO | VertexKey} v2 - VO | VertexKey - The second vertex or vertex ID between which we want to find the minimum
307
307
  * path.
308
308
  * @param {boolean} [isWeight] - A boolean flag indicating whether to consider the weight of edges in finding the
309
309
  * minimum path. If set to true, the function will use Dijkstra's algorithm to find the minimum weighted path. If set
310
310
  * to false, the function will use breadth-first search (BFS) to find the minimum path.
311
- * @returns The function `getMinPathBetween` returns an array of vertices (`V[]`) representing the minimum path between
311
+ * @returns The function `getMinPathBetween` returns an array of vertices (`VO[]`) representing the minimum path between
312
312
  * two vertices (`v1` and `v2`). If there is no path between the vertices, it returns `null`.
313
313
  */
314
314
  getMinPathBetween(v1, v2, isWeight) {
@@ -358,16 +358,16 @@ class AbstractGraph {
358
358
  }
359
359
  }
360
360
  /**
361
- * Dijkstra algorithm time: O(VE) space: O(V + E)
361
+ * Dijkstra algorithm time: O(VE) space: O(VO + EO)
362
362
  * /
363
363
 
364
364
  /**
365
- * Dijkstra algorithm time: O(VE) space: O(V + E)
365
+ * Dijkstra algorithm time: O(VE) space: O(VO + EO)
366
366
  * The function `dijkstraWithoutHeap` implements Dijkstra's algorithm to find the shortest path between two vertices in
367
367
  * a graph without using a heap data structure.
368
- * @param {V | VertexKey} src - The source vertex from which to start the Dijkstra's algorithm. It can be either a
368
+ * @param {VO | VertexKey} src - The source vertex from which to start the Dijkstra's algorithm. It can be either a
369
369
  * vertex object or a vertex ID.
370
- * @param {V | VertexKey | null} [dest] - The `dest` parameter in the `dijkstraWithoutHeap` function is an optional
370
+ * @param {VO | VertexKey | null} [dest] - The `dest` parameter in the `dijkstraWithoutHeap` function is an optional
371
371
  * parameter that specifies the destination vertex for the Dijkstra algorithm. It can be either a vertex object or its
372
372
  * identifier. If no destination is provided, the value is set to `null`.
373
373
  * @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum
@@ -376,7 +376,7 @@ class AbstractGraph {
376
376
  * @param {boolean} [genPaths] - The `genPaths` parameter is a boolean flag that determines whether or not to generate
377
377
  * paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
378
378
  * shortest paths from the source vertex to all other vertices in the graph. If `genPaths
379
- * @returns The function `dijkstraWithoutHeap` returns an object of type `DijkstraResult<V>`.
379
+ * @returns The function `dijkstraWithoutHeap` returns an object of type `DijkstraResult<VO>`.
380
380
  */
381
381
  dijkstraWithoutHeap(src, dest, getMinDist, genPaths) {
382
382
  if (getMinDist === undefined)
@@ -408,10 +408,10 @@ class AbstractGraph {
408
408
  const getMinOfNoSeen = () => {
409
409
  let min = Infinity;
410
410
  let minV = null;
411
- for (const [key, val] of distMap) {
411
+ for (const [key, value] of distMap) {
412
412
  if (!seen.has(key)) {
413
- if (val < min) {
414
- min = val;
413
+ if (value < min) {
414
+ min = value;
415
415
  minV = key;
416
416
  }
417
417
  }
@@ -481,11 +481,11 @@ class AbstractGraph {
481
481
  return { distMap, preMap, seen, paths, minDist, minPath };
482
482
  }
483
483
  /**
484
- * Dijkstra algorithm time: O(logVE) space: O(V + E)
484
+ * Dijkstra algorithm time: O(logVE) space: O(VO + EO)
485
485
  *
486
486
  * 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.
487
487
  * 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.
488
- * 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(V^3), where V is the number of nodes. For dense graphs, Floyd-Warshall might become slower.
488
+ * 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.
489
489
  *
490
490
  * /
491
491
 
@@ -493,9 +493,9 @@ class AbstractGraph {
493
493
  * Dijkstra's algorithm is used to find the shortest paths from a source node to all other nodes in a graph. Its basic idea is to repeatedly choose the node closest to the source node and update the distances of other nodes using this node as an intermediary. Dijkstra's algorithm requires that the edge weights in the graph are non-negative.
494
494
  * The `dijkstra` function implements Dijkstra's algorithm to find the shortest path between a source vertex and an
495
495
  * optional destination vertex, and optionally returns the minimum distance, the paths, and other information.
496
- * @param {V | VertexKey} src - The `src` parameter represents the source vertex from which the Dijkstra algorithm will
496
+ * @param {VO | VertexKey} src - The `src` parameter represents the source vertex from which the Dijkstra algorithm will
497
497
  * start. It can be either a vertex object or a vertex ID.
498
- * @param {V | VertexKey | null} [dest] - The `dest` parameter is the destination vertex or vertex ID. It specifies the
498
+ * @param {VO | VertexKey | null} [dest] - The `dest` parameter is the destination vertex or vertex ID. It specifies the
499
499
  * vertex to which the shortest path is calculated from the source vertex. If no destination is provided, the algorithm
500
500
  * will calculate the shortest paths to all other vertices from the source vertex.
501
501
  * @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum
@@ -504,7 +504,7 @@ class AbstractGraph {
504
504
  * @param {boolean} [genPaths] - The `genPaths` parameter is a boolean flag that determines whether or not to generate
505
505
  * paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
506
506
  * shortest paths from the source vertex to all other vertices in the graph. If `genPaths
507
- * @returns The function `dijkstra` returns an object of type `DijkstraResult<V>`.
507
+ * @returns The function `dijkstra` returns an object of type `DijkstraResult<VO>`.
508
508
  */
509
509
  dijkstra(src, dest, getMinDist, genPaths) {
510
510
  if (getMinDist === undefined)
@@ -531,12 +531,12 @@ class AbstractGraph {
531
531
  distMap.set(vertexOrKey, Infinity);
532
532
  }
533
533
  const heap = new priority_queue_1.PriorityQueue({ comparator: (a, b) => a.key - b.key });
534
- heap.add({ key: 0, val: srcVertex });
534
+ heap.add({ key: 0, value: srcVertex });
535
535
  distMap.set(srcVertex, 0);
536
536
  preMap.set(srcVertex, null);
537
537
  /**
538
538
  * The function `getPaths` retrieves all paths from vertices to a specified minimum vertex.
539
- * @param {V | null} minV - The parameter `minV` is of type `V | null`. It represents the minimum vertex value or
539
+ * @param {VO | null} minV - The parameter `minV` is of type `VO | null`. It represents the minimum vertex value or
540
540
  * null.
541
541
  */
542
542
  const getPaths = (minV) => {
@@ -559,7 +559,7 @@ class AbstractGraph {
559
559
  while (heap.size > 0) {
560
560
  const curHeapNode = heap.poll();
561
561
  const dist = curHeapNode?.key;
562
- const cur = curHeapNode?.val;
562
+ const cur = curHeapNode?.value;
563
563
  if (dist !== undefined) {
564
564
  if (cur) {
565
565
  seen.add(cur);
@@ -580,7 +580,7 @@ class AbstractGraph {
580
580
  const distSrcToNeighbor = distMap.get(neighbor);
581
581
  if (distSrcToNeighbor) {
582
582
  if (dist + weight < distSrcToNeighbor) {
583
- heap.add({ key: dist + weight, val: neighbor });
583
+ heap.add({ key: dist + weight, value: neighbor });
584
584
  preMap.set(neighbor, cur);
585
585
  distMap.set(neighbor, dist + weight);
586
586
  }
@@ -608,17 +608,17 @@ class AbstractGraph {
608
608
  return { distMap, preMap, seen, paths, minDist, minPath };
609
609
  }
610
610
  /**
611
- * BellmanFord time:O(VE) space:O(V)
611
+ * BellmanFord time:O(VE) space:O(VO)
612
612
  * one to rest pairs
613
613
  * /
614
614
 
615
615
  /**
616
- * BellmanFord time:O(VE) space:O(V)
616
+ * BellmanFord time:O(VE) space:O(VO)
617
617
  * one to rest pairs
618
618
  * 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.
619
619
  * The `bellmanFord` function implements the Bellman-Ford algorithm to find the shortest path from a source vertex to
620
620
  * all other vertices in a graph, and optionally detects negative cycles and generates the minimum path.
621
- * @param {V | VertexKey} src - The `src` parameter is the source vertex from which the Bellman-Ford algorithm will
621
+ * @param {VO | VertexKey} src - The `src` parameter is the source vertex from which the Bellman-Ford algorithm will
622
622
  * start calculating the shortest paths. It can be either a vertex object or a vertex ID.
623
623
  * @param {boolean} [scanNegativeCycle] - A boolean flag indicating whether to scan for negative cycles in the graph.
624
624
  * @param {boolean} [getMin] - The `getMin` parameter is a boolean flag that determines whether the algorithm should
@@ -714,31 +714,31 @@ class AbstractGraph {
714
714
  return { hasNegativeCycle, distMap, preMap, paths, min, minPath };
715
715
  }
716
716
  /**
717
- * Dijkstra algorithm time: O(logVE) space: O(V + E)
717
+ * Dijkstra algorithm time: O(logVE) space: O(VO + EO)
718
718
  * /
719
719
 
720
720
  /**
721
- * Dijkstra algorithm time: O(logVE) space: O(V + E)
721
+ * Dijkstra algorithm time: O(logVE) space: O(VO + EO)
722
722
  * Dijkstra's algorithm is used to find the shortest paths from a source node to all other nodes in a graph. Its basic idea is to repeatedly choose the node closest to the source node and update the distances of other nodes using this node as an intermediary. Dijkstra's algorithm requires that the edge weights in the graph are non-negative.
723
723
  */
724
724
  /**
725
- * BellmanFord time:O(VE) space:O(V)
725
+ * BellmanFord time:O(VE) space:O(VO)
726
726
  * one to rest pairs
727
727
  * 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.
728
728
  * The `bellmanFord` function implements the Bellman-Ford algorithm to find the shortest path from a source vertex to
729
729
  */
730
730
  /**
731
- * Floyd algorithm time: O(V^3) space: O(V^2), not support graph with negative weight cycle
731
+ * Floyd algorithm time: O(VO^3) space: O(VO^2), not support graph with negative weight cycle
732
732
  * all pairs
733
733
  * 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.
734
734
  */
735
735
  /**
736
- * Floyd algorithm time: O(V^3) space: O(V^2), not support graph with negative weight cycle
736
+ * Floyd algorithm time: O(VO^3) space: O(VO^2), not support graph with negative weight cycle
737
737
  * all pairs
738
738
  * /
739
739
 
740
740
  /**
741
- * Floyd algorithm time: O(V^3) space: O(V^2), not support graph with negative weight cycle
741
+ * Floyd algorithm time: O(VO^3) space: O(VO^2), not support graph with negative weight cycle
742
742
  * all pairs
743
743
  * 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.
744
744
  * The function implements the Floyd-Warshall algorithm to find the shortest path between all pairs of vertices in a
@@ -6,12 +6,12 @@ export declare class DirectedVertex<V = any> extends AbstractVertex<V> {
6
6
  * The constructor function initializes a vertex with an optional value.
7
7
  * @param {VertexKey} key - The `key` parameter is of type `VertexKey` and represents the identifier of the vertex. It is
8
8
  * used to uniquely identify the vertex within a graph or data structure.
9
- * @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to initialize the value of the
9
+ * @param {V} [value] - The "value" parameter is an optional parameter of type V. It is used to initialize the value of the
10
10
  * vertex. If no value is provided, the vertex will be initialized with a default value.
11
11
  */
12
- constructor(key: VertexKey, val?: V);
12
+ constructor(key: VertexKey, value?: V);
13
13
  }
14
- export declare class DirectedEdge<V = any> extends AbstractEdge<V> {
14
+ export declare class DirectedEdge<E = any> extends AbstractEdge<E> {
15
15
  /**
16
16
  * The constructor function initializes the source and destination vertices of an edge, along with an optional weight
17
17
  * and value.
@@ -20,10 +20,10 @@ export declare class DirectedEdge<V = any> extends AbstractEdge<V> {
20
20
  * @param {VertexKey} dest - The `dest` parameter represents the destination vertex of an edge. It is of type
21
21
  * `VertexKey`, which is likely a unique identifier for a vertex in a graph.
22
22
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
23
- * @param {V} [val] - The `val` parameter is an optional parameter of type `V`. It represents the value associated with
23
+ * @param {E} [value] - The `value` parameter is an optional parameter of type `E`. It represents the value associated with
24
24
  * the edge.
25
25
  */
26
- constructor(src: VertexKey, dest: VertexKey, weight?: number, val?: V);
26
+ constructor(src: VertexKey, dest: VertexKey, weight?: number, value?: E);
27
27
  private _src;
28
28
  get src(): VertexKey;
29
29
  set src(v: VertexKey);
@@ -31,15 +31,15 @@ export declare class DirectedEdge<V = any> extends AbstractEdge<V> {
31
31
  get dest(): VertexKey;
32
32
  set dest(v: VertexKey);
33
33
  }
34
- export declare class DirectedGraph<V extends DirectedVertex<any> = DirectedVertex, E extends DirectedEdge<any> = DirectedEdge> extends AbstractGraph<V, E> implements IGraph<V, E> {
34
+ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V> = DirectedVertex<V>, EO extends DirectedEdge<E> = DirectedEdge<E>> extends AbstractGraph<V, E, VO, EO> implements IGraph<V, E, VO, EO> {
35
35
  /**
36
36
  * The constructor function initializes an instance of a class.
37
37
  */
38
38
  constructor();
39
39
  private _outEdgeMap;
40
- get outEdgeMap(): Map<V, E[]>;
40
+ get outEdgeMap(): Map<VO, EO[]>;
41
41
  private _inEdgeMap;
42
- get inEdgeMap(): Map<V, E[]>;
42
+ get inEdgeMap(): Map<VO, EO[]>;
43
43
  /**
44
44
  * 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.
45
45
  * 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.
@@ -48,12 +48,12 @@ export declare class DirectedGraph<V extends DirectedVertex<any> = DirectedVerte
48
48
  * The function creates a new vertex with an optional value and returns it.
49
49
  * @param {VertexKey} key - The `key` parameter is the unique identifier for the vertex. It is of type `VertexKey`, which
50
50
  * could be a number or a string depending on how you want to identify your vertices.
51
- * @param [val] - The 'val' parameter is an optional value that can be assigned to the vertex. If a value is provided,
52
- * it will be assigned to the 'val' property of the vertex. If no value is provided, the 'val' property will be
51
+ * @param [value] - The 'value' parameter is an optional value that can be assigned to the vertex. If a value is provided,
52
+ * it will be assigned to the 'value' property of the vertex. If no value is provided, the 'value' property will be
53
53
  * assigned the same value as the 'key' parameter
54
- * @returns a new instance of a DirectedVertex object, casted as type V.
54
+ * @returns a new instance of a DirectedVertex object, casted as type VO.
55
55
  */
56
- createVertex(key: VertexKey, val?: V['val']): V;
56
+ createVertex(key: VertexKey, value?: V): VO;
57
57
  /**
58
58
  * 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.
59
59
  * 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.
@@ -64,100 +64,100 @@ export declare class DirectedGraph<V extends DirectedVertex<any> = DirectedVerte
64
64
  * @param {VertexKey} dest - The `dest` parameter is the identifier of the destination vertex for the edge.
65
65
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge. If no
66
66
  * weight is provided, it defaults to 1.
67
- * @param [val] - The 'val' parameter is an optional value that can be assigned to the edge. It can be of any type and
67
+ * @param [value] - The 'value' parameter is an optional value that can be assigned to the edge. It can be of any type and
68
68
  * is used to store additional information or data associated with the edge.
69
- * @returns a new instance of a DirectedEdge object, casted as type E.
69
+ * @returns a new instance of a DirectedEdge object, casted as type EO.
70
70
  */
71
- createEdge(src: VertexKey, dest: VertexKey, weight?: number, val?: E['val']): E;
71
+ createEdge(src: VertexKey, dest: VertexKey, weight?: number, value?: E): EO;
72
72
  /**
73
73
  * The `getEdge` function retrieves an edge between two vertices based on their source and destination IDs.
74
- * @param {V | null | VertexKey} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
75
- * @param {V | null | VertexKey} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
76
- * destination vertex of the edge. It can be either a vertex object (`V`), a vertex ID (`VertexKey`), or `null` if the
74
+ * @param {VO | VertexKey | null} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
75
+ * @param {VO | VertexKey | null} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
76
+ * destination vertex of the edge. It can be either a vertex object (`VO`), a vertex ID (`VertexKey`), or `null` if the
77
77
  * destination is not specified.
78
78
  * @returns the first edge found between the source and destination vertices, or null if no such edge is found.
79
79
  */
80
- getEdge(srcOrKey: V | null | VertexKey, destOrKey: V | null | VertexKey): E | null;
80
+ getEdge(srcOrKey: VO | VertexKey | null, destOrKey: VO | VertexKey | null): EO | null;
81
81
  /**
82
82
  * The function removes an edge between two vertices in a graph and returns the removed edge.
83
- * @param {V | VertexKey} srcOrKey - The source vertex or its ID.
84
- * @param {V | VertexKey} destOrKey - The `destOrKey` parameter represents the destination vertex or its ID.
85
- * @returns the removed edge (E) if it exists, or null if either the source or destination vertex does not exist.
83
+ * @param {VO | VertexKey} srcOrKey - The source vertex or its ID.
84
+ * @param {VO | VertexKey} destOrKey - The `destOrKey` parameter represents the destination vertex or its ID.
85
+ * @returns the removed edge (EO) if it exists, or null if either the source or destination vertex does not exist.
86
86
  */
87
- deleteEdgeSrcToDest(srcOrKey: V | VertexKey, destOrKey: V | VertexKey): E | null;
87
+ deleteEdgeSrcToDest(srcOrKey: VO | VertexKey, destOrKey: VO | VertexKey): EO | null;
88
88
  /**
89
89
  * The function removes an edge from a graph and returns the removed edge, or null if the edge was not found.
90
- * @param {E} edge - The `edge` parameter is an object that represents an edge in a graph. It has two properties: `src`
90
+ * @param {EO} edge - The `edge` parameter is an object that represents an edge in a graph. It has two properties: `src`
91
91
  * and `dest`, which represent the source and destination vertices of the edge, respectively.
92
- * @returns The method `deleteEdge` returns the removed edge (`E`) if it exists, or `null` if the edge does not exist.
92
+ * @returns The method `deleteEdge` returns the removed edge (`EO`) if it exists, or `null` if the edge does not exist.
93
93
  */
94
- deleteEdge(edge: E): E | null;
94
+ deleteEdge(edge: EO): EO | null;
95
95
  /**
96
96
  * The function removes edges between two vertices and returns the removed edges.
97
- * @param {VertexKey | V} v1 - The parameter `v1` can be either a `VertexKey` or a `V`. A `VertexKey` represents the
98
- * unique identifier of a vertex in a graph, while `V` represents the actual vertex object.
99
- * @param {VertexKey | V} v2 - The parameter `v2` represents either a `VertexKey` or a `V` object. It is used to specify
97
+ * @param {VertexKey | VO} v1 - The parameter `v1` can be either a `VertexKey` or a `VO`. A `VertexKey` represents the
98
+ * unique identifier of a vertex in a graph, while `VO` represents the actual vertex object.
99
+ * @param {VertexKey | VO} v2 - The parameter `v2` represents either a `VertexKey` or a `VO` object. It is used to specify
100
100
  * the second vertex in the edge that needs to be removed.
101
- * @returns an array of removed edges (E[]).
101
+ * @returns an array of removed edges (EO[]).
102
102
  */
103
- deleteEdgesBetween(v1: VertexKey | V, v2: VertexKey | V): E[];
103
+ deleteEdgesBetween(v1: VertexKey | VO, v2: VertexKey | VO): EO[];
104
104
  /**
105
105
  * The function `incomingEdgesOf` returns an array of incoming edges for a given vertex or vertex ID.
106
- * @param {V | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`V`) or a vertex ID
106
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
107
107
  * (`VertexKey`).
108
- * @returns The method `incomingEdgesOf` returns an array of edges (`E[]`).
108
+ * @returns The method `incomingEdgesOf` returns an array of edges (`EO[]`).
109
109
  */
110
- incomingEdgesOf(vertexOrKey: V | VertexKey): E[];
110
+ incomingEdgesOf(vertexOrKey: VO | VertexKey): EO[];
111
111
  /**
112
112
  * The function `outgoingEdgesOf` returns an array of outgoing edges from a given vertex or vertex ID.
113
- * @param {V | VertexKey} vertexOrKey - The parameter `vertexOrKey` can accept either a vertex object (`V`) or a vertex ID
113
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can accept either a vertex object (`VO`) or a vertex ID
114
114
  * (`VertexKey`).
115
- * @returns The method `outgoingEdgesOf` returns an array of edges (`E[]`).
115
+ * @returns The method `outgoingEdgesOf` returns an array of edges (`EO[]`).
116
116
  */
117
- outgoingEdgesOf(vertexOrKey: V | VertexKey): E[];
117
+ outgoingEdgesOf(vertexOrKey: VO | VertexKey): EO[];
118
118
  /**
119
119
  * The function "degreeOf" returns the total degree of a vertex, which is the sum of its out-degree and in-degree.
120
- * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`.
120
+ * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
121
121
  * @returns The sum of the out-degree and in-degree of the specified vertex or vertex ID.
122
122
  */
123
- degreeOf(vertexOrKey: VertexKey | V): number;
123
+ degreeOf(vertexOrKey: VertexKey | VO): number;
124
124
  /**
125
125
  * The function "inDegreeOf" returns the number of incoming edges for a given vertex.
126
- * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`.
126
+ * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
127
127
  * @returns The number of incoming edges of the specified vertex or vertex ID.
128
128
  */
129
- inDegreeOf(vertexOrKey: VertexKey | V): number;
129
+ inDegreeOf(vertexOrKey: VertexKey | VO): number;
130
130
  /**
131
131
  * The function `outDegreeOf` returns the number of outgoing edges from a given vertex.
132
- * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`.
132
+ * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
133
133
  * @returns The number of outgoing edges from the specified vertex or vertex ID.
134
134
  */
135
- outDegreeOf(vertexOrKey: VertexKey | V): number;
135
+ outDegreeOf(vertexOrKey: VertexKey | VO): number;
136
136
  /**
137
137
  * The function "edgesOf" returns an array of both outgoing and incoming edges of a given vertex or vertex ID.
138
- * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`.
138
+ * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
139
139
  * @returns The function `edgesOf` returns an array of edges.
140
140
  */
141
- edgesOf(vertexOrKey: VertexKey | V): E[];
141
+ edgesOf(vertexOrKey: VertexKey | VO): EO[];
142
142
  /**
143
143
  * The function "getEdgeSrc" returns the source vertex of an edge, or null if the edge does not exist.
144
- * @param {E} e - The parameter "e" is of type E, which represents an edge in a graph.
145
- * @returns either a vertex object (V) or null.
144
+ * @param {EO} e - The parameter "e" is of type EO, which represents an edge in a graph.
145
+ * @returns either a vertex object (VO) or null.
146
146
  */
147
- getEdgeSrc(e: E): V | null;
147
+ getEdgeSrc(e: EO): VO | null;
148
148
  /**
149
149
  * The function "getEdgeDest" returns the destination vertex of an edge.
150
- * @param {E} e - The parameter "e" is of type "E", which represents an edge in a graph.
151
- * @returns either a vertex object of type V or null.
150
+ * @param {EO} e - The parameter "e" is of type "EO", which represents an edge in a graph.
151
+ * @returns either a vertex object of type VO or null.
152
152
  */
153
- getEdgeDest(e: E): V | null;
153
+ getEdgeDest(e: EO): VO | null;
154
154
  /**
155
155
  * The function `getDestinations` returns an array of destination vertices connected to a given vertex.
156
- * @param {V | VertexKey | null} vertex - The `vertex` parameter represents the starting vertex from which we want to
157
- * find the destinations. It can be either a `V` object, a `VertexKey` value, or `null`.
158
- * @returns an array of vertices (V[]).
156
+ * @param {VO | VertexKey | null} vertex - The `vertex` parameter represents the starting vertex from which we want to
157
+ * find the destinations. It can be either a `VO` object, a `VertexKey` value, or `null`.
158
+ * @returns an array of vertices (VO[]).
159
159
  */
160
- getDestinations(vertex: V | VertexKey | null): V[];
160
+ getDestinations(vertex: VO | VertexKey | null): VO[];
161
161
  /**
162
162
  * The `topologicalSort` function performs a topological sort on a graph and returns an array of vertices or vertex IDs
163
163
  * in the sorted order, or null if the graph contains a cycle.
@@ -166,35 +166,35 @@ export declare class DirectedGraph<V extends DirectedVertex<any> = DirectedVerte
166
166
  * specified, the vertices themselves will be used for sorting. If 'key' is specified, the ids of
167
167
  * @returns an array of vertices or vertex IDs in topological order. If there is a cycle in the graph, it returns null.
168
168
  */
169
- topologicalSort(propertyName?: 'vertex' | 'key'): Array<V | VertexKey> | null;
169
+ topologicalSort(propertyName?: 'vertex' | 'key'): Array<VO | VertexKey> | null;
170
170
  /**
171
171
  * The `edgeSet` function returns an array of all the edges in the graph.
172
- * @returns The `edgeSet()` method returns an array of edges (`E[]`).
172
+ * @returns The `edgeSet()` method returns an array of edges (`EO[]`).
173
173
  */
174
- edgeSet(): E[];
174
+ edgeSet(): EO[];
175
175
  /**
176
176
  * The function `getNeighbors` returns an array of neighboring vertices of a given vertex or vertex ID in a graph.
177
- * @param {V | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`V`) or a vertex ID
177
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
178
178
  * (`VertexKey`).
179
- * @returns an array of vertices (V[]).
179
+ * @returns an array of vertices (VO[]).
180
180
  */
181
- getNeighbors(vertexOrKey: V | VertexKey): V[];
181
+ getNeighbors(vertexOrKey: VO | VertexKey): VO[];
182
182
  /**
183
183
  * The function "getEndsOfEdge" returns the source and destination vertices of an edge if it exists in the graph,
184
184
  * otherwise it returns null.
185
- * @param {E} edge - The parameter `edge` is of type `E`, which represents an edge in a graph.
186
- * @returns The function `getEndsOfEdge` returns an array containing two vertices `[V, V]` if the edge exists in the
185
+ * @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph.
186
+ * @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
187
187
  * graph. If the edge does not exist, it returns `null`.
188
188
  */
189
- getEndsOfEdge(edge: E): [V, V] | null;
189
+ getEndsOfEdge(edge: EO): [VO, VO] | null;
190
190
  /**
191
191
  * The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertices exist.
192
- * @param {E} edge - The parameter `edge` is of type `E`, which represents an edge in a graph. It is the edge that
192
+ * @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph. It is the edge that
193
193
  * needs to be added to the graph.
194
194
  * @returns a boolean value. It returns true if the edge was successfully added to the graph, and false if either the
195
195
  * source or destination vertex does not exist in the graph.
196
196
  */
197
- protected _addEdgeOnly(edge: E): boolean;
198
- protected _setOutEdgeMap(value: Map<V, E[]>): void;
199
- protected _setInEdgeMap(value: Map<V, E[]>): void;
197
+ protected _addEdgeOnly(edge: EO): boolean;
198
+ protected _setOutEdgeMap(value: Map<VO, EO[]>): void;
199
+ protected _setInEdgeMap(value: Map<VO, EO[]>): void;
200
200
  }