data-structure-typed 1.48.4 → 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 (83) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/cjs/data-structures/base/iterable-base.d.ts +6 -6
  3. package/dist/cjs/data-structures/base/iterable-base.js +3 -3
  4. package/dist/cjs/data-structures/base/iterable-base.js.map +1 -1
  5. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +5 -3
  6. package/dist/cjs/data-structures/binary-tree/avl-tree.js +6 -4
  7. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  8. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +18 -15
  9. package/dist/cjs/data-structures/binary-tree/binary-tree.js +16 -13
  10. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  11. package/dist/cjs/data-structures/binary-tree/bst.d.ts +15 -11
  12. package/dist/cjs/data-structures/binary-tree/bst.js +17 -13
  13. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  14. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +19 -13
  15. package/dist/cjs/data-structures/binary-tree/rb-tree.js +20 -14
  16. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  17. package/dist/cjs/data-structures/binary-tree/tree-multimap.d.ts +21 -14
  18. package/dist/cjs/data-structures/binary-tree/tree-multimap.js +25 -18
  19. package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
  20. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +52 -52
  21. package/dist/cjs/data-structures/graph/abstract-graph.js +78 -78
  22. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  23. package/dist/cjs/data-structures/graph/directed-graph.d.ts +47 -47
  24. package/dist/cjs/data-structures/graph/directed-graph.js +56 -56
  25. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  26. package/dist/cjs/data-structures/graph/map-graph.d.ts +5 -5
  27. package/dist/cjs/data-structures/graph/map-graph.js +8 -8
  28. package/dist/cjs/data-structures/graph/map-graph.js.map +1 -1
  29. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +29 -29
  30. package/dist/cjs/data-structures/graph/undirected-graph.js +57 -57
  31. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  32. package/dist/cjs/data-structures/hash/hash-map.d.ts +8 -8
  33. package/dist/cjs/data-structures/hash/hash-map.js +2 -2
  34. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  35. package/dist/cjs/interfaces/binary-tree.d.ts +1 -1
  36. package/dist/cjs/types/data-structures/base/base.d.ts +3 -3
  37. package/dist/mjs/data-structures/base/iterable-base.d.ts +6 -6
  38. package/dist/mjs/data-structures/base/iterable-base.js +1 -1
  39. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +5 -3
  40. package/dist/mjs/data-structures/binary-tree/avl-tree.js +6 -4
  41. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +18 -15
  42. package/dist/mjs/data-structures/binary-tree/binary-tree.js +17 -14
  43. package/dist/mjs/data-structures/binary-tree/bst.d.ts +15 -11
  44. package/dist/mjs/data-structures/binary-tree/bst.js +17 -13
  45. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +19 -13
  46. package/dist/mjs/data-structures/binary-tree/rb-tree.js +20 -14
  47. package/dist/mjs/data-structures/binary-tree/tree-multimap.d.ts +21 -14
  48. package/dist/mjs/data-structures/binary-tree/tree-multimap.js +25 -18
  49. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +52 -52
  50. package/dist/mjs/data-structures/graph/abstract-graph.js +79 -79
  51. package/dist/mjs/data-structures/graph/directed-graph.d.ts +47 -47
  52. package/dist/mjs/data-structures/graph/directed-graph.js +56 -56
  53. package/dist/mjs/data-structures/graph/map-graph.d.ts +5 -5
  54. package/dist/mjs/data-structures/graph/map-graph.js +8 -8
  55. package/dist/mjs/data-structures/graph/undirected-graph.d.ts +29 -29
  56. package/dist/mjs/data-structures/graph/undirected-graph.js +59 -59
  57. package/dist/mjs/data-structures/hash/hash-map.d.ts +8 -8
  58. package/dist/mjs/data-structures/hash/hash-map.js +3 -3
  59. package/dist/mjs/interfaces/binary-tree.d.ts +1 -1
  60. package/dist/mjs/types/data-structures/base/base.d.ts +3 -3
  61. package/dist/umd/data-structure-typed.js +302 -280
  62. package/dist/umd/data-structure-typed.min.js +2 -2
  63. package/dist/umd/data-structure-typed.min.js.map +1 -1
  64. package/package.json +1 -1
  65. package/src/data-structures/base/iterable-base.ts +6 -6
  66. package/src/data-structures/binary-tree/avl-tree.ts +8 -5
  67. package/src/data-structures/binary-tree/binary-tree.ts +23 -19
  68. package/src/data-structures/binary-tree/bst.ts +19 -14
  69. package/src/data-structures/binary-tree/rb-tree.ts +20 -14
  70. package/src/data-structures/binary-tree/tree-multimap.ts +27 -19
  71. package/src/data-structures/graph/abstract-graph.ts +82 -82
  72. package/src/data-structures/graph/directed-graph.ts +56 -56
  73. package/src/data-structures/graph/map-graph.ts +8 -8
  74. package/src/data-structures/graph/undirected-graph.ts +59 -59
  75. package/src/data-structures/hash/hash-map.ts +8 -8
  76. package/src/interfaces/binary-tree.ts +1 -1
  77. package/src/types/data-structures/base/base.ts +3 -3
  78. package/test/integration/bst.test.ts +1 -1
  79. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +1 -1
  80. package/test/unit/data-structures/binary-tree/tree-multimap.test.ts +3 -3
  81. package/test/unit/data-structures/graph/directed-graph.test.ts +15 -15
  82. package/test/unit/data-structures/graph/map-graph.test.ts +3 -3
  83. package/test/unit/data-structures/graph/undirected-graph.test.ts +12 -12
@@ -15,7 +15,7 @@ export declare class DirectedEdge<E = any> extends AbstractEdge<E> {
15
15
  src: VertexKey;
16
16
  dest: VertexKey;
17
17
  /**
18
- * The constructor function initializes the source and destination vertices of an edge, along with an optional weight
18
+ * The constructor function initializes the source and destination vertexMap of an edge, along with an optional weight
19
19
  * and value.
20
20
  * @param {VertexKey} src - The `src` parameter is the source vertex ID. It represents the starting point of an edge in
21
21
  * a graph.
@@ -43,7 +43,7 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
43
43
  /**
44
44
  * The function creates a new vertex with an optional value and returns it.
45
45
  * @param {VertexKey} key - The `key` parameter is the unique identifier for the vertex. It is of type `VertexKey`, which
46
- * could be a number or a string depending on how you want to identify your vertices.
46
+ * could be a number or a string depending on how you want to identify your vertexMap.
47
47
  * @param [value] - The 'value' parameter is an optional value that can be assigned to the vertex. If a value is provided,
48
48
  * it will be assigned to the 'value' property of the vertex. If no value is provided, the 'value' property will be
49
49
  * assigned the same value as the 'key' parameter
@@ -55,7 +55,7 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
55
55
  * This means that using abstract methods in the parent class cannot constrain the grandchild classes. Defining methods within an interface also cannot constrain the descendant classes. When inheriting from this class, developers need to be aware that this method needs to be overridden.
56
56
  */
57
57
  /**
58
- * The function creates a directed edge between two vertices with an optional weight and value.
58
+ * The function creates a directed edge between two vertexMap with an optional weight and value.
59
59
  * @param {VertexKey} src - The source vertex ID of the edge. It represents the starting point of the edge.
60
60
  * @param {VertexKey} dest - The `dest` parameter is the identifier of the destination vertex for the edge.
61
61
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge. If no
@@ -66,41 +66,41 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
66
66
  */
67
67
  createEdge(src: VertexKey, dest: VertexKey, weight?: number, value?: E): EO;
68
68
  /**
69
- * Time Complexity: O(|V|) where |V| is the number of vertices
69
+ * Time Complexity: O(|V|) where |V| is the number of vertexMap
70
70
  * Space Complexity: O(1)
71
71
  */
72
72
  /**
73
- * Time Complexity: O(|V|) where |V| is the number of vertices
73
+ * Time Complexity: O(|V|) where |V| is the number of vertexMap
74
74
  * Space Complexity: O(1)
75
75
  *
76
- * The `getEdge` function retrieves an edge between two vertices based on their source and destination IDs.
76
+ * The `getEdge` function retrieves an edge between two vertexMap based on their source and destination IDs.
77
77
  * @param {VO | VertexKey | undefined} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
78
78
  * @param {VO | VertexKey | undefined} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
79
79
  * destination vertex of the edge. It can be either a vertex object (`VO`), a vertex ID (`VertexKey`), or `undefined` if the
80
80
  * destination is not specified.
81
- * @returns the first edge found between the source and destination vertices, or undefined if no such edge is found.
81
+ * @returns the first edge found between the source and destination vertexMap, or undefined if no such edge is found.
82
82
  */
83
83
  getEdge(srcOrKey: VO | VertexKey | undefined, destOrKey: VO | VertexKey | undefined): EO | undefined;
84
84
  /**
85
- * Time Complexity: O(|E|) where |E| is the number of edges
85
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
86
86
  * Space Complexity: O(1)
87
87
  */
88
88
  /**
89
- * Time Complexity: O(|E|) where |E| is the number of edges
89
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
90
90
  * Space Complexity: O(1)
91
91
  *
92
- * The function removes an edge between two vertices in a graph and returns the removed edge.
92
+ * The function removes an edge between two vertexMap in a graph and returns the removed edge.
93
93
  * @param {VO | VertexKey} srcOrKey - The source vertex or its ID.
94
94
  * @param {VO | VertexKey} destOrKey - The `destOrKey` parameter represents the destination vertex or its ID.
95
95
  * @returns the removed edge (EO) if it exists, or undefined if either the source or destination vertex does not exist.
96
96
  */
97
97
  deleteEdgeSrcToDest(srcOrKey: VO | VertexKey, destOrKey: VO | VertexKey): EO | undefined;
98
98
  /**
99
- * Time Complexity: O(E) where E is the number of edges
99
+ * Time Complexity: O(E) where E is the number of edgeMap
100
100
  * Space Complexity: O(1)
101
101
  */
102
102
  /**
103
- * Time Complexity: O(E) where E is the number of edges
103
+ * Time Complexity: O(E) where E is the number of edgeMap
104
104
  * Space Complexity: O(1)
105
105
  *
106
106
  * The `deleteEdge` function removes an edge from a graph and returns the removed edge.
@@ -128,19 +128,19 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
128
128
  */
129
129
  deleteVertex(vertexOrKey: VO | VertexKey): boolean;
130
130
  /**
131
- * Time Complexity: O(|E|) where |E| is the number of edges
131
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
132
132
  * Space Complexity: O(1)
133
133
  */
134
134
  /**
135
- * Time Complexity: O(|E|) where |E| is the number of edges
135
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
136
136
  * Space Complexity: O(1)
137
137
  *
138
- * The function removes edges between two vertices and returns the removed edges.
138
+ * The function removes edgeMap between two vertexMap and returns the removed edgeMap.
139
139
  * @param {VertexKey | VO} v1 - The parameter `v1` can be either a `VertexKey` or a `VO`. A `VertexKey` represents the
140
140
  * unique identifier of a vertex in a graph, while `VO` represents the actual vertex object.
141
141
  * @param {VertexKey | VO} v2 - The parameter `v2` represents either a `VertexKey` or a `VO` object. It is used to specify
142
142
  * the second vertex in the edge that needs to be removed.
143
- * @returns an array of removed edges (EO[]).
143
+ * @returns an array of removed edgeMap (EO[]).
144
144
  */
145
145
  deleteEdgesBetween(v1: VertexKey | VO, v2: VertexKey | VO): EO[];
146
146
  /**
@@ -151,10 +151,10 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
151
151
  * Time Complexity: O(1)
152
152
  * Space Complexity: O(1)
153
153
  *
154
- * The function `incomingEdgesOf` returns an array of incoming edges for a given vertex or vertex ID.
154
+ * The function `incomingEdgesOf` returns an array of incoming edgeMap for a given vertex or vertex ID.
155
155
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
156
156
  * (`VertexKey`).
157
- * @returns The method `incomingEdgesOf` returns an array of edges (`EO[]`).
157
+ * @returns The method `incomingEdgesOf` returns an array of edgeMap (`EO[]`).
158
158
  */
159
159
  incomingEdgesOf(vertexOrKey: VO | VertexKey): EO[];
160
160
  /**
@@ -165,10 +165,10 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
165
165
  * Time Complexity: O(1)
166
166
  * Space Complexity: O(1)
167
167
  *
168
- * The function `outgoingEdgesOf` returns an array of outgoing edges from a given vertex or vertex ID.
168
+ * The function `outgoingEdgesOf` returns an array of outgoing edgeMap from a given vertex or vertex ID.
169
169
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can accept either a vertex object (`VO`) or a vertex ID
170
170
  * (`VertexKey`).
171
- * @returns The method `outgoingEdgesOf` returns an array of edges (`EO[]`).
171
+ * @returns The method `outgoingEdgesOf` returns an array of edgeMap (`EO[]`).
172
172
  */
173
173
  outgoingEdgesOf(vertexOrKey: VO | VertexKey): EO[];
174
174
  /**
@@ -192,9 +192,9 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
192
192
  * Time Complexity: O(1)
193
193
  * Space Complexity: O(1)
194
194
  *
195
- * The function "inDegreeOf" returns the number of incoming edges for a given vertex.
195
+ * The function "inDegreeOf" returns the number of incoming edgeMap for a given vertex.
196
196
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
197
- * @returns The number of incoming edges of the specified vertex or vertex ID.
197
+ * @returns The number of incoming edgeMap of the specified vertex or vertex ID.
198
198
  */
199
199
  inDegreeOf(vertexOrKey: VertexKey | VO): number;
200
200
  /**
@@ -205,9 +205,9 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
205
205
  * Time Complexity: O(1)
206
206
  * Space Complexity: O(1)
207
207
  *
208
- * The function `outDegreeOf` returns the number of outgoing edges from a given vertex.
208
+ * The function `outDegreeOf` returns the number of outgoing edgeMap from a given vertex.
209
209
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
210
- * @returns The number of outgoing edges from the specified vertex or vertex ID.
210
+ * @returns The number of outgoing edgeMap from the specified vertex or vertex ID.
211
211
  */
212
212
  outDegreeOf(vertexOrKey: VertexKey | VO): number;
213
213
  /**
@@ -218,9 +218,9 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
218
218
  * Time Complexity: O(1)
219
219
  * Space Complexity: O(1)
220
220
  *
221
- * The function "edgesOf" returns an array of both outgoing and incoming edges of a given vertex or vertex ID.
221
+ * The function "edgesOf" returns an array of both outgoing and incoming edgeMap of a given vertex or vertex ID.
222
222
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
223
- * @returns The function `edgesOf` returns an array of edges.
223
+ * @returns The function `edgesOf` returns an array of edgeMap.
224
224
  */
225
225
  edgesOf(vertexOrKey: VertexKey | VO): EO[];
226
226
  /**
@@ -250,59 +250,59 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
250
250
  */
251
251
  getEdgeDest(e: EO): VO | undefined;
252
252
  /**
253
- * Time Complexity: O(|E|) where |E| is the number of edges
253
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
254
254
  * Space Complexity: O(1)
255
255
  */
256
256
  /**
257
- * Time Complexity: O(|E|) where |E| is the number of edges
257
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
258
258
  * Space Complexity: O(1)
259
259
  *
260
- * The function `getDestinations` returns an array of destination vertices connected to a given vertex.
260
+ * The function `getDestinations` returns an array of destination vertexMap connected to a given vertex.
261
261
  * @param {VO | VertexKey | undefined} vertex - The `vertex` parameter represents the starting vertex from which we want to
262
262
  * find the destinations. It can be either a `VO` object, a `VertexKey` value, or `undefined`.
263
- * @returns an array of vertices (VO[]).
263
+ * @returns an array of vertexMap (VO[]).
264
264
  */
265
265
  getDestinations(vertex: VO | VertexKey | undefined): VO[];
266
266
  /**
267
- * Time Complexity: O(|V| + |E|) where |V| is the number of vertices and |E| is the number of edges
267
+ * Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
268
268
  * Space Complexity: O(|V|)
269
269
  */
270
270
  /**
271
- * Time Complexity: O(|V| + |E|) where |V| is the number of vertices and |E| is the number of edges
271
+ * Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
272
272
  * Space Complexity: O(|V|)
273
273
  *
274
- * The `topologicalSort` function performs a topological sort on a graph and returns an array of vertices or vertex IDs
274
+ * The `topologicalSort` function performs a topological sort on a graph and returns an array of vertexMap or vertex IDs
275
275
  * in the sorted order, or undefined if the graph contains a cycle.
276
276
  * @param {'vertex' | 'key'} [propertyName] - The `propertyName` parameter is an optional parameter that specifies the
277
- * property to use for sorting the vertices. It can have two possible values: 'vertex' or 'key'. If 'vertex' is
278
- * specified, the vertices themselves will be used for sorting. If 'key' is specified, the ids of
279
- * @returns an array of vertices or vertex IDs in topological order. If there is a cycle in the graph, it returns undefined.
277
+ * property to use for sorting the vertexMap. It can have two possible values: 'vertex' or 'key'. If 'vertex' is
278
+ * specified, the vertexMap themselves will be used for sorting. If 'key' is specified, the ids of
279
+ * @returns an array of vertexMap or vertex IDs in topological order. If there is a cycle in the graph, it returns undefined.
280
280
  */
281
281
  topologicalSort(propertyName?: 'vertex' | 'key'): Array<VO | VertexKey> | undefined;
282
282
  /**
283
- * Time Complexity: O(|E|) where |E| is the number of edges
283
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
284
284
  * Space Complexity: O(|E|)
285
285
  */
286
286
  /**
287
- * Time Complexity: O(|E|) where |E| is the number of edges
287
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
288
288
  * Space Complexity: O(|E|)
289
289
  *
290
- * The `edgeSet` function returns an array of all the edges in the graph.
291
- * @returns The `edgeSet()` method returns an array of edges (`EO[]`).
290
+ * The `edgeSet` function returns an array of all the edgeMap in the graph.
291
+ * @returns The `edgeSet()` method returns an array of edgeMap (`EO[]`).
292
292
  */
293
293
  edgeSet(): EO[];
294
294
  /**
295
- * Time Complexity: O(|E|) where |E| is the number of edges
295
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
296
296
  * Space Complexity: O(1)
297
297
  */
298
298
  /**
299
- * Time Complexity: O(|E|) where |E| is the number of edges
299
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
300
300
  * Space Complexity: O(1)
301
301
  *
302
- * The function `getNeighbors` returns an array of neighboring vertices of a given vertex or vertex ID in a graph.
302
+ * The function `getNeighbors` returns an array of neighboring vertexMap of a given vertex or vertex ID in a graph.
303
303
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
304
304
  * (`VertexKey`).
305
- * @returns an array of vertices (VO[]).
305
+ * @returns an array of vertexMap (VO[]).
306
306
  */
307
307
  getNeighbors(vertexOrKey: VO | VertexKey): VO[];
308
308
  /**
@@ -313,10 +313,10 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
313
313
  * Time Complexity: O(1)
314
314
  * Space Complexity: O(1)
315
315
  *
316
- * The function "getEndsOfEdge" returns the source and destination vertices of an edge if it exists in the graph,
316
+ * The function "getEndsOfEdge" returns the source and destination vertexMap of an edge if it exists in the graph,
317
317
  * otherwise it returns undefined.
318
318
  * @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph.
319
- * @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
319
+ * @returns The function `getEndsOfEdge` returns an array containing two vertexMap `[VO, VO]` if the edge exists in the
320
320
  * graph. If the edge does not exist, it returns `undefined`.
321
321
  */
322
322
  getEndsOfEdge(edge: EO): [VO, VO] | undefined;
@@ -328,7 +328,7 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
328
328
  * Time Complexity: O(1)
329
329
  * Space Complexity: O(1)
330
330
  *
331
- * The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertices exist.
331
+ * The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertexMap exist.
332
332
  * @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph. It is the edge that
333
333
  * needs to be added to the graph.
334
334
  * @returns a boolean value. It returns true if the edge was successfully added to the graph, and false if either the
@@ -23,7 +23,7 @@ export class DirectedEdge extends AbstractEdge {
23
23
  src;
24
24
  dest;
25
25
  /**
26
- * The constructor function initializes the source and destination vertices of an edge, along with an optional weight
26
+ * The constructor function initializes the source and destination vertexMap of an edge, along with an optional weight
27
27
  * and value.
28
28
  * @param {VertexKey} src - The `src` parameter is the source vertex ID. It represents the starting point of an edge in
29
29
  * a graph.
@@ -61,7 +61,7 @@ export class DirectedGraph extends AbstractGraph {
61
61
  /**
62
62
  * The function creates a new vertex with an optional value and returns it.
63
63
  * @param {VertexKey} key - The `key` parameter is the unique identifier for the vertex. It is of type `VertexKey`, which
64
- * could be a number or a string depending on how you want to identify your vertices.
64
+ * could be a number or a string depending on how you want to identify your vertexMap.
65
65
  * @param [value] - The 'value' parameter is an optional value that can be assigned to the vertex. If a value is provided,
66
66
  * it will be assigned to the 'value' property of the vertex. If no value is provided, the 'value' property will be
67
67
  * assigned the same value as the 'key' parameter
@@ -75,7 +75,7 @@ export class DirectedGraph extends AbstractGraph {
75
75
  * This means that using abstract methods in the parent class cannot constrain the grandchild classes. Defining methods within an interface also cannot constrain the descendant classes. When inheriting from this class, developers need to be aware that this method needs to be overridden.
76
76
  */
77
77
  /**
78
- * The function creates a directed edge between two vertices with an optional weight and value.
78
+ * The function creates a directed edge between two vertexMap with an optional weight and value.
79
79
  * @param {VertexKey} src - The source vertex ID of the edge. It represents the starting point of the edge.
80
80
  * @param {VertexKey} dest - The `dest` parameter is the identifier of the destination vertex for the edge.
81
81
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge. If no
@@ -88,43 +88,43 @@ export class DirectedGraph extends AbstractGraph {
88
88
  return new DirectedEdge(src, dest, weight ?? 1, value);
89
89
  }
90
90
  /**
91
- * Time Complexity: O(|V|) where |V| is the number of vertices
91
+ * Time Complexity: O(|V|) where |V| is the number of vertexMap
92
92
  * Space Complexity: O(1)
93
93
  */
94
94
  /**
95
- * Time Complexity: O(|V|) where |V| is the number of vertices
95
+ * Time Complexity: O(|V|) where |V| is the number of vertexMap
96
96
  * Space Complexity: O(1)
97
97
  *
98
- * The `getEdge` function retrieves an edge between two vertices based on their source and destination IDs.
98
+ * The `getEdge` function retrieves an edge between two vertexMap based on their source and destination IDs.
99
99
  * @param {VO | VertexKey | undefined} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
100
100
  * @param {VO | VertexKey | undefined} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
101
101
  * destination vertex of the edge. It can be either a vertex object (`VO`), a vertex ID (`VertexKey`), or `undefined` if the
102
102
  * destination is not specified.
103
- * @returns the first edge found between the source and destination vertices, or undefined if no such edge is found.
103
+ * @returns the first edge found between the source and destination vertexMap, or undefined if no such edge is found.
104
104
  */
105
105
  getEdge(srcOrKey, destOrKey) {
106
- let edges = [];
106
+ let edgeMap = [];
107
107
  if (srcOrKey !== undefined && destOrKey !== undefined) {
108
108
  const src = this._getVertex(srcOrKey);
109
109
  const dest = this._getVertex(destOrKey);
110
110
  if (src && dest) {
111
111
  const srcOutEdges = this._outEdgeMap.get(src);
112
112
  if (srcOutEdges) {
113
- edges = srcOutEdges.filter(edge => edge.dest === dest.key);
113
+ edgeMap = srcOutEdges.filter(edge => edge.dest === dest.key);
114
114
  }
115
115
  }
116
116
  }
117
- return edges[0] || undefined;
117
+ return edgeMap[0] || undefined;
118
118
  }
119
119
  /**
120
- * Time Complexity: O(|E|) where |E| is the number of edges
120
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
121
121
  * Space Complexity: O(1)
122
122
  */
123
123
  /**
124
- * Time Complexity: O(|E|) where |E| is the number of edges
124
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
125
125
  * Space Complexity: O(1)
126
126
  *
127
- * The function removes an edge between two vertices in a graph and returns the removed edge.
127
+ * The function removes an edge between two vertexMap in a graph and returns the removed edge.
128
128
  * @param {VO | VertexKey} srcOrKey - The source vertex or its ID.
129
129
  * @param {VO | VertexKey} destOrKey - The `destOrKey` parameter represents the destination vertex or its ID.
130
130
  * @returns the removed edge (EO) if it exists, or undefined if either the source or destination vertex does not exist.
@@ -147,11 +147,11 @@ export class DirectedGraph extends AbstractGraph {
147
147
  return removed;
148
148
  }
149
149
  /**
150
- * Time Complexity: O(E) where E is the number of edges
150
+ * Time Complexity: O(E) where E is the number of edgeMap
151
151
  * Space Complexity: O(1)
152
152
  */
153
153
  /**
154
- * Time Complexity: O(E) where E is the number of edges
154
+ * Time Complexity: O(E) where E is the number of edgeMap
155
155
  * Space Complexity: O(1)
156
156
  *
157
157
  * The `deleteEdge` function removes an edge from a graph and returns the removed edge.
@@ -219,22 +219,22 @@ export class DirectedGraph extends AbstractGraph {
219
219
  this._outEdgeMap.delete(vertex);
220
220
  this._inEdgeMap.delete(vertex);
221
221
  }
222
- return this._vertices.delete(vertexKey);
222
+ return this._vertexMap.delete(vertexKey);
223
223
  }
224
224
  /**
225
- * Time Complexity: O(|E|) where |E| is the number of edges
225
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
226
226
  * Space Complexity: O(1)
227
227
  */
228
228
  /**
229
- * Time Complexity: O(|E|) where |E| is the number of edges
229
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
230
230
  * Space Complexity: O(1)
231
231
  *
232
- * The function removes edges between two vertices and returns the removed edges.
232
+ * The function removes edgeMap between two vertexMap and returns the removed edgeMap.
233
233
  * @param {VertexKey | VO} v1 - The parameter `v1` can be either a `VertexKey` or a `VO`. A `VertexKey` represents the
234
234
  * unique identifier of a vertex in a graph, while `VO` represents the actual vertex object.
235
235
  * @param {VertexKey | VO} v2 - The parameter `v2` represents either a `VertexKey` or a `VO` object. It is used to specify
236
236
  * the second vertex in the edge that needs to be removed.
237
- * @returns an array of removed edges (EO[]).
237
+ * @returns an array of removed edgeMap (EO[]).
238
238
  */
239
239
  deleteEdgesBetween(v1, v2) {
240
240
  const removed = [];
@@ -254,10 +254,10 @@ export class DirectedGraph extends AbstractGraph {
254
254
  * Time Complexity: O(1)
255
255
  * Space Complexity: O(1)
256
256
  *
257
- * The function `incomingEdgesOf` returns an array of incoming edges for a given vertex or vertex ID.
257
+ * The function `incomingEdgesOf` returns an array of incoming edgeMap for a given vertex or vertex ID.
258
258
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
259
259
  * (`VertexKey`).
260
- * @returns The method `incomingEdgesOf` returns an array of edges (`EO[]`).
260
+ * @returns The method `incomingEdgesOf` returns an array of edgeMap (`EO[]`).
261
261
  */
262
262
  incomingEdgesOf(vertexOrKey) {
263
263
  const target = this._getVertex(vertexOrKey);
@@ -274,10 +274,10 @@ export class DirectedGraph extends AbstractGraph {
274
274
  * Time Complexity: O(1)
275
275
  * Space Complexity: O(1)
276
276
  *
277
- * The function `outgoingEdgesOf` returns an array of outgoing edges from a given vertex or vertex ID.
277
+ * The function `outgoingEdgesOf` returns an array of outgoing edgeMap from a given vertex or vertex ID.
278
278
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can accept either a vertex object (`VO`) or a vertex ID
279
279
  * (`VertexKey`).
280
- * @returns The method `outgoingEdgesOf` returns an array of edges (`EO[]`).
280
+ * @returns The method `outgoingEdgesOf` returns an array of edgeMap (`EO[]`).
281
281
  */
282
282
  outgoingEdgesOf(vertexOrKey) {
283
283
  const target = this._getVertex(vertexOrKey);
@@ -309,9 +309,9 @@ export class DirectedGraph extends AbstractGraph {
309
309
  * Time Complexity: O(1)
310
310
  * Space Complexity: O(1)
311
311
  *
312
- * The function "inDegreeOf" returns the number of incoming edges for a given vertex.
312
+ * The function "inDegreeOf" returns the number of incoming edgeMap for a given vertex.
313
313
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
314
- * @returns The number of incoming edges of the specified vertex or vertex ID.
314
+ * @returns The number of incoming edgeMap of the specified vertex or vertex ID.
315
315
  */
316
316
  inDegreeOf(vertexOrKey) {
317
317
  return this.incomingEdgesOf(vertexOrKey).length;
@@ -324,9 +324,9 @@ export class DirectedGraph extends AbstractGraph {
324
324
  * Time Complexity: O(1)
325
325
  * Space Complexity: O(1)
326
326
  *
327
- * The function `outDegreeOf` returns the number of outgoing edges from a given vertex.
327
+ * The function `outDegreeOf` returns the number of outgoing edgeMap from a given vertex.
328
328
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
329
- * @returns The number of outgoing edges from the specified vertex or vertex ID.
329
+ * @returns The number of outgoing edgeMap from the specified vertex or vertex ID.
330
330
  */
331
331
  outDegreeOf(vertexOrKey) {
332
332
  return this.outgoingEdgesOf(vertexOrKey).length;
@@ -339,9 +339,9 @@ export class DirectedGraph extends AbstractGraph {
339
339
  * Time Complexity: O(1)
340
340
  * Space Complexity: O(1)
341
341
  *
342
- * The function "edgesOf" returns an array of both outgoing and incoming edges of a given vertex or vertex ID.
342
+ * The function "edgesOf" returns an array of both outgoing and incoming edgeMap of a given vertex or vertex ID.
343
343
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
344
- * @returns The function `edgesOf` returns an array of edges.
344
+ * @returns The function `edgesOf` returns an array of edgeMap.
345
345
  */
346
346
  edgesOf(vertexOrKey) {
347
347
  return [...this.outgoingEdgesOf(vertexOrKey), ...this.incomingEdgesOf(vertexOrKey)];
@@ -377,17 +377,17 @@ export class DirectedGraph extends AbstractGraph {
377
377
  return this._getVertex(e.dest);
378
378
  }
379
379
  /**
380
- * Time Complexity: O(|E|) where |E| is the number of edges
380
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
381
381
  * Space Complexity: O(1)
382
382
  */
383
383
  /**
384
- * Time Complexity: O(|E|) where |E| is the number of edges
384
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
385
385
  * Space Complexity: O(1)
386
386
  *
387
- * The function `getDestinations` returns an array of destination vertices connected to a given vertex.
387
+ * The function `getDestinations` returns an array of destination vertexMap connected to a given vertex.
388
388
  * @param {VO | VertexKey | undefined} vertex - The `vertex` parameter represents the starting vertex from which we want to
389
389
  * find the destinations. It can be either a `VO` object, a `VertexKey` value, or `undefined`.
390
- * @returns an array of vertices (VO[]).
390
+ * @returns an array of vertexMap (VO[]).
391
391
  */
392
392
  getDestinations(vertex) {
393
393
  if (vertex === undefined) {
@@ -404,26 +404,26 @@ export class DirectedGraph extends AbstractGraph {
404
404
  return destinations;
405
405
  }
406
406
  /**
407
- * Time Complexity: O(|V| + |E|) where |V| is the number of vertices and |E| is the number of edges
407
+ * Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
408
408
  * Space Complexity: O(|V|)
409
409
  */
410
410
  /**
411
- * Time Complexity: O(|V| + |E|) where |V| is the number of vertices and |E| is the number of edges
411
+ * Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
412
412
  * Space Complexity: O(|V|)
413
413
  *
414
- * The `topologicalSort` function performs a topological sort on a graph and returns an array of vertices or vertex IDs
414
+ * The `topologicalSort` function performs a topological sort on a graph and returns an array of vertexMap or vertex IDs
415
415
  * in the sorted order, or undefined if the graph contains a cycle.
416
416
  * @param {'vertex' | 'key'} [propertyName] - The `propertyName` parameter is an optional parameter that specifies the
417
- * property to use for sorting the vertices. It can have two possible values: 'vertex' or 'key'. If 'vertex' is
418
- * specified, the vertices themselves will be used for sorting. If 'key' is specified, the ids of
419
- * @returns an array of vertices or vertex IDs in topological order. If there is a cycle in the graph, it returns undefined.
417
+ * property to use for sorting the vertexMap. It can have two possible values: 'vertex' or 'key'. If 'vertex' is
418
+ * specified, the vertexMap themselves will be used for sorting. If 'key' is specified, the ids of
419
+ * @returns an array of vertexMap or vertex IDs in topological order. If there is a cycle in the graph, it returns undefined.
420
420
  */
421
421
  topologicalSort(propertyName) {
422
422
  propertyName = propertyName ?? 'key';
423
423
  // When judging whether there is a cycle in the undirected graph, all nodes with degree of **<= 1** are enqueued
424
424
  // When judging whether there is a cycle in the directed graph, all nodes with **in degree = 0** are enqueued
425
425
  const statusMap = new Map();
426
- for (const entry of this.vertices) {
426
+ for (const entry of this.vertexMap) {
427
427
  statusMap.set(entry[1], 0);
428
428
  }
429
429
  let sorted = [];
@@ -443,7 +443,7 @@ export class DirectedGraph extends AbstractGraph {
443
443
  statusMap.set(cur, 2);
444
444
  sorted.push(cur);
445
445
  };
446
- for (const entry of this.vertices) {
446
+ for (const entry of this.vertexMap) {
447
447
  if (statusMap.get(entry[1]) === 0) {
448
448
  dfs(entry[1]);
449
449
  }
@@ -455,35 +455,35 @@ export class DirectedGraph extends AbstractGraph {
455
455
  return sorted.reverse();
456
456
  }
457
457
  /**
458
- * Time Complexity: O(|E|) where |E| is the number of edges
458
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
459
459
  * Space Complexity: O(|E|)
460
460
  */
461
461
  /**
462
- * Time Complexity: O(|E|) where |E| is the number of edges
462
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
463
463
  * Space Complexity: O(|E|)
464
464
  *
465
- * The `edgeSet` function returns an array of all the edges in the graph.
466
- * @returns The `edgeSet()` method returns an array of edges (`EO[]`).
465
+ * The `edgeSet` function returns an array of all the edgeMap in the graph.
466
+ * @returns The `edgeSet()` method returns an array of edgeMap (`EO[]`).
467
467
  */
468
468
  edgeSet() {
469
- let edges = [];
469
+ let edgeMap = [];
470
470
  this._outEdgeMap.forEach(outEdges => {
471
- edges = [...edges, ...outEdges];
471
+ edgeMap = [...edgeMap, ...outEdges];
472
472
  });
473
- return edges;
473
+ return edgeMap;
474
474
  }
475
475
  /**
476
- * Time Complexity: O(|E|) where |E| is the number of edges
476
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
477
477
  * Space Complexity: O(1)
478
478
  */
479
479
  /**
480
- * Time Complexity: O(|E|) where |E| is the number of edges
480
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
481
481
  * Space Complexity: O(1)
482
482
  *
483
- * The function `getNeighbors` returns an array of neighboring vertices of a given vertex or vertex ID in a graph.
483
+ * The function `getNeighbors` returns an array of neighboring vertexMap of a given vertex or vertex ID in a graph.
484
484
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
485
485
  * (`VertexKey`).
486
- * @returns an array of vertices (VO[]).
486
+ * @returns an array of vertexMap (VO[]).
487
487
  */
488
488
  getNeighbors(vertexOrKey) {
489
489
  const neighbors = [];
@@ -508,10 +508,10 @@ export class DirectedGraph extends AbstractGraph {
508
508
  * Time Complexity: O(1)
509
509
  * Space Complexity: O(1)
510
510
  *
511
- * The function "getEndsOfEdge" returns the source and destination vertices of an edge if it exists in the graph,
511
+ * The function "getEndsOfEdge" returns the source and destination vertexMap of an edge if it exists in the graph,
512
512
  * otherwise it returns undefined.
513
513
  * @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph.
514
- * @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
514
+ * @returns The function `getEndsOfEdge` returns an array containing two vertexMap `[VO, VO]` if the edge exists in the
515
515
  * graph. If the edge does not exist, it returns `undefined`.
516
516
  */
517
517
  getEndsOfEdge(edge) {
@@ -535,7 +535,7 @@ export class DirectedGraph extends AbstractGraph {
535
535
  * Time Complexity: O(1)
536
536
  * Space Complexity: O(1)
537
537
  *
538
- * The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertices exist.
538
+ * The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertexMap exist.
539
539
  * @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph. It is the edge that
540
540
  * needs to be added to the graph.
541
541
  * @returns a boolean value. It returns true if the edge was successfully added to the graph, and false if either the
@@ -32,17 +32,17 @@ export declare class MapEdge<E = any> extends DirectedEdge<E> {
32
32
  }
33
33
  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> {
34
34
  /**
35
- * The constructor function initializes the origin and bottomRight properties of a MapGraphCoordinate object.
36
- * @param {MapGraphCoordinate} origin - The `origin` parameter is a `MapGraphCoordinate` object that represents the
35
+ * The constructor function initializes the originCoord and bottomRight properties of a MapGraphCoordinate object.
36
+ * @param {MapGraphCoordinate} originCoord - The `originCoord` parameter is a `MapGraphCoordinate` object that represents the
37
37
  * starting point or reference point of the map graph. It defines the coordinates of the top-left corner of the map
38
38
  * graph.
39
39
  * @param {MapGraphCoordinate} [bottomRight] - The `bottomRight` parameter is an optional parameter of type
40
40
  * `MapGraphCoordinate`. It represents the bottom right coordinate of a map graph. If this parameter is not provided,
41
41
  * it will default to `undefined`.
42
42
  */
43
- constructor(origin: MapGraphCoordinate, bottomRight?: MapGraphCoordinate);
44
- protected _origin: MapGraphCoordinate;
45
- get origin(): MapGraphCoordinate;
43
+ constructor(originCoord: MapGraphCoordinate, bottomRight?: MapGraphCoordinate);
44
+ protected _originCoord: MapGraphCoordinate;
45
+ get originCoord(): MapGraphCoordinate;
46
46
  protected _bottomRight: MapGraphCoordinate | undefined;
47
47
  get bottomRight(): MapGraphCoordinate | undefined;
48
48
  /**
@@ -37,22 +37,22 @@ export class MapEdge extends DirectedEdge {
37
37
  }
38
38
  export class MapGraph extends DirectedGraph {
39
39
  /**
40
- * The constructor function initializes the origin and bottomRight properties of a MapGraphCoordinate object.
41
- * @param {MapGraphCoordinate} origin - The `origin` parameter is a `MapGraphCoordinate` object that represents the
40
+ * The constructor function initializes the originCoord and bottomRight properties of a MapGraphCoordinate object.
41
+ * @param {MapGraphCoordinate} originCoord - The `originCoord` parameter is a `MapGraphCoordinate` object that represents the
42
42
  * starting point or reference point of the map graph. It defines the coordinates of the top-left corner of the map
43
43
  * graph.
44
44
  * @param {MapGraphCoordinate} [bottomRight] - The `bottomRight` parameter is an optional parameter of type
45
45
  * `MapGraphCoordinate`. It represents the bottom right coordinate of a map graph. If this parameter is not provided,
46
46
  * it will default to `undefined`.
47
47
  */
48
- constructor(origin, bottomRight) {
48
+ constructor(originCoord, bottomRight) {
49
49
  super();
50
- this._origin = origin;
50
+ this._originCoord = originCoord;
51
51
  this._bottomRight = bottomRight;
52
52
  }
53
- _origin = [0, 0];
54
- get origin() {
55
- return this._origin;
53
+ _originCoord = [0, 0];
54
+ get originCoord() {
55
+ return this._originCoord;
56
56
  }
57
57
  _bottomRight;
58
58
  get bottomRight() {
@@ -69,7 +69,7 @@ export class MapGraph extends DirectedGraph {
69
69
  * @param {number} long - The `long` parameter represents the longitude coordinate of the vertex.
70
70
  * @returns The method is returning a new instance of the `MapVertex` class, casted as type `VO`.
71
71
  */
72
- createVertex(key, value, lat = this.origin[0], long = this.origin[1]) {
72
+ createVertex(key, value, lat = this.originCoord[0], long = this.originCoord[1]) {
73
73
  return new MapVertex(key, value, lat, long);
74
74
  }
75
75
  /**