data-structure-typed 1.39.4 → 1.39.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +2 -1
  2. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +88 -88
  3. package/dist/cjs/data-structures/graph/abstract-graph.js +41 -41
  4. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  5. package/dist/cjs/data-structures/graph/directed-graph.d.ts +63 -63
  6. package/dist/cjs/data-structures/graph/directed-graph.js +36 -36
  7. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  8. package/dist/cjs/data-structures/graph/map-graph.d.ts +10 -10
  9. package/dist/cjs/data-structures/graph/map-graph.js +7 -7
  10. package/dist/cjs/data-structures/graph/map-graph.js.map +1 -1
  11. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +38 -38
  12. package/dist/cjs/data-structures/graph/undirected-graph.js +21 -21
  13. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  14. package/dist/cjs/data-structures/queue/queue.d.ts +1 -1
  15. package/dist/cjs/data-structures/queue/queue.js +3 -3
  16. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  17. package/dist/cjs/interfaces/graph.d.ts +3 -3
  18. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +88 -88
  19. package/dist/mjs/data-structures/graph/abstract-graph.js +41 -41
  20. package/dist/mjs/data-structures/graph/directed-graph.d.ts +63 -63
  21. package/dist/mjs/data-structures/graph/directed-graph.js +36 -36
  22. package/dist/mjs/data-structures/graph/map-graph.d.ts +10 -10
  23. package/dist/mjs/data-structures/graph/map-graph.js +7 -7
  24. package/dist/mjs/data-structures/graph/undirected-graph.d.ts +38 -38
  25. package/dist/mjs/data-structures/graph/undirected-graph.js +21 -21
  26. package/dist/mjs/data-structures/queue/queue.d.ts +1 -1
  27. package/dist/mjs/data-structures/queue/queue.js +3 -3
  28. package/dist/mjs/interfaces/graph.d.ts +3 -3
  29. package/dist/umd/data-structure-typed.min.js +1 -1
  30. package/dist/umd/data-structure-typed.min.js.map +1 -1
  31. package/package.json +5 -5
  32. package/src/data-structures/graph/abstract-graph.ts +135 -133
  33. package/src/data-structures/graph/directed-graph.ts +92 -87
  34. package/src/data-structures/graph/map-graph.ts +17 -20
  35. package/src/data-structures/graph/undirected-graph.ts +56 -54
  36. package/src/data-structures/queue/queue.ts +1 -1
  37. package/src/interfaces/graph.ts +3 -3
  38. package/test/unit/data-structures/graph/directed-graph.test.ts +20 -15
  39. package/test/unit/data-structures/graph/map-graph.test.ts +23 -23
  40. package/test/unit/data-structures/graph/undirected-graph.test.ts +2 -2
  41. package/test/unit/data-structures/queue/queue.test.ts +8 -8
@@ -32,7 +32,7 @@ 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} [val] - The `val` parameter is an optional parameter of type `E`. It represents the value associated with
36
36
  * the edge.
37
37
  */
38
38
  constructor(src, dest, weight, val) {
@@ -82,7 +82,7 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
82
82
  * @param [val] - The 'val' parameter is an optional value that can be assigned to the vertex. If a value is provided,
83
83
  * it will be assigned to the 'val' property of the vertex. If no value is provided, the 'val' 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
87
  createVertex(key, val) {
88
88
  return new DirectedVertex(key, val ?? key);
@@ -99,16 +99,16 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
99
99
  * weight is provided, it defaults to 1.
100
100
  * @param [val] - The 'val' 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
104
  createEdge(src, dest, weight, val) {
105
105
  return new DirectedEdge(src, dest, weight ?? 1, val);
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 | null | VertexKey} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
110
+ * @param {VO | 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 (`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.
@@ -13,7 +13,7 @@ export declare class MapVertex<V = any> extends DirectedVertex<V> {
13
13
  * @param {V} [val] - The "val" 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, val: 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} [val] - The "val" 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, val?: 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
@@ -56,13 +56,13 @@ export declare class MapGraph<V extends MapVertex<V['val']> = MapVertex, E exten
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
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`.
59
+ * is of type `V`, which means it should be of the same type as the `val` 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, val?: 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.
@@ -73,7 +73,7 @@ export declare class MapGraph<V extends MapVertex<V['val']> = MapVertex, E exten
73
73
  * If the weight is not provided, it can be set to a default value or left undefined.
74
74
  * @param [val] - The `val` 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, val?: E): EO;
79
79
  }
@@ -15,7 +15,7 @@ class MapVertex extends directed_graph_1.DirectedVertex {
15
15
  * @param {V} [val] - The "val" 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) {
18
+ constructor(key, val, lat, long) {
19
19
  super(key, val);
20
20
  this._lat = lat;
21
21
  this._long = long;
@@ -44,7 +44,7 @@ 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} [val] - The "val" 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
50
  constructor(src, dest, weight, val) {
@@ -86,14 +86,14 @@ class MapGraph extends directed_graph_1.DirectedGraph {
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
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`.
89
+ * is of type `V`, which means it should be of the same type as the `val` 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, val, lat = this.origin[0], long = this.origin[1]) {
96
+ return new MapVertex(key, val, 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.
@@ -105,7 +105,7 @@ class MapGraph extends directed_graph_1.DirectedGraph {
105
105
  * If the weight is not provided, it can be set to a default value or left undefined.
106
106
  * @param [val] - The `val` 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
110
  createEdge(src, dest, weight, val) {
111
111
  return new MapEdge(src, dest, weight, val);
@@ -11,7 +11,7 @@ export declare class UndirectedVertex<V = any> extends AbstractVertex<V> {
11
11
  */
12
12
  constructor(key: VertexKey, val?: 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,21 +19,21 @@ 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} [val] - The "val" 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, val?: 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
@@ -41,9 +41,9 @@ export declare class UndirectedGraph<V extends UndirectedVertex<any> = Undirecte
41
41
  * @param [val] - The `val` 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, val?: VO['val']): 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.
@@ -52,76 +52,76 @@ export declare class UndirectedGraph<V extends UndirectedVertex<any> = Undirecte
52
52
  * no weight is provided, it defaults to 1.
53
53
  * @param [val] - The `val` 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, val?: EO['val']): 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 | null | VertexKey} 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 | null | VertexKey} 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 | null | VertexKey, v2: VO | null | VertexKey): 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
  }
@@ -31,7 +31,7 @@ class UndirectedEdge extends abstract_graph_1.AbstractEdge {
31
31
  * @param {VertexKey} v2 - The parameter `v2` is a `VertexKey`, which represents the identifier of the second vertex in a
32
32
  * graph edge.
33
33
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
34
- * @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to store a value associated
34
+ * @param {E} [val] - The "val" parameter is an optional parameter of type E. It is used to store a value associated
35
35
  * with the edge.
36
36
  */
37
37
  constructor(v1, v2, weight, val) {
@@ -66,7 +66,7 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
66
66
  * @param [val] - The `val` parameter is an optional value that can be assigned to the vertex. If a value is provided,
67
67
  * 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
68
68
  * the vertex.
69
- * @returns The method is returning a new instance of the `UndirectedVertex` class, casted as type `V`.
69
+ * @returns The method is returning a new instance of the `UndirectedVertex` class, casted as type `VO`.
70
70
  */
71
71
  createVertex(key, val) {
72
72
  return new UndirectedVertex(key, val ?? key);
@@ -79,18 +79,18 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
79
79
  * no weight is provided, it defaults to 1.
80
80
  * @param [val] - The `val` parameter is an optional value that can be assigned to the edge. It can be of any type and
81
81
  * is used to store additional information or data associated with the edge.
82
- * @returns a new instance of the `UndirectedEdge` class, which is casted as type `E`.
82
+ * @returns a new instance of the `UndirectedEdge` class, which is casted as type `EO`.
83
83
  */
84
84
  createEdge(v1, v2, weight, val) {
85
85
  return new UndirectedEdge(v1, v2, weight ?? 1, val);
86
86
  }
87
87
  /**
88
88
  * The function `getEdge` returns the first edge that connects two vertices, or null if no such edge exists.
89
- * @param {V | null | VertexKey} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `V` (vertex
89
+ * @param {VO | null | VertexKey} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `VO` (vertex
90
90
  * object), `null`, or `VertexKey` (a string or number representing the ID of a vertex).
91
- * @param {V | null | VertexKey} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `V` (vertex
91
+ * @param {VO | null | VertexKey} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `VO` (vertex
92
92
  * object), `null`, or `VertexKey` (vertex ID).
93
- * @returns an edge (E) or null.
93
+ * @returns an edge (EO) or null.
94
94
  */
95
95
  getEdge(v1, v2) {
96
96
  let edges = [];
@@ -105,10 +105,10 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
105
105
  }
106
106
  /**
107
107
  * The function removes an edge between two vertices in a graph and returns the removed edge.
108
- * @param {V | VertexKey} v1 - The parameter `v1` represents either a vertex object (`V`) or a vertex ID (`VertexKey`).
109
- * @param {V | VertexKey} v2 - V | VertexKey - This parameter can be either a vertex object (V) or a vertex ID
108
+ * @param {VO | VertexKey} v1 - The parameter `v1` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).
109
+ * @param {VO | VertexKey} v2 - VO | VertexKey - This parameter can be either a vertex object (VO) or a vertex ID
110
110
  * (VertexKey). It represents the second vertex of the edge that needs to be removed.
111
- * @returns the removed edge (E) if it exists, or null if either of the vertices (V) does not exist.
111
+ * @returns the removed edge (EO) if it exists, or null if either of the vertices (VO) does not exist.
112
112
  */
113
113
  deleteEdgeBetween(v1, v2) {
114
114
  const vertex1 = this._getVertex(v1);
@@ -129,8 +129,8 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
129
129
  }
130
130
  /**
131
131
  * The deleteEdge function removes an edge between two vertices in a graph.
132
- * @param {E} edge - The parameter "edge" is of type E, which represents an edge in a graph.
133
- * @returns The method is returning either the removed edge (of type E) or null if the edge was not found.
132
+ * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
133
+ * @returns The method is returning either the removed edge (of type EO) or null if the edge was not found.
134
134
  */
135
135
  deleteEdge(edge) {
136
136
  return this.deleteEdgeBetween(edge.vertices[0], edge.vertices[1]);
@@ -138,7 +138,7 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
138
138
  /**
139
139
  * The function `degreeOf` returns the degree of a vertex in a graph, which is the number of edges connected to that
140
140
  * vertex.
141
- * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`.
141
+ * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
142
142
  * @returns The function `degreeOf` returns the degree of a vertex in a graph. The degree of a vertex is the number of
143
143
  * edges connected to that vertex.
144
144
  */
@@ -153,8 +153,8 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
153
153
  }
154
154
  /**
155
155
  * The function returns the edges of a given vertex or vertex ID.
156
- * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`. A `VertexKey` is a
157
- * unique identifier for a vertex in a graph, while `V` represents the type of the vertex.
156
+ * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`. A `VertexKey` is a
157
+ * unique identifier for a vertex in a graph, while `VO` represents the type of the vertex.
158
158
  * @returns an array of edges.
159
159
  */
160
160
  edgesOf(vertexOrKey) {
@@ -168,7 +168,7 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
168
168
  }
169
169
  /**
170
170
  * The function "edgeSet" returns an array of unique edges from a set of edges.
171
- * @returns The method `edgeSet()` returns an array of type `E[]`.
171
+ * @returns The method `edgeSet()` returns an array of type `EO[]`.
172
172
  */
173
173
  edgeSet() {
174
174
  const edgeSet = new Set();
@@ -181,9 +181,9 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
181
181
  }
182
182
  /**
183
183
  * The function "getNeighbors" returns an array of neighboring vertices for a given vertex or vertex ID.
184
- * @param {V | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`V`) or a vertex ID
184
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
185
185
  * (`VertexKey`).
186
- * @returns an array of vertices (V[]).
186
+ * @returns an array of vertices (VO[]).
187
187
  */
188
188
  getNeighbors(vertexOrKey) {
189
189
  const neighbors = [];
@@ -202,8 +202,8 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
202
202
  /**
203
203
  * The function "getEndsOfEdge" returns the vertices at the ends of an edge if the edge exists in the graph, otherwise
204
204
  * it returns null.
205
- * @param {E} edge - The parameter "edge" is of type E, which represents an edge in a graph.
206
- * @returns The function `getEndsOfEdge` returns an array containing two vertices `[V, V]` if the edge exists in the
205
+ * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
206
+ * @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
207
207
  * graph. If the edge does not exist, it returns `null`.
208
208
  */
209
209
  getEndsOfEdge(edge) {
@@ -221,7 +221,7 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
221
221
  }
222
222
  /**
223
223
  * The function adds an edge to the graph by updating the adjacency list with the vertices of the edge.
224
- * @param {E} edge - The parameter "edge" is of type E, which represents an edge in a graph.
224
+ * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
225
225
  * @returns a boolean value.
226
226
  */
227
227
  _addEdgeOnly(edge) {
@@ -243,7 +243,7 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
243
243
  }
244
244
  /**
245
245
  * The function sets the edges of a graph.
246
- * @param v - A map where the keys are of type V and the values are arrays of type E.
246
+ * @param v - A map where the keys are of type VO and the values are arrays of type EO.
247
247
  */
248
248
  _setEdges(v) {
249
249
  this._edges = v;
@@ -4,7 +4,7 @@
4
4
  * @class
5
5
  */
6
6
  import { SinglyLinkedList } from '../linked-list';
7
- export declare class LinkedListQueue<E = any> extends SinglyLinkedList<E> {
7
+ export declare class SkipQueue<E = any> extends SinglyLinkedList<E> {
8
8
  /**
9
9
  * The enqueue function adds a value to the end of an array.
10
10
  * @param {E} value - The value parameter represents the value that you want to add to the queue.