linked-list-typed 1.48.3 → 1.48.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/data-structures/base/iterable-base.d.ts +6 -6
  2. package/dist/data-structures/base/iterable-base.js +3 -3
  3. package/dist/data-structures/binary-tree/avl-tree.d.ts +5 -3
  4. package/dist/data-structures/binary-tree/avl-tree.js +6 -4
  5. package/dist/data-structures/binary-tree/binary-tree.d.ts +18 -15
  6. package/dist/data-structures/binary-tree/binary-tree.js +16 -13
  7. package/dist/data-structures/binary-tree/bst.d.ts +15 -11
  8. package/dist/data-structures/binary-tree/bst.js +17 -13
  9. package/dist/data-structures/binary-tree/rb-tree.d.ts +19 -13
  10. package/dist/data-structures/binary-tree/rb-tree.js +20 -14
  11. package/dist/data-structures/binary-tree/tree-multimap.d.ts +21 -14
  12. package/dist/data-structures/binary-tree/tree-multimap.js +25 -18
  13. package/dist/data-structures/graph/abstract-graph.d.ts +53 -52
  14. package/dist/data-structures/graph/abstract-graph.js +82 -78
  15. package/dist/data-structures/graph/directed-graph.d.ts +70 -52
  16. package/dist/data-structures/graph/directed-graph.js +111 -65
  17. package/dist/data-structures/graph/map-graph.d.ts +5 -5
  18. package/dist/data-structures/graph/map-graph.js +8 -8
  19. package/dist/data-structures/graph/undirected-graph.d.ts +51 -32
  20. package/dist/data-structures/graph/undirected-graph.js +117 -54
  21. package/dist/data-structures/hash/hash-map.d.ts +8 -8
  22. package/dist/data-structures/hash/hash-map.js +2 -2
  23. package/dist/interfaces/binary-tree.d.ts +1 -1
  24. package/dist/types/data-structures/base/base.d.ts +3 -3
  25. package/package.json +2 -2
  26. package/src/data-structures/base/iterable-base.ts +6 -6
  27. package/src/data-structures/binary-tree/avl-tree.ts +8 -5
  28. package/src/data-structures/binary-tree/binary-tree.ts +23 -19
  29. package/src/data-structures/binary-tree/bst.ts +19 -14
  30. package/src/data-structures/binary-tree/rb-tree.ts +20 -14
  31. package/src/data-structures/binary-tree/tree-multimap.ts +27 -19
  32. package/src/data-structures/graph/abstract-graph.ts +87 -82
  33. package/src/data-structures/graph/directed-graph.ts +114 -65
  34. package/src/data-structures/graph/map-graph.ts +8 -8
  35. package/src/data-structures/graph/undirected-graph.ts +124 -56
  36. package/src/data-structures/hash/hash-map.ts +8 -8
  37. package/src/interfaces/binary-tree.ts +1 -1
  38. package/src/types/data-structures/base/base.ts +3 -3
@@ -28,7 +28,7 @@ export class DirectedEdge<E = any> extends AbstractEdge<E> {
28
28
  dest: VertexKey;
29
29
 
30
30
  /**
31
- * The constructor function initializes the source and destination vertices of an edge, along with an optional weight
31
+ * The constructor function initializes the source and destination vertexMap of an edge, along with an optional weight
32
32
  * and value.
33
33
  * @param {VertexKey} src - The `src` parameter is the source vertex ID. It represents the starting point of an edge in
34
34
  * a graph.
@@ -80,7 +80,7 @@ export class DirectedGraph<
80
80
  /**
81
81
  * The function creates a new vertex with an optional value and returns it.
82
82
  * @param {VertexKey} key - The `key` parameter is the unique identifier for the vertex. It is of type `VertexKey`, which
83
- * could be a number or a string depending on how you want to identify your vertices.
83
+ * could be a number or a string depending on how you want to identify your vertexMap.
84
84
  * @param [value] - The 'value' parameter is an optional value that can be assigned to the vertex. If a value is provided,
85
85
  * it will be assigned to the 'value' property of the vertex. If no value is provided, the 'value' property will be
86
86
  * assigned the same value as the 'key' parameter
@@ -96,7 +96,7 @@ export class DirectedGraph<
96
96
  */
97
97
 
98
98
  /**
99
- * The function creates a directed edge between two vertices with an optional weight and value.
99
+ * The function creates a directed edge between two vertexMap with an optional weight and value.
100
100
  * @param {VertexKey} src - The source vertex ID of the edge. It represents the starting point of the edge.
101
101
  * @param {VertexKey} dest - The `dest` parameter is the identifier of the destination vertex for the edge.
102
102
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge. If no
@@ -110,23 +110,23 @@ export class DirectedGraph<
110
110
  }
111
111
 
112
112
  /**
113
- * Time Complexity: O(|V|) where |V| is the number of vertices
113
+ * Time Complexity: O(|V|) where |V| is the number of vertexMap
114
114
  * Space Complexity: O(1)
115
115
  */
116
116
 
117
117
  /**
118
- * Time Complexity: O(|V|) where |V| is the number of vertices
118
+ * Time Complexity: O(|V|) where |V| is the number of vertexMap
119
119
  * Space Complexity: O(1)
120
120
  *
121
- * The `getEdge` function retrieves an edge between two vertices based on their source and destination IDs.
121
+ * The `getEdge` function retrieves an edge between two vertexMap based on their source and destination IDs.
122
122
  * @param {VO | VertexKey | undefined} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
123
123
  * @param {VO | VertexKey | undefined} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
124
124
  * destination vertex of the edge. It can be either a vertex object (`VO`), a vertex ID (`VertexKey`), or `undefined` if the
125
125
  * destination is not specified.
126
- * @returns the first edge found between the source and destination vertices, or undefined if no such edge is found.
126
+ * @returns the first edge found between the source and destination vertexMap, or undefined if no such edge is found.
127
127
  */
128
128
  getEdge(srcOrKey: VO | VertexKey | undefined, destOrKey: VO | VertexKey | undefined): EO | undefined {
129
- let edges: EO[] = [];
129
+ let edgeMap: EO[] = [];
130
130
 
131
131
  if (srcOrKey !== undefined && destOrKey !== undefined) {
132
132
  const src: VO | undefined = this._getVertex(srcOrKey);
@@ -135,24 +135,24 @@ export class DirectedGraph<
135
135
  if (src && dest) {
136
136
  const srcOutEdges = this._outEdgeMap.get(src);
137
137
  if (srcOutEdges) {
138
- edges = srcOutEdges.filter(edge => edge.dest === dest.key);
138
+ edgeMap = srcOutEdges.filter(edge => edge.dest === dest.key);
139
139
  }
140
140
  }
141
141
  }
142
142
 
143
- return edges[0] || undefined;
143
+ return edgeMap[0] || undefined;
144
144
  }
145
145
 
146
146
  /**
147
- * Time Complexity: O(|E|) where |E| is the number of edges
147
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
148
148
  * Space Complexity: O(1)
149
149
  */
150
150
 
151
151
  /**
152
- * Time Complexity: O(|E|) where |E| is the number of edges
152
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
153
153
  * Space Complexity: O(1)
154
154
  *
155
- * The function removes an edge between two vertices in a graph and returns the removed edge.
155
+ * The function removes an edge between two vertexMap in a graph and returns the removed edge.
156
156
  * @param {VO | VertexKey} srcOrKey - The source vertex or its ID.
157
157
  * @param {VO | VertexKey} destOrKey - The `destOrKey` parameter represents the destination vertex or its ID.
158
158
  * @returns the removed edge (EO) if it exists, or undefined if either the source or destination vertex does not exist.
@@ -178,32 +178,48 @@ export class DirectedGraph<
178
178
  }
179
179
 
180
180
  /**
181
- * Time Complexity: O(|E|) where |E| is the number of edges
181
+ * Time Complexity: O(E) where E is the number of edgeMap
182
182
  * Space Complexity: O(1)
183
183
  */
184
184
 
185
+
185
186
  /**
186
- * Time Complexity: O(|E|) where |E| is the number of edges
187
+ * Time Complexity: O(E) where E is the number of edgeMap
187
188
  * Space Complexity: O(1)
188
189
  *
189
- * The function removes an edge from a graph and returns the removed edge, or undefined if the edge was not found.
190
- * @param {EO} edge - The `edge` parameter is an object that represents an edge in a graph. It has two properties: `src`
191
- * and `dest`, which represent the source and destination vertices of the edge, respectively.
192
- * @returns The method `deleteEdge` returns the removed edge (`EO`) if it exists, or `undefined` if the edge does not exist.
193
- */
194
- deleteEdge(edge: EO): EO | undefined {
190
+ * The `deleteEdge` function removes an edge from a graph and returns the removed edge.
191
+ * @param {EO | VertexKey} edgeOrSrcVertexKey - The `edge` parameter can be either an `EO` object (edge object) or
192
+ * a `VertexKey` (key of a vertex).
193
+ * @param {VertexKey} [destVertexKey] - The `destVertexKey` parameter is an optional parameter that
194
+ * represents the key of the destination vertex of the edge. It is used to specify the destination
195
+ * vertex when the `edge` parameter is a vertex key. If `destVertexKey` is not provided, the function
196
+ * assumes that the `edge`
197
+ * @returns the removed edge (EO) or undefined if no edge was removed.
198
+ */
199
+ deleteEdge(edgeOrSrcVertexKey: EO | VertexKey, destVertexKey?: VertexKey): EO | undefined {
195
200
  let removed: EO | undefined = undefined;
196
- const src = this._getVertex(edge.src);
197
- const dest = this._getVertex(edge.dest);
201
+ let src: VO | undefined, dest: VO | undefined;
202
+ if (this.isVertexKey(edgeOrSrcVertexKey)) {
203
+ if (this.isVertexKey(destVertexKey)) {
204
+ src = this._getVertex(edgeOrSrcVertexKey);
205
+ dest = this._getVertex(destVertexKey);
206
+ } else {
207
+ return;
208
+ }
209
+ } else {
210
+ src = this._getVertex(edgeOrSrcVertexKey.src);
211
+ dest = this._getVertex(edgeOrSrcVertexKey.dest);
212
+ }
213
+
198
214
  if (src && dest) {
199
215
  const srcOutEdges = this._outEdgeMap.get(src);
200
216
  if (srcOutEdges && srcOutEdges.length > 0) {
201
- arrayRemove(srcOutEdges, (edge: EO) => edge.src === src.key);
217
+ arrayRemove(srcOutEdges, (edge: EO) => edge.src === src!.key && edge.dest === dest?.key);
202
218
  }
203
219
 
204
220
  const destInEdges = this._inEdgeMap.get(dest);
205
221
  if (destInEdges && destInEdges.length > 0) {
206
- removed = arrayRemove(destInEdges, (edge: EO) => edge.dest === dest.key)[0];
222
+ removed = arrayRemove(destInEdges, (edge: EO) => edge.src === src!.key && edge.dest === dest!.key)[0];
207
223
  }
208
224
  }
209
225
 
@@ -211,20 +227,53 @@ export class DirectedGraph<
211
227
  }
212
228
 
213
229
  /**
214
- * Time Complexity: O(|E|) where |E| is the number of edges
230
+ * Time Complexity: O(1) - Constant time for Map operations.
231
+ * Space Complexity: O(1) - Constant space, as it creates only a few variables.
232
+ */
233
+
234
+ /**
235
+ * Time Complexity: O(1) - Constant time for Map operations.
236
+ * Space Complexity: O(1) - Constant space, as it creates only a few variables.
237
+ *
238
+ * The `deleteVertex` function removes a vertex from a graph by its ID or by the vertex object itself.
239
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
240
+ * (`VertexKey`).
241
+ * @returns The method is returning a boolean value.
242
+ */
243
+ override deleteVertex(vertexOrKey: VO | VertexKey): boolean {
244
+ let vertexKey: VertexKey;
245
+ let vertex: VO | undefined;
246
+ if (this.isVertexKey(vertexOrKey)) {
247
+ vertex = this.getVertex(vertexOrKey);
248
+ vertexKey = vertexOrKey;
249
+ } else {
250
+ vertex = vertexOrKey;
251
+ vertexKey = this._getVertexKey(vertexOrKey)
252
+ }
253
+
254
+ if (vertex) {
255
+ this._outEdgeMap.delete(vertex)
256
+ this._inEdgeMap.delete(vertex)
257
+ }
258
+
259
+ return this._vertexMap.delete(vertexKey);
260
+ }
261
+
262
+ /**
263
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
215
264
  * Space Complexity: O(1)
216
265
  */
217
266
 
218
267
  /**
219
- * Time Complexity: O(|E|) where |E| is the number of edges
268
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
220
269
  * Space Complexity: O(1)
221
270
  *
222
- * The function removes edges between two vertices and returns the removed edges.
271
+ * The function removes edgeMap between two vertexMap and returns the removed edgeMap.
223
272
  * @param {VertexKey | VO} v1 - The parameter `v1` can be either a `VertexKey` or a `VO`. A `VertexKey` represents the
224
273
  * unique identifier of a vertex in a graph, while `VO` represents the actual vertex object.
225
274
  * @param {VertexKey | VO} v2 - The parameter `v2` represents either a `VertexKey` or a `VO` object. It is used to specify
226
275
  * the second vertex in the edge that needs to be removed.
227
- * @returns an array of removed edges (EO[]).
276
+ * @returns an array of removed edgeMap (EO[]).
228
277
  */
229
278
  deleteEdgesBetween(v1: VertexKey | VO, v2: VertexKey | VO): EO[] {
230
279
  const removed: EO[] = [];
@@ -249,10 +298,10 @@ export class DirectedGraph<
249
298
  * Time Complexity: O(1)
250
299
  * Space Complexity: O(1)
251
300
  *
252
- * The function `incomingEdgesOf` returns an array of incoming edges for a given vertex or vertex ID.
301
+ * The function `incomingEdgesOf` returns an array of incoming edgeMap for a given vertex or vertex ID.
253
302
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
254
303
  * (`VertexKey`).
255
- * @returns The method `incomingEdgesOf` returns an array of edges (`EO[]`).
304
+ * @returns The method `incomingEdgesOf` returns an array of edgeMap (`EO[]`).
256
305
  */
257
306
  incomingEdgesOf(vertexOrKey: VO | VertexKey): EO[] {
258
307
  const target = this._getVertex(vertexOrKey);
@@ -271,10 +320,10 @@ export class DirectedGraph<
271
320
  * Time Complexity: O(1)
272
321
  * Space Complexity: O(1)
273
322
  *
274
- * The function `outgoingEdgesOf` returns an array of outgoing edges from a given vertex or vertex ID.
323
+ * The function `outgoingEdgesOf` returns an array of outgoing edgeMap from a given vertex or vertex ID.
275
324
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can accept either a vertex object (`VO`) or a vertex ID
276
325
  * (`VertexKey`).
277
- * @returns The method `outgoingEdgesOf` returns an array of edges (`EO[]`).
326
+ * @returns The method `outgoingEdgesOf` returns an array of edgeMap (`EO[]`).
278
327
  */
279
328
  outgoingEdgesOf(vertexOrKey: VO | VertexKey): EO[] {
280
329
  const target = this._getVertex(vertexOrKey);
@@ -310,9 +359,9 @@ export class DirectedGraph<
310
359
  * Time Complexity: O(1)
311
360
  * Space Complexity: O(1)
312
361
  *
313
- * The function "inDegreeOf" returns the number of incoming edges for a given vertex.
362
+ * The function "inDegreeOf" returns the number of incoming edgeMap for a given vertex.
314
363
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
315
- * @returns The number of incoming edges of the specified vertex or vertex ID.
364
+ * @returns The number of incoming edgeMap of the specified vertex or vertex ID.
316
365
  */
317
366
  inDegreeOf(vertexOrKey: VertexKey | VO): number {
318
367
  return this.incomingEdgesOf(vertexOrKey).length;
@@ -327,9 +376,9 @@ export class DirectedGraph<
327
376
  * Time Complexity: O(1)
328
377
  * Space Complexity: O(1)
329
378
  *
330
- * The function `outDegreeOf` returns the number of outgoing edges from a given vertex.
379
+ * The function `outDegreeOf` returns the number of outgoing edgeMap from a given vertex.
331
380
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
332
- * @returns The number of outgoing edges from the specified vertex or vertex ID.
381
+ * @returns The number of outgoing edgeMap from the specified vertex or vertex ID.
333
382
  */
334
383
  outDegreeOf(vertexOrKey: VertexKey | VO): number {
335
384
  return this.outgoingEdgesOf(vertexOrKey).length;
@@ -344,9 +393,9 @@ export class DirectedGraph<
344
393
  * Time Complexity: O(1)
345
394
  * Space Complexity: O(1)
346
395
  *
347
- * The function "edgesOf" returns an array of both outgoing and incoming edges of a given vertex or vertex ID.
396
+ * The function "edgesOf" returns an array of both outgoing and incoming edgeMap of a given vertex or vertex ID.
348
397
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
349
- * @returns The function `edgesOf` returns an array of edges.
398
+ * @returns The function `edgesOf` returns an array of edgeMap.
350
399
  */
351
400
  edgesOf(vertexOrKey: VertexKey | VO): EO[] {
352
401
  return [...this.outgoingEdgesOf(vertexOrKey), ...this.incomingEdgesOf(vertexOrKey)];
@@ -387,18 +436,18 @@ export class DirectedGraph<
387
436
  }
388
437
 
389
438
  /**
390
- * Time Complexity: O(|E|) where |E| is the number of edges
439
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
391
440
  * Space Complexity: O(1)
392
441
  */
393
442
 
394
443
  /**
395
- * Time Complexity: O(|E|) where |E| is the number of edges
444
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
396
445
  * Space Complexity: O(1)
397
446
  *
398
- * The function `getDestinations` returns an array of destination vertices connected to a given vertex.
447
+ * The function `getDestinations` returns an array of destination vertexMap connected to a given vertex.
399
448
  * @param {VO | VertexKey | undefined} vertex - The `vertex` parameter represents the starting vertex from which we want to
400
449
  * find the destinations. It can be either a `VO` object, a `VertexKey` value, or `undefined`.
401
- * @returns an array of vertices (VO[]).
450
+ * @returns an array of vertexMap (VO[]).
402
451
  */
403
452
  getDestinations(vertex: VO | VertexKey | undefined): VO[] {
404
453
  if (vertex === undefined) {
@@ -416,27 +465,27 @@ export class DirectedGraph<
416
465
  }
417
466
 
418
467
  /**
419
- * Time Complexity: O(|V| + |E|) where |V| is the number of vertices and |E| is the number of edges
468
+ * Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
420
469
  * Space Complexity: O(|V|)
421
470
  */
422
471
 
423
472
  /**
424
- * Time Complexity: O(|V| + |E|) where |V| is the number of vertices and |E| is the number of edges
473
+ * Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
425
474
  * Space Complexity: O(|V|)
426
475
  *
427
- * The `topologicalSort` function performs a topological sort on a graph and returns an array of vertices or vertex IDs
476
+ * The `topologicalSort` function performs a topological sort on a graph and returns an array of vertexMap or vertex IDs
428
477
  * in the sorted order, or undefined if the graph contains a cycle.
429
478
  * @param {'vertex' | 'key'} [propertyName] - The `propertyName` parameter is an optional parameter that specifies the
430
- * property to use for sorting the vertices. It can have two possible values: 'vertex' or 'key'. If 'vertex' is
431
- * specified, the vertices themselves will be used for sorting. If 'key' is specified, the ids of
432
- * @returns an array of vertices or vertex IDs in topological order. If there is a cycle in the graph, it returns undefined.
479
+ * property to use for sorting the vertexMap. It can have two possible values: 'vertex' or 'key'. If 'vertex' is
480
+ * specified, the vertexMap themselves will be used for sorting. If 'key' is specified, the ids of
481
+ * @returns an array of vertexMap or vertex IDs in topological order. If there is a cycle in the graph, it returns undefined.
433
482
  */
434
483
  topologicalSort(propertyName?: 'vertex' | 'key'): Array<VO | VertexKey> | undefined {
435
484
  propertyName = propertyName ?? 'key';
436
485
  // When judging whether there is a cycle in the undirected graph, all nodes with degree of **<= 1** are enqueued
437
486
  // When judging whether there is a cycle in the directed graph, all nodes with **in degree = 0** are enqueued
438
487
  const statusMap: Map<VO | VertexKey, TopologicalStatus> = new Map<VO | VertexKey, TopologicalStatus>();
439
- for (const entry of this.vertices) {
488
+ for (const entry of this.vertexMap) {
440
489
  statusMap.set(entry[1], 0);
441
490
  }
442
491
 
@@ -457,7 +506,7 @@ export class DirectedGraph<
457
506
  sorted.push(cur);
458
507
  };
459
508
 
460
- for (const entry of this.vertices) {
509
+ for (const entry of this.vertexMap) {
461
510
  if (statusMap.get(entry[1]) === 0) {
462
511
  dfs(entry[1]);
463
512
  }
@@ -470,38 +519,38 @@ export class DirectedGraph<
470
519
  }
471
520
 
472
521
  /**
473
- * Time Complexity: O(|E|) where |E| is the number of edges
522
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
474
523
  * Space Complexity: O(|E|)
475
524
  */
476
525
 
477
526
  /**
478
- * Time Complexity: O(|E|) where |E| is the number of edges
527
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
479
528
  * Space Complexity: O(|E|)
480
529
  *
481
- * The `edgeSet` function returns an array of all the edges in the graph.
482
- * @returns The `edgeSet()` method returns an array of edges (`EO[]`).
530
+ * The `edgeSet` function returns an array of all the edgeMap in the graph.
531
+ * @returns The `edgeSet()` method returns an array of edgeMap (`EO[]`).
483
532
  */
484
533
  edgeSet(): EO[] {
485
- let edges: EO[] = [];
534
+ let edgeMap: EO[] = [];
486
535
  this._outEdgeMap.forEach(outEdges => {
487
- edges = [...edges, ...outEdges];
536
+ edgeMap = [...edgeMap, ...outEdges];
488
537
  });
489
- return edges;
538
+ return edgeMap;
490
539
  }
491
540
 
492
541
  /**
493
- * Time Complexity: O(|E|) where |E| is the number of edges
542
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
494
543
  * Space Complexity: O(1)
495
544
  */
496
545
 
497
546
  /**
498
- * Time Complexity: O(|E|) where |E| is the number of edges
547
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
499
548
  * Space Complexity: O(1)
500
549
  *
501
- * The function `getNeighbors` returns an array of neighboring vertices of a given vertex or vertex ID in a graph.
550
+ * The function `getNeighbors` returns an array of neighboring vertexMap of a given vertex or vertex ID in a graph.
502
551
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
503
552
  * (`VertexKey`).
504
- * @returns an array of vertices (VO[]).
553
+ * @returns an array of vertexMap (VO[]).
505
554
  */
506
555
  getNeighbors(vertexOrKey: VO | VertexKey): VO[] {
507
556
  const neighbors: VO[] = [];
@@ -528,10 +577,10 @@ export class DirectedGraph<
528
577
  * Time Complexity: O(1)
529
578
  * Space Complexity: O(1)
530
579
  *
531
- * The function "getEndsOfEdge" returns the source and destination vertices of an edge if it exists in the graph,
580
+ * The function "getEndsOfEdge" returns the source and destination vertexMap of an edge if it exists in the graph,
532
581
  * otherwise it returns undefined.
533
582
  * @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph.
534
- * @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
583
+ * @returns The function `getEndsOfEdge` returns an array containing two vertexMap `[VO, VO]` if the edge exists in the
535
584
  * graph. If the edge does not exist, it returns `undefined`.
536
585
  */
537
586
  getEndsOfEdge(edge: EO): [VO, VO] | undefined {
@@ -556,7 +605,7 @@ export class DirectedGraph<
556
605
  * Time Complexity: O(1)
557
606
  * Space Complexity: O(1)
558
607
  *
559
- * The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertices exist.
608
+ * The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertexMap exist.
560
609
  * @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph. It is the edge that
561
610
  * needs to be added to the graph.
562
611
  * @returns a boolean value. It returns true if the edge was successfully added to the graph, and false if either the
@@ -47,24 +47,24 @@ export class MapGraph<
47
47
  EO extends MapEdge<E> = MapEdge<E>
48
48
  > extends DirectedGraph<V, E, VO, EO> {
49
49
  /**
50
- * The constructor function initializes the origin and bottomRight properties of a MapGraphCoordinate object.
51
- * @param {MapGraphCoordinate} origin - The `origin` parameter is a `MapGraphCoordinate` object that represents the
50
+ * The constructor function initializes the originCoord and bottomRight properties of a MapGraphCoordinate object.
51
+ * @param {MapGraphCoordinate} originCoord - The `originCoord` parameter is a `MapGraphCoordinate` object that represents the
52
52
  * starting point or reference point of the map graph. It defines the coordinates of the top-left corner of the map
53
53
  * graph.
54
54
  * @param {MapGraphCoordinate} [bottomRight] - The `bottomRight` parameter is an optional parameter of type
55
55
  * `MapGraphCoordinate`. It represents the bottom right coordinate of a map graph. If this parameter is not provided,
56
56
  * it will default to `undefined`.
57
57
  */
58
- constructor(origin: MapGraphCoordinate, bottomRight?: MapGraphCoordinate) {
58
+ constructor(originCoord: MapGraphCoordinate, bottomRight?: MapGraphCoordinate) {
59
59
  super();
60
- this._origin = origin;
60
+ this._originCoord = originCoord;
61
61
  this._bottomRight = bottomRight;
62
62
  }
63
63
 
64
- protected _origin: MapGraphCoordinate = [0, 0];
64
+ protected _originCoord: MapGraphCoordinate = [0, 0];
65
65
 
66
- get origin(): MapGraphCoordinate {
67
- return this._origin;
66
+ get originCoord(): MapGraphCoordinate {
67
+ return this._originCoord;
68
68
  }
69
69
 
70
70
  protected _bottomRight: MapGraphCoordinate | undefined;
@@ -84,7 +84,7 @@ export class MapGraph<
84
84
  * @param {number} long - The `long` parameter represents the longitude coordinate of the vertex.
85
85
  * @returns The method is returning a new instance of the `MapVertex` class, casted as type `VO`.
86
86
  */
87
- override createVertex(key: VertexKey, value?: V, lat: number = this.origin[0], long: number = this.origin[1]): VO {
87
+ override createVertex(key: VertexKey, value?: V, lat: number = this.originCoord[0], long: number = this.originCoord[1]): VO {
88
88
  return new MapVertex(key, value, lat, long) as VO;
89
89
  }
90
90