min-heap-typed 1.42.8 → 1.43.0

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 (49) hide show
  1. package/dist/data-structures/binary-tree/avl-tree.d.ts +88 -23
  2. package/dist/data-structures/binary-tree/avl-tree.js +88 -23
  3. package/dist/data-structures/binary-tree/binary-tree.d.ts +180 -74
  4. package/dist/data-structures/binary-tree/binary-tree.js +415 -236
  5. package/dist/data-structures/binary-tree/bst.d.ts +121 -66
  6. package/dist/data-structures/binary-tree/bst.js +121 -67
  7. package/dist/data-structures/binary-tree/rb-tree.d.ts +72 -5
  8. package/dist/data-structures/binary-tree/rb-tree.js +95 -18
  9. package/dist/data-structures/binary-tree/tree-multimap.d.ts +82 -43
  10. package/dist/data-structures/binary-tree/tree-multimap.js +82 -43
  11. package/dist/data-structures/graph/abstract-graph.d.ts +139 -36
  12. package/dist/data-structures/graph/abstract-graph.js +147 -36
  13. package/dist/data-structures/graph/directed-graph.d.ts +126 -0
  14. package/dist/data-structures/graph/directed-graph.js +126 -0
  15. package/dist/data-structures/graph/undirected-graph.d.ts +63 -0
  16. package/dist/data-structures/graph/undirected-graph.js +63 -0
  17. package/dist/data-structures/heap/heap.d.ts +175 -12
  18. package/dist/data-structures/heap/heap.js +175 -12
  19. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +203 -0
  20. package/dist/data-structures/linked-list/doubly-linked-list.js +203 -0
  21. package/dist/data-structures/linked-list/singly-linked-list.d.ts +182 -0
  22. package/dist/data-structures/linked-list/singly-linked-list.js +182 -0
  23. package/dist/data-structures/linked-list/skip-linked-list.d.ts +64 -0
  24. package/dist/data-structures/linked-list/skip-linked-list.js +64 -0
  25. package/dist/data-structures/queue/deque.d.ts +113 -3
  26. package/dist/data-structures/queue/deque.js +113 -3
  27. package/dist/data-structures/queue/queue.d.ts +87 -0
  28. package/dist/data-structures/queue/queue.js +87 -0
  29. package/dist/data-structures/stack/stack.d.ts +42 -0
  30. package/dist/data-structures/stack/stack.js +42 -0
  31. package/dist/data-structures/trie/trie.d.ts +76 -0
  32. package/dist/data-structures/trie/trie.js +76 -1
  33. package/package.json +2 -2
  34. package/src/data-structures/binary-tree/avl-tree.ts +97 -23
  35. package/src/data-structures/binary-tree/binary-tree.ts +465 -256
  36. package/src/data-structures/binary-tree/bst.ts +130 -68
  37. package/src/data-structures/binary-tree/rb-tree.ts +106 -19
  38. package/src/data-structures/binary-tree/tree-multimap.ts +88 -44
  39. package/src/data-structures/graph/abstract-graph.ts +133 -7
  40. package/src/data-structures/graph/directed-graph.ts +145 -1
  41. package/src/data-structures/graph/undirected-graph.ts +72 -0
  42. package/src/data-structures/heap/heap.ts +201 -12
  43. package/src/data-structures/linked-list/doubly-linked-list.ts +232 -0
  44. package/src/data-structures/linked-list/singly-linked-list.ts +208 -0
  45. package/src/data-structures/linked-list/skip-linked-list.ts +74 -0
  46. package/src/data-structures/queue/deque.ts +127 -3
  47. package/src/data-structures/queue/queue.ts +99 -0
  48. package/src/data-structures/stack/stack.ts +48 -0
  49. package/src/data-structures/trie/trie.ts +87 -4
@@ -91,6 +91,13 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
91
91
  return new DirectedEdge(src, dest, weight !== null && weight !== void 0 ? weight : 1, value);
92
92
  }
93
93
  /**
94
+ * Time Complexity: O(|V|) where |V| is the number of vertices
95
+ * Space Complexity: O(1)
96
+ */
97
+ /**
98
+ * Time Complexity: O(|V|) where |V| is the number of vertices
99
+ * Space Complexity: O(1)
100
+ *
94
101
  * The `getEdge` function retrieves an edge between two vertices based on their source and destination IDs.
95
102
  * @param {VO | VertexKey | null} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
96
103
  * @param {VO | VertexKey | null} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
@@ -113,6 +120,13 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
113
120
  return edges[0] || null;
114
121
  }
115
122
  /**
123
+ * Time Complexity: O(|E|) where |E| is the number of edges
124
+ * Space Complexity: O(1)
125
+ */
126
+ /**
127
+ * Time Complexity: O(|E|) where |E| is the number of edges
128
+ * Space Complexity: O(1)
129
+ *
116
130
  * The function removes an edge between two vertices in a graph and returns the removed edge.
117
131
  * @param {VO | VertexKey} srcOrKey - The source vertex or its ID.
118
132
  * @param {VO | VertexKey} destOrKey - The `destOrKey` parameter represents the destination vertex or its ID.
@@ -136,6 +150,13 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
136
150
  return removed;
137
151
  }
138
152
  /**
153
+ * Time Complexity: O(|E|) where |E| is the number of edges
154
+ * Space Complexity: O(1)
155
+ */
156
+ /**
157
+ * Time Complexity: O(|E|) where |E| is the number of edges
158
+ * Space Complexity: O(1)
159
+ *
139
160
  * The function removes an edge from a graph and returns the removed edge, or null if the edge was not found.
140
161
  * @param {EO} edge - The `edge` parameter is an object that represents an edge in a graph. It has two properties: `src`
141
162
  * and `dest`, which represent the source and destination vertices of the edge, respectively.
@@ -158,6 +179,13 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
158
179
  return removed;
159
180
  }
160
181
  /**
182
+ * Time Complexity: O(|E|) where |E| is the number of edges
183
+ * Space Complexity: O(1)
184
+ */
185
+ /**
186
+ * Time Complexity: O(|E|) where |E| is the number of edges
187
+ * Space Complexity: O(1)
188
+ *
161
189
  * The function removes edges between two vertices and returns the removed edges.
162
190
  * @param {VertexKey | VO} v1 - The parameter `v1` can be either a `VertexKey` or a `VO`. A `VertexKey` represents the
163
191
  * unique identifier of a vertex in a graph, while `VO` represents the actual vertex object.
@@ -176,6 +204,13 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
176
204
  return removed;
177
205
  }
178
206
  /**
207
+ * Time Complexity: O(1)
208
+ * Space Complexity: O(1)
209
+ */
210
+ /**
211
+ * Time Complexity: O(1)
212
+ * Space Complexity: O(1)
213
+ *
179
214
  * The function `incomingEdgesOf` returns an array of incoming edges for a given vertex or vertex ID.
180
215
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
181
216
  * (`VertexKey`).
@@ -189,6 +224,13 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
189
224
  return [];
190
225
  }
191
226
  /**
227
+ * Time Complexity: O(1)
228
+ * Space Complexity: O(1)
229
+ */
230
+ /**
231
+ * Time Complexity: O(1)
232
+ * Space Complexity: O(1)
233
+ *
192
234
  * The function `outgoingEdgesOf` returns an array of outgoing edges from a given vertex or vertex ID.
193
235
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can accept either a vertex object (`VO`) or a vertex ID
194
236
  * (`VertexKey`).
@@ -202,6 +244,13 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
202
244
  return [];
203
245
  }
204
246
  /**
247
+ * Time Complexity: O(1)
248
+ * Space Complexity: O(1)
249
+ */
250
+ /**
251
+ * Time Complexity: O(1)
252
+ * Space Complexity: O(1)
253
+ *
205
254
  * The function "degreeOf" returns the total degree of a vertex, which is the sum of its out-degree and in-degree.
206
255
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
207
256
  * @returns The sum of the out-degree and in-degree of the specified vertex or vertex ID.
@@ -210,6 +259,13 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
210
259
  return this.outDegreeOf(vertexOrKey) + this.inDegreeOf(vertexOrKey);
211
260
  }
212
261
  /**
262
+ * Time Complexity: O(1)
263
+ * Space Complexity: O(1)
264
+ */
265
+ /**
266
+ * Time Complexity: O(1)
267
+ * Space Complexity: O(1)
268
+ *
213
269
  * The function "inDegreeOf" returns the number of incoming edges for a given vertex.
214
270
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
215
271
  * @returns The number of incoming edges of the specified vertex or vertex ID.
@@ -218,6 +274,13 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
218
274
  return this.incomingEdgesOf(vertexOrKey).length;
219
275
  }
220
276
  /**
277
+ * Time Complexity: O(1)
278
+ * Space Complexity: O(1)
279
+ */
280
+ /**
281
+ * Time Complexity: O(1)
282
+ * Space Complexity: O(1)
283
+ *
221
284
  * The function `outDegreeOf` returns the number of outgoing edges from a given vertex.
222
285
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
223
286
  * @returns The number of outgoing edges from the specified vertex or vertex ID.
@@ -226,6 +289,13 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
226
289
  return this.outgoingEdgesOf(vertexOrKey).length;
227
290
  }
228
291
  /**
292
+ * Time Complexity: O(1)
293
+ * Space Complexity: O(1)
294
+ */
295
+ /**
296
+ * Time Complexity: O(1)
297
+ * Space Complexity: O(1)
298
+ *
229
299
  * The function "edgesOf" returns an array of both outgoing and incoming edges of a given vertex or vertex ID.
230
300
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
231
301
  * @returns The function `edgesOf` returns an array of edges.
@@ -234,6 +304,13 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
234
304
  return [...this.outgoingEdgesOf(vertexOrKey), ...this.incomingEdgesOf(vertexOrKey)];
235
305
  }
236
306
  /**
307
+ * Time Complexity: O(1)
308
+ * Space Complexity: O(1)
309
+ */
310
+ /**
311
+ * Time Complexity: O(1)
312
+ * Space Complexity: O(1)
313
+ *
237
314
  * The function "getEdgeSrc" returns the source vertex of an edge, or null if the edge does not exist.
238
315
  * @param {EO} e - The parameter "e" is of type EO, which represents an edge in a graph.
239
316
  * @returns either a vertex object (VO) or null.
@@ -242,6 +319,13 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
242
319
  return this._getVertex(e.src);
243
320
  }
244
321
  /**
322
+ * Time Complexity: O(1)
323
+ * Space Complexity: O(1)
324
+ */
325
+ /**
326
+ * Time Complexity: O(1)
327
+ * Space Complexity: O(1)
328
+ *
245
329
  * The function "getEdgeDest" returns the destination vertex of an edge.
246
330
  * @param {EO} e - The parameter "e" is of type "EO", which represents an edge in a graph.
247
331
  * @returns either a vertex object of type VO or null.
@@ -250,6 +334,13 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
250
334
  return this._getVertex(e.dest);
251
335
  }
252
336
  /**
337
+ * Time Complexity: O(|E|) where |E| is the number of edges
338
+ * Space Complexity: O(1)
339
+ */
340
+ /**
341
+ * Time Complexity: O(|E|) where |E| is the number of edges
342
+ * Space Complexity: O(1)
343
+ *
253
344
  * The function `getDestinations` returns an array of destination vertices connected to a given vertex.
254
345
  * @param {VO | VertexKey | null} vertex - The `vertex` parameter represents the starting vertex from which we want to
255
346
  * find the destinations. It can be either a `VO` object, a `VertexKey` value, or `null`.
@@ -270,6 +361,13 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
270
361
  return destinations;
271
362
  }
272
363
  /**
364
+ * Time Complexity: O(|V| + |E|) where |V| is the number of vertices and |E| is the number of edges
365
+ * Space Complexity: O(|V|)
366
+ */
367
+ /**
368
+ * Time Complexity: O(|V| + |E|) where |V| is the number of vertices and |E| is the number of edges
369
+ * Space Complexity: O(|V|)
370
+ *
273
371
  * The `topologicalSort` function performs a topological sort on a graph and returns an array of vertices or vertex IDs
274
372
  * in the sorted order, or null if the graph contains a cycle.
275
373
  * @param {'vertex' | 'key'} [propertyName] - The `propertyName` parameter is an optional parameter that specifies the
@@ -314,6 +412,13 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
314
412
  return sorted.reverse();
315
413
  }
316
414
  /**
415
+ * Time Complexity: O(|E|) where |E| is the number of edges
416
+ * Space Complexity: O(|E|)
417
+ */
418
+ /**
419
+ * Time Complexity: O(|E|) where |E| is the number of edges
420
+ * Space Complexity: O(|E|)
421
+ *
317
422
  * The `edgeSet` function returns an array of all the edges in the graph.
318
423
  * @returns The `edgeSet()` method returns an array of edges (`EO[]`).
319
424
  */
@@ -325,6 +430,13 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
325
430
  return edges;
326
431
  }
327
432
  /**
433
+ * Time Complexity: O(|E|) where |E| is the number of edges
434
+ * Space Complexity: O(1)
435
+ */
436
+ /**
437
+ * Time Complexity: O(|E|) where |E| is the number of edges
438
+ * Space Complexity: O(1)
439
+ *
328
440
  * The function `getNeighbors` returns an array of neighboring vertices of a given vertex or vertex ID in a graph.
329
441
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
330
442
  * (`VertexKey`).
@@ -346,6 +458,13 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
346
458
  return neighbors;
347
459
  }
348
460
  /**
461
+ * Time Complexity: O(1)
462
+ * Space Complexity: O(1)
463
+ */
464
+ /**
465
+ * Time Complexity: O(1)
466
+ * Space Complexity: O(1)
467
+ *
349
468
  * The function "getEndsOfEdge" returns the source and destination vertices of an edge if it exists in the graph,
350
469
  * otherwise it returns null.
351
470
  * @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph.
@@ -366,6 +485,13 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
366
485
  }
367
486
  }
368
487
  /**
488
+ * Time Complexity: O(1)
489
+ * Space Complexity: O(1)
490
+ */
491
+ /**
492
+ * Time Complexity: O(1)
493
+ * Space Complexity: O(1)
494
+ *
369
495
  * The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertices exist.
370
496
  * @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph. It is the edge that
371
497
  * needs to be added to the graph.
@@ -54,6 +54,13 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
54
54
  */
55
55
  createEdge(v1: VertexKey, v2: VertexKey, weight?: number, value?: EO['value']): EO;
56
56
  /**
57
+ * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
58
+ * Space Complexity: O(1)
59
+ */
60
+ /**
61
+ * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
62
+ * Space Complexity: O(1)
63
+ *
57
64
  * The function `getEdge` returns the first edge that connects two vertices, or null if no such edge exists.
58
65
  * @param {VO | VertexKey | null} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `VO` (vertex
59
66
  * object), `null`, or `VertexKey` (a string or number representing the ID of a vertex).
@@ -63,6 +70,13 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
63
70
  */
64
71
  getEdge(v1: VO | VertexKey | null, v2: VO | VertexKey | null): EO | null;
65
72
  /**
73
+ * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
74
+ * Space Complexity: O(1)
75
+ */
76
+ /**
77
+ * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
78
+ * Space Complexity: O(1)
79
+ *
66
80
  * The function removes an edge between two vertices in a graph and returns the removed edge.
67
81
  * @param {VO | VertexKey} v1 - The parameter `v1` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).
68
82
  * @param {VO | VertexKey} v2 - VO | VertexKey - This parameter can be either a vertex object (VO) or a vertex ID
@@ -71,12 +85,26 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
71
85
  */
72
86
  deleteEdgeBetween(v1: VO | VertexKey, v2: VO | VertexKey): EO | null;
73
87
  /**
88
+ * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
89
+ * Space Complexity: O(1)
90
+ */
91
+ /**
92
+ * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
93
+ * Space Complexity: O(1)
94
+ *
74
95
  * The deleteEdge function removes an edge between two vertices in a graph.
75
96
  * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
76
97
  * @returns The method is returning either the removed edge (of type EO) or null if the edge was not found.
77
98
  */
78
99
  deleteEdge(edge: EO): EO | null;
79
100
  /**
101
+ * Time Complexity: O(1)
102
+ * Space Complexity: O(1)
103
+ */
104
+ /**
105
+ * Time Complexity: O(1)
106
+ * Space Complexity: O(1)
107
+ *
80
108
  * The function `degreeOf` returns the degree of a vertex in a graph, which is the number of edges connected to that
81
109
  * vertex.
82
110
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
@@ -85,6 +113,13 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
85
113
  */
86
114
  degreeOf(vertexOrKey: VertexKey | VO): number;
87
115
  /**
116
+ * Time Complexity: O(1)
117
+ * Space Complexity: O(1)
118
+ */
119
+ /**
120
+ * Time Complexity: O(1)
121
+ * Space Complexity: O(1)
122
+ *
88
123
  * The function returns the edges of a given vertex or vertex ID.
89
124
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`. A `VertexKey` is a
90
125
  * unique identifier for a vertex in a graph, while `VO` represents the type of the vertex.
@@ -92,11 +127,25 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
92
127
  */
93
128
  edgesOf(vertexOrKey: VertexKey | VO): EO[];
94
129
  /**
130
+ * Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
131
+ * Space Complexity: O(|E|)
132
+ */
133
+ /**
134
+ * Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
135
+ * Space Complexity: O(|E|)
136
+ *
95
137
  * The function "edgeSet" returns an array of unique edges from a set of edges.
96
138
  * @returns The method `edgeSet()` returns an array of type `EO[]`.
97
139
  */
98
140
  edgeSet(): EO[];
99
141
  /**
142
+ * Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
143
+ * Space Complexity: O(|E|)
144
+ */
145
+ /**
146
+ * Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
147
+ * Space Complexity: O(|E|)
148
+ *
100
149
  * The function "getNeighbors" returns an array of neighboring vertices for a given vertex or vertex ID.
101
150
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
102
151
  * (`VertexKey`).
@@ -104,6 +153,13 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
104
153
  */
105
154
  getNeighbors(vertexOrKey: VO | VertexKey): VO[];
106
155
  /**
156
+ * Time Complexity: O(1)
157
+ * Space Complexity: O(1)
158
+ */
159
+ /**
160
+ * Time Complexity: O(1)
161
+ * Space Complexity: O(1)
162
+ *
107
163
  * The function "getEndsOfEdge" returns the vertices at the ends of an edge if the edge exists in the graph, otherwise
108
164
  * it returns null.
109
165
  * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
@@ -112,6 +168,13 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
112
168
  */
113
169
  getEndsOfEdge(edge: EO): [VO, VO] | null;
114
170
  /**
171
+ * Time Complexity: O(1)
172
+ * Space Complexity: O(1)
173
+ */
174
+ /**
175
+ * Time Complexity: O(1)
176
+ * Space Complexity: O(1)
177
+ *
115
178
  * The function adds an edge to the graph by updating the adjacency list with the vertices of the edge.
116
179
  * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
117
180
  * @returns a boolean value.
@@ -77,6 +77,13 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
77
77
  return new UndirectedEdge(v1, v2, weight !== null && weight !== void 0 ? weight : 1, value);
78
78
  }
79
79
  /**
80
+ * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
81
+ * Space Complexity: O(1)
82
+ */
83
+ /**
84
+ * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
85
+ * Space Complexity: O(1)
86
+ *
80
87
  * The function `getEdge` returns the first edge that connects two vertices, or null if no such edge exists.
81
88
  * @param {VO | VertexKey | null} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `VO` (vertex
82
89
  * object), `null`, or `VertexKey` (a string or number representing the ID of a vertex).
@@ -97,6 +104,13 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
97
104
  return edges ? edges[0] || null : null;
98
105
  }
99
106
  /**
107
+ * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
108
+ * Space Complexity: O(1)
109
+ */
110
+ /**
111
+ * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
112
+ * Space Complexity: O(1)
113
+ *
100
114
  * The function removes an edge between two vertices in a graph and returns the removed edge.
101
115
  * @param {VO | VertexKey} v1 - The parameter `v1` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).
102
116
  * @param {VO | VertexKey} v2 - VO | VertexKey - This parameter can be either a vertex object (VO) or a vertex ID
@@ -121,6 +135,13 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
121
135
  return removed;
122
136
  }
123
137
  /**
138
+ * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
139
+ * Space Complexity: O(1)
140
+ */
141
+ /**
142
+ * Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
143
+ * Space Complexity: O(1)
144
+ *
124
145
  * The deleteEdge function removes an edge between two vertices in a graph.
125
146
  * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
126
147
  * @returns The method is returning either the removed edge (of type EO) or null if the edge was not found.
@@ -129,6 +150,13 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
129
150
  return this.deleteEdgeBetween(edge.vertices[0], edge.vertices[1]);
130
151
  }
131
152
  /**
153
+ * Time Complexity: O(1)
154
+ * Space Complexity: O(1)
155
+ */
156
+ /**
157
+ * Time Complexity: O(1)
158
+ * Space Complexity: O(1)
159
+ *
132
160
  * The function `degreeOf` returns the degree of a vertex in a graph, which is the number of edges connected to that
133
161
  * vertex.
134
162
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
@@ -146,6 +174,13 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
146
174
  }
147
175
  }
148
176
  /**
177
+ * Time Complexity: O(1)
178
+ * Space Complexity: O(1)
179
+ */
180
+ /**
181
+ * Time Complexity: O(1)
182
+ * Space Complexity: O(1)
183
+ *
149
184
  * The function returns the edges of a given vertex or vertex ID.
150
185
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`. A `VertexKey` is a
151
186
  * unique identifier for a vertex in a graph, while `VO` represents the type of the vertex.
@@ -161,6 +196,13 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
161
196
  }
162
197
  }
163
198
  /**
199
+ * Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
200
+ * Space Complexity: O(|E|)
201
+ */
202
+ /**
203
+ * Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
204
+ * Space Complexity: O(|E|)
205
+ *
164
206
  * The function "edgeSet" returns an array of unique edges from a set of edges.
165
207
  * @returns The method `edgeSet()` returns an array of type `EO[]`.
166
208
  */
@@ -174,6 +216,13 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
174
216
  return [...edgeSet];
175
217
  }
176
218
  /**
219
+ * Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
220
+ * Space Complexity: O(|E|)
221
+ */
222
+ /**
223
+ * Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
224
+ * Space Complexity: O(|E|)
225
+ *
177
226
  * The function "getNeighbors" returns an array of neighboring vertices for a given vertex or vertex ID.
178
227
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
179
228
  * (`VertexKey`).
@@ -194,6 +243,13 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
194
243
  return neighbors;
195
244
  }
196
245
  /**
246
+ * Time Complexity: O(1)
247
+ * Space Complexity: O(1)
248
+ */
249
+ /**
250
+ * Time Complexity: O(1)
251
+ * Space Complexity: O(1)
252
+ *
197
253
  * The function "getEndsOfEdge" returns the vertices at the ends of an edge if the edge exists in the graph, otherwise
198
254
  * it returns null.
199
255
  * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
@@ -214,6 +270,13 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
214
270
  }
215
271
  }
216
272
  /**
273
+ * Time Complexity: O(1)
274
+ * Space Complexity: O(1)
275
+ */
276
+ /**
277
+ * Time Complexity: O(1)
278
+ * Space Complexity: O(1)
279
+ *
217
280
  * The function adds an edge to the graph by updating the adjacency list with the vertices of the edge.
218
281
  * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
219
282
  * @returns a boolean value.