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
@@ -15,11 +15,11 @@ class DirectedVertex extends abstract_graph_1.AbstractVertex {
15
15
  * The constructor function initializes a vertex with an optional value.
16
16
  * @param {VertexKey} key - The `key` parameter is of type `VertexKey` and represents the identifier of the vertex. It is
17
17
  * used to uniquely identify the vertex within a graph or data structure.
18
- * @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to initialize the value of the
18
+ * @param {V} [value] - The "value" parameter is an optional parameter of type V. It is used to initialize the value of the
19
19
  * vertex. If no value is provided, the vertex will be initialized with a default value.
20
20
  */
21
- constructor(key, val) {
22
- super(key, val);
21
+ constructor(key, value) {
22
+ super(key, value);
23
23
  }
24
24
  }
25
25
  exports.DirectedVertex = DirectedVertex;
@@ -32,11 +32,11 @@ class DirectedEdge extends abstract_graph_1.AbstractEdge {
32
32
  * @param {VertexKey} dest - The `dest` parameter represents the destination vertex of an edge. It is of type
33
33
  * `VertexKey`, which is likely a unique identifier for a vertex in a graph.
34
34
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
35
- * @param {V} [val] - The `val` parameter is an optional parameter of type `V`. It represents the value associated with
35
+ * @param {E} [value] - The `value` parameter is an optional parameter of type `E`. It represents the value associated with
36
36
  * the edge.
37
37
  */
38
- constructor(src, dest, weight, val) {
39
- super(weight, val);
38
+ constructor(src, dest, weight, value) {
39
+ super(weight, value);
40
40
  this._src = src;
41
41
  this._dest = dest;
42
42
  }
@@ -79,13 +79,13 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
79
79
  * The function creates a new vertex with an optional value and returns it.
80
80
  * @param {VertexKey} key - The `key` parameter is the unique identifier for the vertex. It is of type `VertexKey`, which
81
81
  * could be a number or a string depending on how you want to identify your vertices.
82
- * @param [val] - The 'val' parameter is an optional value that can be assigned to the vertex. If a value is provided,
83
- * it will be assigned to the 'val' property of the vertex. If no value is provided, the 'val' property will be
82
+ * @param [value] - The 'value' parameter is an optional value that can be assigned to the vertex. If a value is provided,
83
+ * it will be assigned to the 'value' property of the vertex. If no value is provided, the 'value' property will be
84
84
  * assigned the same value as the 'key' parameter
85
- * @returns a new instance of a DirectedVertex object, casted as type V.
85
+ * @returns a new instance of a DirectedVertex object, casted as type VO.
86
86
  */
87
- createVertex(key, val) {
88
- return new DirectedVertex(key, val ?? key);
87
+ createVertex(key, value) {
88
+ return new DirectedVertex(key, value ?? key);
89
89
  }
90
90
  /**
91
91
  * 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.
@@ -97,18 +97,18 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
97
97
  * @param {VertexKey} dest - The `dest` parameter is the identifier of the destination vertex for the edge.
98
98
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge. If no
99
99
  * weight is provided, it defaults to 1.
100
- * @param [val] - The 'val' parameter is an optional value that can be assigned to the edge. It can be of any type and
100
+ * @param [value] - The 'value' parameter is an optional value that can be assigned to the edge. It can be of any type and
101
101
  * is used to store additional information or data associated with the edge.
102
- * @returns a new instance of a DirectedEdge object, casted as type E.
102
+ * @returns a new instance of a DirectedEdge object, casted as type EO.
103
103
  */
104
- createEdge(src, dest, weight, val) {
105
- return new DirectedEdge(src, dest, weight ?? 1, val);
104
+ createEdge(src, dest, weight, value) {
105
+ return new DirectedEdge(src, dest, weight ?? 1, value);
106
106
  }
107
107
  /**
108
108
  * The `getEdge` function retrieves an edge between two vertices based on their source and destination IDs.
109
- * @param {V | null | VertexKey} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
110
- * @param {V | null | VertexKey} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
111
- * destination vertex of the edge. It can be either a vertex object (`V`), a vertex ID (`VertexKey`), or `null` if the
109
+ * @param {VO | VertexKey | null} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
110
+ * @param {VO | VertexKey | null} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
111
+ * destination vertex of the edge. It can be either a vertex object (`VO`), a vertex ID (`VertexKey`), or `null` if the
112
112
  * destination is not specified.
113
113
  * @returns the first edge found between the source and destination vertices, or null if no such edge is found.
114
114
  */
@@ -128,9 +128,9 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
128
128
  }
129
129
  /**
130
130
  * The function removes an edge between two vertices in a graph and returns the removed edge.
131
- * @param {V | VertexKey} srcOrKey - The source vertex or its ID.
132
- * @param {V | VertexKey} destOrKey - The `destOrKey` parameter represents the destination vertex or its ID.
133
- * @returns the removed edge (E) if it exists, or null if either the source or destination vertex does not exist.
131
+ * @param {VO | VertexKey} srcOrKey - The source vertex or its ID.
132
+ * @param {VO | VertexKey} destOrKey - The `destOrKey` parameter represents the destination vertex or its ID.
133
+ * @returns the removed edge (EO) if it exists, or null if either the source or destination vertex does not exist.
134
134
  */
135
135
  deleteEdgeSrcToDest(srcOrKey, destOrKey) {
136
136
  const src = this._getVertex(srcOrKey);
@@ -151,9 +151,9 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
151
151
  }
152
152
  /**
153
153
  * The function removes an edge from a graph and returns the removed edge, or null if the edge was not found.
154
- * @param {E} edge - The `edge` parameter is an object that represents an edge in a graph. It has two properties: `src`
154
+ * @param {EO} edge - The `edge` parameter is an object that represents an edge in a graph. It has two properties: `src`
155
155
  * and `dest`, which represent the source and destination vertices of the edge, respectively.
156
- * @returns The method `deleteEdge` returns the removed edge (`E`) if it exists, or `null` if the edge does not exist.
156
+ * @returns The method `deleteEdge` returns the removed edge (`EO`) if it exists, or `null` if the edge does not exist.
157
157
  */
158
158
  deleteEdge(edge) {
159
159
  let removed = null;
@@ -173,11 +173,11 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
173
173
  }
174
174
  /**
175
175
  * The function removes edges between two vertices and returns the removed edges.
176
- * @param {VertexKey | V} v1 - The parameter `v1` can be either a `VertexKey` or a `V`. A `VertexKey` represents the
177
- * unique identifier of a vertex in a graph, while `V` represents the actual vertex object.
178
- * @param {VertexKey | V} v2 - The parameter `v2` represents either a `VertexKey` or a `V` object. It is used to specify
176
+ * @param {VertexKey | VO} v1 - The parameter `v1` can be either a `VertexKey` or a `VO`. A `VertexKey` represents the
177
+ * unique identifier of a vertex in a graph, while `VO` represents the actual vertex object.
178
+ * @param {VertexKey | VO} v2 - The parameter `v2` represents either a `VertexKey` or a `VO` object. It is used to specify
179
179
  * the second vertex in the edge that needs to be removed.
180
- * @returns an array of removed edges (E[]).
180
+ * @returns an array of removed edges (EO[]).
181
181
  */
182
182
  deleteEdgesBetween(v1, v2) {
183
183
  const removed = [];
@@ -191,9 +191,9 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
191
191
  }
192
192
  /**
193
193
  * The function `incomingEdgesOf` returns an array of incoming edges for a given vertex or vertex ID.
194
- * @param {V | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`V`) or a vertex ID
194
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
195
195
  * (`VertexKey`).
196
- * @returns The method `incomingEdgesOf` returns an array of edges (`E[]`).
196
+ * @returns The method `incomingEdgesOf` returns an array of edges (`EO[]`).
197
197
  */
198
198
  incomingEdgesOf(vertexOrKey) {
199
199
  const target = this._getVertex(vertexOrKey);
@@ -204,9 +204,9 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
204
204
  }
205
205
  /**
206
206
  * The function `outgoingEdgesOf` returns an array of outgoing edges from a given vertex or vertex ID.
207
- * @param {V | VertexKey} vertexOrKey - The parameter `vertexOrKey` can accept either a vertex object (`V`) or a vertex ID
207
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can accept either a vertex object (`VO`) or a vertex ID
208
208
  * (`VertexKey`).
209
- * @returns The method `outgoingEdgesOf` returns an array of edges (`E[]`).
209
+ * @returns The method `outgoingEdgesOf` returns an array of edges (`EO[]`).
210
210
  */
211
211
  outgoingEdgesOf(vertexOrKey) {
212
212
  const target = this._getVertex(vertexOrKey);
@@ -217,7 +217,7 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
217
217
  }
218
218
  /**
219
219
  * The function "degreeOf" returns the total degree of a vertex, which is the sum of its out-degree and in-degree.
220
- * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`.
220
+ * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
221
221
  * @returns The sum of the out-degree and in-degree of the specified vertex or vertex ID.
222
222
  */
223
223
  degreeOf(vertexOrKey) {
@@ -225,7 +225,7 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
225
225
  }
226
226
  /**
227
227
  * The function "inDegreeOf" returns the number of incoming edges for a given vertex.
228
- * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`.
228
+ * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
229
229
  * @returns The number of incoming edges of the specified vertex or vertex ID.
230
230
  */
231
231
  inDegreeOf(vertexOrKey) {
@@ -233,7 +233,7 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
233
233
  }
234
234
  /**
235
235
  * The function `outDegreeOf` returns the number of outgoing edges from a given vertex.
236
- * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`.
236
+ * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
237
237
  * @returns The number of outgoing edges from the specified vertex or vertex ID.
238
238
  */
239
239
  outDegreeOf(vertexOrKey) {
@@ -241,7 +241,7 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
241
241
  }
242
242
  /**
243
243
  * The function "edgesOf" returns an array of both outgoing and incoming edges of a given vertex or vertex ID.
244
- * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`.
244
+ * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
245
245
  * @returns The function `edgesOf` returns an array of edges.
246
246
  */
247
247
  edgesOf(vertexOrKey) {
@@ -249,25 +249,25 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
249
249
  }
250
250
  /**
251
251
  * The function "getEdgeSrc" returns the source vertex of an edge, or null if the edge does not exist.
252
- * @param {E} e - The parameter "e" is of type E, which represents an edge in a graph.
253
- * @returns either a vertex object (V) or null.
252
+ * @param {EO} e - The parameter "e" is of type EO, which represents an edge in a graph.
253
+ * @returns either a vertex object (VO) or null.
254
254
  */
255
255
  getEdgeSrc(e) {
256
256
  return this._getVertex(e.src);
257
257
  }
258
258
  /**
259
259
  * The function "getEdgeDest" returns the destination vertex of an edge.
260
- * @param {E} e - The parameter "e" is of type "E", which represents an edge in a graph.
261
- * @returns either a vertex object of type V or null.
260
+ * @param {EO} e - The parameter "e" is of type "EO", which represents an edge in a graph.
261
+ * @returns either a vertex object of type VO or null.
262
262
  */
263
263
  getEdgeDest(e) {
264
264
  return this._getVertex(e.dest);
265
265
  }
266
266
  /**
267
267
  * The function `getDestinations` returns an array of destination vertices connected to a given vertex.
268
- * @param {V | VertexKey | null} vertex - The `vertex` parameter represents the starting vertex from which we want to
269
- * find the destinations. It can be either a `V` object, a `VertexKey` value, or `null`.
270
- * @returns an array of vertices (V[]).
268
+ * @param {VO | VertexKey | null} vertex - The `vertex` parameter represents the starting vertex from which we want to
269
+ * find the destinations. It can be either a `VO` object, a `VertexKey` value, or `null`.
270
+ * @returns an array of vertices (VO[]).
271
271
  */
272
272
  getDestinations(vertex) {
273
273
  if (vertex === null) {
@@ -329,7 +329,7 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
329
329
  }
330
330
  /**
331
331
  * The `edgeSet` function returns an array of all the edges in the graph.
332
- * @returns The `edgeSet()` method returns an array of edges (`E[]`).
332
+ * @returns The `edgeSet()` method returns an array of edges (`EO[]`).
333
333
  */
334
334
  edgeSet() {
335
335
  let edges = [];
@@ -340,9 +340,9 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
340
340
  }
341
341
  /**
342
342
  * The function `getNeighbors` returns an array of neighboring vertices of a given vertex or vertex ID in a graph.
343
- * @param {V | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`V`) or a vertex ID
343
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
344
344
  * (`VertexKey`).
345
- * @returns an array of vertices (V[]).
345
+ * @returns an array of vertices (VO[]).
346
346
  */
347
347
  getNeighbors(vertexOrKey) {
348
348
  const neighbors = [];
@@ -362,8 +362,8 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
362
362
  /**
363
363
  * The function "getEndsOfEdge" returns the source and destination vertices of an edge if it exists in the graph,
364
364
  * otherwise it returns null.
365
- * @param {E} edge - The parameter `edge` is of type `E`, which represents an edge in a graph.
366
- * @returns The function `getEndsOfEdge` returns an array containing two vertices `[V, V]` if the edge exists in the
365
+ * @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph.
366
+ * @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
367
367
  * graph. If the edge does not exist, it returns `null`.
368
368
  */
369
369
  getEndsOfEdge(edge) {
@@ -381,7 +381,7 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
381
381
  }
382
382
  /**
383
383
  * The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertices exist.
384
- * @param {E} edge - The parameter `edge` is of type `E`, which represents an edge in a graph. It is the edge that
384
+ * @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph. It is the edge that
385
385
  * needs to be added to the graph.
386
386
  * @returns a boolean value. It returns true if the edge was successfully added to the graph, and false if either the
387
387
  * source or destination vertex does not exist in the graph.
@@ -10,10 +10,10 @@ export declare class MapVertex<V = any> extends DirectedVertex<V> {
10
10
  * @param {number} long - The "long" parameter represents the longitude of a location. Longitude is a geographic
11
11
  * coordinate that specifies the east-west position of a point on the Earth's surface. It is measured in degrees, with
12
12
  * values ranging from -180 to 180.
13
- * @param {V} [val] - The "val" parameter is an optional value of type V. It is not required to be provided when
13
+ * @param {V} [value] - The "value" parameter is an optional value of type V. It is not required to be provided when
14
14
  * creating an instance of the class.
15
15
  */
16
- constructor(key: VertexKey, lat: number, long: number, val?: V);
16
+ constructor(key: VertexKey, value: V, lat: number, long: number);
17
17
  private _lat;
18
18
  get lat(): number;
19
19
  set lat(value: number);
@@ -21,7 +21,7 @@ export declare class MapVertex<V = any> extends DirectedVertex<V> {
21
21
  get long(): number;
22
22
  set long(value: number);
23
23
  }
24
- export declare class MapEdge<V = any> extends DirectedEdge<V> {
24
+ export declare class MapEdge<E = any> extends DirectedEdge<E> {
25
25
  /**
26
26
  * The constructor function initializes a new instance of a class with the given source, destination, weight, and
27
27
  * value.
@@ -29,12 +29,12 @@ export declare class MapEdge<V = any> extends DirectedEdge<V> {
29
29
  * a graph.
30
30
  * @param {VertexKey} dest - The `dest` parameter is the identifier of the destination vertex for an edge.
31
31
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
32
- * @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to store additional
32
+ * @param {E} [value] - The "value" parameter is an optional parameter of type E. It is used to store additional
33
33
  * information or data associated with the edge.
34
34
  */
35
- constructor(src: VertexKey, dest: VertexKey, weight?: number, val?: V);
35
+ constructor(src: VertexKey, dest: VertexKey, weight?: number, value?: E);
36
36
  }
37
- export declare class MapGraph<V extends MapVertex<V['val']> = MapVertex, E extends MapEdge = MapEdge> extends DirectedGraph<V, E> {
37
+ export declare class MapGraph<V = any, E = any, VO extends MapVertex<V> = MapVertex<V>, EO extends MapEdge<E> = MapEdge<E>> extends DirectedGraph<V, E, VO, EO> {
38
38
  /**
39
39
  * The constructor function initializes the origin and bottomRight properties of a MapGraphCoordinate object.
40
40
  * @param {MapGraphCoordinate} origin - The `origin` parameter is a `MapGraphCoordinate` object that represents the
@@ -55,14 +55,14 @@ export declare class MapGraph<V extends MapVertex<V['val']> = MapVertex, E exten
55
55
  * The function creates a new vertex with the given key, value, latitude, and longitude.
56
56
  * @param {VertexKey} key - The key parameter is the unique identifier for the vertex. It is of type VertexKey, which could
57
57
  * be a string or a number depending on how you define it in your code.
58
- * @param [val] - The `val` parameter is an optional value that can be assigned to the `val` property of the vertex. It
59
- * is of type `V['val']`, which means it should be of the same type as the `val` property of the vertex class `V`.
58
+ * @param [value] - The `value` parameter is an optional value that can be assigned to the `value` property of the vertex. It
59
+ * is of type `V`, which means it should be of the same type as the `value` property of the vertex class `VO`.
60
60
  * @param {number} lat - The `lat` parameter represents the latitude of the vertex. It is a number that specifies the
61
61
  * position of the vertex on the Earth's surface in the north-south direction.
62
62
  * @param {number} long - The `long` parameter represents the longitude coordinate of the vertex.
63
- * @returns The method is returning a new instance of the `MapVertex` class, casted as type `V`.
63
+ * @returns The method is returning a new instance of the `MapVertex` class, casted as type `VO`.
64
64
  */
65
- createVertex(key: VertexKey, lat?: number, long?: number, val?: V['val']): V;
65
+ createVertex(key: VertexKey, value?: V, lat?: number, long?: number): VO;
66
66
  /**
67
67
  * The function creates a new instance of a MapEdge with the given source, destination, weight, and value.
68
68
  * @param {VertexKey} src - The source vertex ID of the edge. It represents the starting point of the edge.
@@ -71,9 +71,9 @@ export declare class MapGraph<V extends MapVertex<V['val']> = MapVertex, E exten
71
71
  * @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the edge. It
72
72
  * is used to assign a numerical value to the edge, which can be used in algorithms such as shortest path algorithms.
73
73
  * If the weight is not provided, it can be set to a default value or left undefined.
74
- * @param [val] - The `val` parameter is an optional value that can be assigned to the edge. It can be of any type,
74
+ * @param [value] - The `value` parameter is an optional value that can be assigned to the edge. It can be of any type,
75
75
  * depending on the specific implementation of the `MapEdge` class.
76
- * @returns a new instance of the `MapEdge` class, cast as type `E`.
76
+ * @returns a new instance of the `MapEdge` class, cast as type `EO`.
77
77
  */
78
- createEdge(src: VertexKey, dest: VertexKey, weight?: number, val?: E['val']): E;
78
+ createEdge(src: VertexKey, dest: VertexKey, weight?: number, value?: E): EO;
79
79
  }
@@ -12,11 +12,11 @@ class MapVertex extends directed_graph_1.DirectedVertex {
12
12
  * @param {number} long - The "long" parameter represents the longitude of a location. Longitude is a geographic
13
13
  * coordinate that specifies the east-west position of a point on the Earth's surface. It is measured in degrees, with
14
14
  * values ranging from -180 to 180.
15
- * @param {V} [val] - The "val" parameter is an optional value of type V. It is not required to be provided when
15
+ * @param {V} [value] - The "value" parameter is an optional value of type V. It is not required to be provided when
16
16
  * creating an instance of the class.
17
17
  */
18
- constructor(key, lat, long, val) {
19
- super(key, val);
18
+ constructor(key, value, lat, long) {
19
+ super(key, value);
20
20
  this._lat = lat;
21
21
  this._long = long;
22
22
  }
@@ -44,11 +44,11 @@ class MapEdge extends directed_graph_1.DirectedEdge {
44
44
  * a graph.
45
45
  * @param {VertexKey} dest - The `dest` parameter is the identifier of the destination vertex for an edge.
46
46
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
47
- * @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to store additional
47
+ * @param {E} [value] - The "value" parameter is an optional parameter of type E. It is used to store additional
48
48
  * information or data associated with the edge.
49
49
  */
50
- constructor(src, dest, weight, val) {
51
- super(src, dest, weight, val);
50
+ constructor(src, dest, weight, value) {
51
+ super(src, dest, weight, value);
52
52
  }
53
53
  }
54
54
  exports.MapEdge = MapEdge;
@@ -85,15 +85,15 @@ class MapGraph extends directed_graph_1.DirectedGraph {
85
85
  * The function creates a new vertex with the given key, value, latitude, and longitude.
86
86
  * @param {VertexKey} key - The key parameter is the unique identifier for the vertex. It is of type VertexKey, which could
87
87
  * be a string or a number depending on how you define it in your code.
88
- * @param [val] - The `val` parameter is an optional value that can be assigned to the `val` property of the vertex. It
89
- * is of type `V['val']`, which means it should be of the same type as the `val` property of the vertex class `V`.
88
+ * @param [value] - The `value` parameter is an optional value that can be assigned to the `value` property of the vertex. It
89
+ * is of type `V`, which means it should be of the same type as the `value` property of the vertex class `VO`.
90
90
  * @param {number} lat - The `lat` parameter represents the latitude of the vertex. It is a number that specifies the
91
91
  * position of the vertex on the Earth's surface in the north-south direction.
92
92
  * @param {number} long - The `long` parameter represents the longitude coordinate of the vertex.
93
- * @returns The method is returning a new instance of the `MapVertex` class, casted as type `V`.
93
+ * @returns The method is returning a new instance of the `MapVertex` class, casted as type `VO`.
94
94
  */
95
- createVertex(key, lat = this.origin[0], long = this.origin[1], val) {
96
- return new MapVertex(key, lat, long, val);
95
+ createVertex(key, value, lat = this.origin[0], long = this.origin[1]) {
96
+ return new MapVertex(key, value, lat, long);
97
97
  }
98
98
  /**
99
99
  * The function creates a new instance of a MapEdge with the given source, destination, weight, and value.
@@ -103,12 +103,12 @@ class MapGraph extends directed_graph_1.DirectedGraph {
103
103
  * @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the edge. It
104
104
  * is used to assign a numerical value to the edge, which can be used in algorithms such as shortest path algorithms.
105
105
  * If the weight is not provided, it can be set to a default value or left undefined.
106
- * @param [val] - The `val` parameter is an optional value that can be assigned to the edge. It can be of any type,
106
+ * @param [value] - The `value` parameter is an optional value that can be assigned to the edge. It can be of any type,
107
107
  * depending on the specific implementation of the `MapEdge` class.
108
- * @returns a new instance of the `MapEdge` class, cast as type `E`.
108
+ * @returns a new instance of the `MapEdge` class, cast as type `EO`.
109
109
  */
110
- createEdge(src, dest, weight, val) {
111
- return new MapEdge(src, dest, weight, val);
110
+ createEdge(src, dest, weight, value) {
111
+ return new MapEdge(src, dest, weight, value);
112
112
  }
113
113
  }
114
114
  exports.MapGraph = MapGraph;
@@ -6,12 +6,12 @@ export declare class UndirectedVertex<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 network.
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 UndirectedEdge<V = number> extends AbstractEdge<V> {
14
+ export declare class UndirectedEdge<E = number> extends AbstractEdge<E> {
15
15
  /**
16
16
  * The constructor function creates an instance of a class with two vertex IDs, an optional weight, and an optional
17
17
  * value.
@@ -19,109 +19,109 @@ export declare class UndirectedEdge<V = number> extends AbstractEdge<V> {
19
19
  * @param {VertexKey} v2 - The parameter `v2` is a `VertexKey`, which represents the identifier of the second vertex in a
20
20
  * graph edge.
21
21
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
22
- * @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to store a value associated
22
+ * @param {E} [value] - The "value" parameter is an optional parameter of type E. It is used to store a value associated
23
23
  * with the edge.
24
24
  */
25
- constructor(v1: VertexKey, v2: VertexKey, weight?: number, val?: V);
25
+ constructor(v1: VertexKey, v2: VertexKey, weight?: number, value?: E);
26
26
  private _vertices;
27
27
  get vertices(): [VertexKey, VertexKey];
28
28
  set vertices(v: [VertexKey, VertexKey]);
29
29
  }
30
- export declare class UndirectedGraph<V extends UndirectedVertex<any> = UndirectedVertex, E extends UndirectedEdge<any> = UndirectedEdge> extends AbstractGraph<V, E> implements IGraph<V, E> {
30
+ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVertex<V> = UndirectedVertex<V>, EO extends UndirectedEdge<E> = UndirectedEdge<E>> extends AbstractGraph<V, E, VO, EO> implements IGraph<V, E, VO, EO> {
31
31
  /**
32
32
  * The constructor initializes a new Map object to store edges.
33
33
  */
34
34
  constructor();
35
- protected _edges: Map<V, E[]>;
36
- get edges(): Map<V, E[]>;
35
+ protected _edges: Map<VO, EO[]>;
36
+ get edges(): Map<VO, EO[]>;
37
37
  /**
38
38
  * The function creates a new vertex with an optional value and returns it.
39
39
  * @param {VertexKey} key - The `key` parameter is the unique identifier for the vertex. It is used to distinguish one
40
40
  * vertex from another in the graph.
41
- * @param [val] - The `val` parameter is an optional value that can be assigned to the vertex. If a value is provided,
41
+ * @param [value] - The `value` parameter is an optional value that can be assigned to the vertex. If a value is provided,
42
42
  * it will be used as the value of the vertex. If no value is provided, the `key` parameter will be used as the value of
43
43
  * the vertex.
44
- * @returns The method is returning a new instance of the `UndirectedVertex` class, casted as type `V`.
44
+ * @returns The method is returning a new instance of the `UndirectedVertex` class, casted as type `VO`.
45
45
  */
46
- createVertex(key: VertexKey, val?: V['val']): V;
46
+ createVertex(key: VertexKey, value?: VO['value']): VO;
47
47
  /**
48
48
  * The function creates an undirected edge between two vertices with an optional weight and value.
49
49
  * @param {VertexKey} v1 - The parameter `v1` represents the first vertex of the edge.
50
50
  * @param {VertexKey} v2 - The parameter `v2` represents the second vertex of the edge.
51
51
  * @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the edge. If
52
52
  * no weight is provided, it defaults to 1.
53
- * @param [val] - The `val` parameter is an optional value that can be assigned to the edge. It can be of any type and
53
+ * @param [value] - The `value` parameter is an optional value that can be assigned to the edge. It can be of any type and
54
54
  * is used to store additional information or data associated with the edge.
55
- * @returns a new instance of the `UndirectedEdge` class, which is casted as type `E`.
55
+ * @returns a new instance of the `UndirectedEdge` class, which is casted as type `EO`.
56
56
  */
57
- createEdge(v1: VertexKey, v2: VertexKey, weight?: number, val?: E['val']): E;
57
+ createEdge(v1: VertexKey, v2: VertexKey, weight?: number, value?: EO['value']): EO;
58
58
  /**
59
59
  * The function `getEdge` returns the first edge that connects two vertices, or null if no such edge exists.
60
- * @param {V | null | VertexKey} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `V` (vertex
60
+ * @param {VO | VertexKey | null} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `VO` (vertex
61
61
  * object), `null`, or `VertexKey` (a string or number representing the ID of a vertex).
62
- * @param {V | null | VertexKey} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `V` (vertex
62
+ * @param {VO | VertexKey | null} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `VO` (vertex
63
63
  * object), `null`, or `VertexKey` (vertex ID).
64
- * @returns an edge (E) or null.
64
+ * @returns an edge (EO) or null.
65
65
  */
66
- getEdge(v1: V | null | VertexKey, v2: V | null | VertexKey): E | null;
66
+ getEdge(v1: VO | VertexKey | null, v2: VO | VertexKey | null): EO | null;
67
67
  /**
68
68
  * The function removes an edge between two vertices in a graph and returns the removed edge.
69
- * @param {V | VertexKey} v1 - The parameter `v1` represents either a vertex object (`V`) or a vertex ID (`VertexKey`).
70
- * @param {V | VertexKey} v2 - V | VertexKey - This parameter can be either a vertex object (V) or a vertex ID
69
+ * @param {VO | VertexKey} v1 - The parameter `v1` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).
70
+ * @param {VO | VertexKey} v2 - VO | VertexKey - This parameter can be either a vertex object (VO) or a vertex ID
71
71
  * (VertexKey). It represents the second vertex of the edge that needs to be removed.
72
- * @returns the removed edge (E) if it exists, or null if either of the vertices (V) does not exist.
72
+ * @returns the removed edge (EO) if it exists, or null if either of the vertices (VO) does not exist.
73
73
  */
74
- deleteEdgeBetween(v1: V | VertexKey, v2: V | VertexKey): E | null;
74
+ deleteEdgeBetween(v1: VO | VertexKey, v2: VO | VertexKey): EO | null;
75
75
  /**
76
76
  * The deleteEdge function removes an edge between two vertices in a graph.
77
- * @param {E} edge - The parameter "edge" is of type E, which represents an edge in a graph.
78
- * @returns The method is returning either the removed edge (of type E) or null if the edge was not found.
77
+ * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
78
+ * @returns The method is returning either the removed edge (of type EO) or null if the edge was not found.
79
79
  */
80
- deleteEdge(edge: E): E | null;
80
+ deleteEdge(edge: EO): EO | null;
81
81
  /**
82
82
  * The function `degreeOf` returns the degree of a vertex in a graph, which is the number of edges connected to that
83
83
  * vertex.
84
- * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`.
84
+ * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
85
85
  * @returns The function `degreeOf` returns the degree of a vertex in a graph. The degree of a vertex is the number of
86
86
  * edges connected to that vertex.
87
87
  */
88
- degreeOf(vertexOrKey: VertexKey | V): number;
88
+ degreeOf(vertexOrKey: VertexKey | VO): number;
89
89
  /**
90
90
  * The function returns the edges of a given vertex or vertex ID.
91
- * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`. A `VertexKey` is a
92
- * unique identifier for a vertex in a graph, while `V` represents the type of the vertex.
91
+ * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`. A `VertexKey` is a
92
+ * unique identifier for a vertex in a graph, while `VO` represents the type of the vertex.
93
93
  * @returns an array of edges.
94
94
  */
95
- edgesOf(vertexOrKey: VertexKey | V): E[];
95
+ edgesOf(vertexOrKey: VertexKey | VO): EO[];
96
96
  /**
97
97
  * The function "edgeSet" returns an array of unique edges from a set of edges.
98
- * @returns The method `edgeSet()` returns an array of type `E[]`.
98
+ * @returns The method `edgeSet()` returns an array of type `EO[]`.
99
99
  */
100
- edgeSet(): E[];
100
+ edgeSet(): EO[];
101
101
  /**
102
102
  * The function "getNeighbors" returns an array of neighboring vertices for a given vertex or vertex ID.
103
- * @param {V | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`V`) or a vertex ID
103
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
104
104
  * (`VertexKey`).
105
- * @returns an array of vertices (V[]).
105
+ * @returns an array of vertices (VO[]).
106
106
  */
107
- getNeighbors(vertexOrKey: V | VertexKey): V[];
107
+ getNeighbors(vertexOrKey: VO | VertexKey): VO[];
108
108
  /**
109
109
  * The function "getEndsOfEdge" returns the vertices at the ends of an edge if the edge exists in the graph, otherwise
110
110
  * it returns null.
111
- * @param {E} edge - The parameter "edge" is of type E, which represents an edge in a graph.
112
- * @returns The function `getEndsOfEdge` returns an array containing two vertices `[V, V]` if the edge exists in the
111
+ * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
112
+ * @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
113
113
  * graph. If the edge does not exist, it returns `null`.
114
114
  */
115
- getEndsOfEdge(edge: E): [V, V] | null;
115
+ getEndsOfEdge(edge: EO): [VO, VO] | null;
116
116
  /**
117
117
  * The function adds an edge to the graph by updating the adjacency list with the vertices of the edge.
118
- * @param {E} edge - The parameter "edge" is of type E, which represents an edge in a graph.
118
+ * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
119
119
  * @returns a boolean value.
120
120
  */
121
- protected _addEdgeOnly(edge: E): boolean;
121
+ protected _addEdgeOnly(edge: EO): boolean;
122
122
  /**
123
123
  * The function sets the edges of a graph.
124
- * @param v - A map where the keys are of type V and the values are arrays of type E.
124
+ * @param v - A map where the keys are of type VO and the values are arrays of type EO.
125
125
  */
126
- protected _setEdges(v: Map<V, E[]>): void;
126
+ protected _setEdges(v: Map<VO, EO[]>): void;
127
127
  }