undirected-graph-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
@@ -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,63 +66,81 @@ 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
- * The function removes an edge from a graph and returns the removed edge, or undefined if the edge was not found.
107
- * @param {EO} edge - The `edge` parameter is an object that represents an edge in a graph. It has two properties: `src`
108
- * and `dest`, which represent the source and destination vertices of the edge, respectively.
109
- * @returns The method `deleteEdge` returns the removed edge (`EO`) if it exists, or `undefined` if the edge does not exist.
106
+ * The `deleteEdge` function removes an edge from a graph and returns the removed edge.
107
+ * @param {EO | VertexKey} edgeOrSrcVertexKey - The `edge` parameter can be either an `EO` object (edge object) or
108
+ * a `VertexKey` (key of a vertex).
109
+ * @param {VertexKey} [destVertexKey] - The `destVertexKey` parameter is an optional parameter that
110
+ * represents the key of the destination vertex of the edge. It is used to specify the destination
111
+ * vertex when the `edge` parameter is a vertex key. If `destVertexKey` is not provided, the function
112
+ * assumes that the `edge`
113
+ * @returns the removed edge (EO) or undefined if no edge was removed.
110
114
  */
111
- deleteEdge(edge: EO): EO | undefined;
115
+ deleteEdge(edgeOrSrcVertexKey: EO | VertexKey, destVertexKey?: VertexKey): EO | undefined;
112
116
  /**
113
- * Time Complexity: O(|E|) where |E| is the number of edges
117
+ * Time Complexity: O(1) - Constant time for Map operations.
118
+ * Space Complexity: O(1) - Constant space, as it creates only a few variables.
119
+ */
120
+ /**
121
+ * Time Complexity: O(1) - Constant time for Map operations.
122
+ * Space Complexity: O(1) - Constant space, as it creates only a few variables.
123
+ *
124
+ * The `deleteVertex` function removes a vertex from a graph by its ID or by the vertex object itself.
125
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
126
+ * (`VertexKey`).
127
+ * @returns The method is returning a boolean value.
128
+ */
129
+ deleteVertex(vertexOrKey: VO | VertexKey): boolean;
130
+ /**
131
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
114
132
  * Space Complexity: O(1)
115
133
  */
116
134
  /**
117
- * Time Complexity: O(|E|) where |E| is the number of edges
135
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
118
136
  * Space Complexity: O(1)
119
137
  *
120
- * 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.
121
139
  * @param {VertexKey | VO} v1 - The parameter `v1` can be either a `VertexKey` or a `VO`. A `VertexKey` represents the
122
140
  * unique identifier of a vertex in a graph, while `VO` represents the actual vertex object.
123
141
  * @param {VertexKey | VO} v2 - The parameter `v2` represents either a `VertexKey` or a `VO` object. It is used to specify
124
142
  * the second vertex in the edge that needs to be removed.
125
- * @returns an array of removed edges (EO[]).
143
+ * @returns an array of removed edgeMap (EO[]).
126
144
  */
127
145
  deleteEdgesBetween(v1: VertexKey | VO, v2: VertexKey | VO): EO[];
128
146
  /**
@@ -133,10 +151,10 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
133
151
  * Time Complexity: O(1)
134
152
  * Space Complexity: O(1)
135
153
  *
136
- * 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.
137
155
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
138
156
  * (`VertexKey`).
139
- * @returns The method `incomingEdgesOf` returns an array of edges (`EO[]`).
157
+ * @returns The method `incomingEdgesOf` returns an array of edgeMap (`EO[]`).
140
158
  */
141
159
  incomingEdgesOf(vertexOrKey: VO | VertexKey): EO[];
142
160
  /**
@@ -147,10 +165,10 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
147
165
  * Time Complexity: O(1)
148
166
  * Space Complexity: O(1)
149
167
  *
150
- * 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.
151
169
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can accept either a vertex object (`VO`) or a vertex ID
152
170
  * (`VertexKey`).
153
- * @returns The method `outgoingEdgesOf` returns an array of edges (`EO[]`).
171
+ * @returns The method `outgoingEdgesOf` returns an array of edgeMap (`EO[]`).
154
172
  */
155
173
  outgoingEdgesOf(vertexOrKey: VO | VertexKey): EO[];
156
174
  /**
@@ -174,9 +192,9 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
174
192
  * Time Complexity: O(1)
175
193
  * Space Complexity: O(1)
176
194
  *
177
- * 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.
178
196
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
179
- * @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.
180
198
  */
181
199
  inDegreeOf(vertexOrKey: VertexKey | VO): number;
182
200
  /**
@@ -187,9 +205,9 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
187
205
  * Time Complexity: O(1)
188
206
  * Space Complexity: O(1)
189
207
  *
190
- * 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.
191
209
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
192
- * @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.
193
211
  */
194
212
  outDegreeOf(vertexOrKey: VertexKey | VO): number;
195
213
  /**
@@ -200,9 +218,9 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
200
218
  * Time Complexity: O(1)
201
219
  * Space Complexity: O(1)
202
220
  *
203
- * 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.
204
222
  * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
205
- * @returns The function `edgesOf` returns an array of edges.
223
+ * @returns The function `edgesOf` returns an array of edgeMap.
206
224
  */
207
225
  edgesOf(vertexOrKey: VertexKey | VO): EO[];
208
226
  /**
@@ -232,59 +250,59 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
232
250
  */
233
251
  getEdgeDest(e: EO): VO | undefined;
234
252
  /**
235
- * Time Complexity: O(|E|) where |E| is the number of edges
253
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
236
254
  * Space Complexity: O(1)
237
255
  */
238
256
  /**
239
- * Time Complexity: O(|E|) where |E| is the number of edges
257
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
240
258
  * Space Complexity: O(1)
241
259
  *
242
- * 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.
243
261
  * @param {VO | VertexKey | undefined} vertex - The `vertex` parameter represents the starting vertex from which we want to
244
262
  * find the destinations. It can be either a `VO` object, a `VertexKey` value, or `undefined`.
245
- * @returns an array of vertices (VO[]).
263
+ * @returns an array of vertexMap (VO[]).
246
264
  */
247
265
  getDestinations(vertex: VO | VertexKey | undefined): VO[];
248
266
  /**
249
- * 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
250
268
  * Space Complexity: O(|V|)
251
269
  */
252
270
  /**
253
- * 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
254
272
  * Space Complexity: O(|V|)
255
273
  *
256
- * 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
257
275
  * in the sorted order, or undefined if the graph contains a cycle.
258
276
  * @param {'vertex' | 'key'} [propertyName] - The `propertyName` parameter is an optional parameter that specifies the
259
- * property to use for sorting the vertices. It can have two possible values: 'vertex' or 'key'. If 'vertex' is
260
- * specified, the vertices themselves will be used for sorting. If 'key' is specified, the ids of
261
- * @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.
262
280
  */
263
281
  topologicalSort(propertyName?: 'vertex' | 'key'): Array<VO | VertexKey> | undefined;
264
282
  /**
265
- * Time Complexity: O(|E|) where |E| is the number of edges
283
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
266
284
  * Space Complexity: O(|E|)
267
285
  */
268
286
  /**
269
- * Time Complexity: O(|E|) where |E| is the number of edges
287
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
270
288
  * Space Complexity: O(|E|)
271
289
  *
272
- * The `edgeSet` function returns an array of all the edges in the graph.
273
- * @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[]`).
274
292
  */
275
293
  edgeSet(): EO[];
276
294
  /**
277
- * Time Complexity: O(|E|) where |E| is the number of edges
295
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
278
296
  * Space Complexity: O(1)
279
297
  */
280
298
  /**
281
- * Time Complexity: O(|E|) where |E| is the number of edges
299
+ * Time Complexity: O(|E|) where |E| is the number of edgeMap
282
300
  * Space Complexity: O(1)
283
301
  *
284
- * 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.
285
303
  * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
286
304
  * (`VertexKey`).
287
- * @returns an array of vertices (VO[]).
305
+ * @returns an array of vertexMap (VO[]).
288
306
  */
289
307
  getNeighbors(vertexOrKey: VO | VertexKey): VO[];
290
308
  /**
@@ -295,10 +313,10 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
295
313
  * Time Complexity: O(1)
296
314
  * Space Complexity: O(1)
297
315
  *
298
- * 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,
299
317
  * otherwise it returns undefined.
300
318
  * @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph.
301
- * @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
302
320
  * graph. If the edge does not exist, it returns `undefined`.
303
321
  */
304
322
  getEndsOfEdge(edge: EO): [VO, VO] | undefined;
@@ -310,7 +328,7 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
310
328
  * Time Complexity: O(1)
311
329
  * Space Complexity: O(1)
312
330
  *
313
- * 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.
314
332
  * @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph. It is the edge that
315
333
  * needs to be added to the graph.
316
334
  * @returns a boolean value. It returns true if the edge was successfully added to the graph, and false if either the