min-heap-typed 1.49.3 → 1.49.4
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.
- package/dist/data-structures/binary-tree/binary-tree.d.ts +1 -1
- package/dist/data-structures/binary-tree/binary-tree.js +1 -1
- package/dist/data-structures/graph/abstract-graph.d.ts +1 -10
- package/dist/data-structures/graph/abstract-graph.js +0 -17
- package/dist/data-structures/graph/directed-graph.js +4 -0
- package/package.json +2 -2
- package/src/data-structures/binary-tree/binary-tree.ts +1 -1
- package/src/data-structures/graph/abstract-graph.ts +1 -13
- package/src/data-structures/graph/directed-graph.ts +7 -3
- package/src/data-structures/graph/undirected-graph.ts +1 -1
- package/src/data-structures/linked-list/singly-linked-list.ts +1 -2
|
@@ -525,7 +525,7 @@ export declare class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V,
|
|
|
525
525
|
print(beginRoot?: BTNKeyOrNode<K, N>, options?: BinaryTreePrintOptions): void;
|
|
526
526
|
protected _getIterator(node?: N | null | undefined): IterableIterator<[K, V | undefined]>;
|
|
527
527
|
protected _displayAux(node: N | null | undefined, options: BinaryTreePrintOptions): NodeDisplayLayout;
|
|
528
|
-
protected _defaultOneParamCallback: (node: N) => K;
|
|
528
|
+
protected _defaultOneParamCallback: (node: N | null | undefined) => K | undefined;
|
|
529
529
|
/**
|
|
530
530
|
* Swap the data of two nodes in the binary tree.
|
|
531
531
|
* @param {N} srcNode - The source node to swap.
|
|
@@ -80,7 +80,7 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
80
80
|
super();
|
|
81
81
|
this.iterationType = types_1.IterationType.ITERATIVE;
|
|
82
82
|
this._extractor = (key) => Number(key);
|
|
83
|
-
this._defaultOneParamCallback = (node) => node.key;
|
|
83
|
+
this._defaultOneParamCallback = (node) => node ? node.key : undefined;
|
|
84
84
|
if (options) {
|
|
85
85
|
const { iterationType, extractor } = options;
|
|
86
86
|
if (iterationType) {
|
|
@@ -99,16 +99,7 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
|
|
|
99
99
|
* Time Complexity: O(1) - Constant time for Map operations.
|
|
100
100
|
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
|
|
101
101
|
*/
|
|
102
|
-
|
|
103
|
-
* Time Complexity: O(1) - Constant time for Map operations.
|
|
104
|
-
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
|
|
105
|
-
*
|
|
106
|
-
* The `deleteVertex` function removes a vertex from a graph by its ID or by the vertex object itself.
|
|
107
|
-
* @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
|
|
108
|
-
* (`VertexKey`).
|
|
109
|
-
* @returns The method is returning a boolean value.
|
|
110
|
-
*/
|
|
111
|
-
deleteVertex(vertexOrKey: VO | VertexKey): boolean;
|
|
102
|
+
abstract deleteVertex(vertexOrKey: VO | VertexKey): boolean;
|
|
112
103
|
/**
|
|
113
104
|
* Time Complexity: O(K), where K is the number of vertexMap to be removed.
|
|
114
105
|
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
|
|
@@ -97,23 +97,6 @@ class AbstractGraph extends base_1.IterableEntryBase {
|
|
|
97
97
|
const potentialKeyType = typeof potentialKey;
|
|
98
98
|
return potentialKeyType === "string" || potentialKeyType === "number";
|
|
99
99
|
}
|
|
100
|
-
/**
|
|
101
|
-
* Time Complexity: O(1) - Constant time for Map operations.
|
|
102
|
-
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
|
|
103
|
-
*/
|
|
104
|
-
/**
|
|
105
|
-
* Time Complexity: O(1) - Constant time for Map operations.
|
|
106
|
-
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
|
|
107
|
-
*
|
|
108
|
-
* The `deleteVertex` function removes a vertex from a graph by its ID or by the vertex object itself.
|
|
109
|
-
* @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
|
|
110
|
-
* (`VertexKey`).
|
|
111
|
-
* @returns The method is returning a boolean value.
|
|
112
|
-
*/
|
|
113
|
-
deleteVertex(vertexOrKey) {
|
|
114
|
-
const vertexKey = this._getVertexKey(vertexOrKey);
|
|
115
|
-
return this._vertexMap.delete(vertexKey);
|
|
116
|
-
}
|
|
117
100
|
/**
|
|
118
101
|
* Time Complexity: O(K), where K is the number of vertexMap to be removed.
|
|
119
102
|
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
|
|
@@ -212,6 +212,10 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
|
|
|
212
212
|
vertexKey = this._getVertexKey(vertexOrKey);
|
|
213
213
|
}
|
|
214
214
|
if (vertex) {
|
|
215
|
+
const neighbors = this.getNeighbors(vertex);
|
|
216
|
+
for (const neighbor of neighbors) {
|
|
217
|
+
this._inEdgeMap.delete(neighbor);
|
|
218
|
+
}
|
|
215
219
|
this._outEdgeMap.delete(vertex);
|
|
216
220
|
this._inEdgeMap.delete(vertex);
|
|
217
221
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "min-heap-typed",
|
|
3
|
-
"version": "1.49.
|
|
3
|
+
"version": "1.49.4",
|
|
4
4
|
"description": "Min Heap. Javascript & Typescript Data Structure.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -132,6 +132,6 @@
|
|
|
132
132
|
"typescript": "^4.9.5"
|
|
133
133
|
},
|
|
134
134
|
"dependencies": {
|
|
135
|
-
"data-structure-typed": "^1.49.
|
|
135
|
+
"data-structure-typed": "^1.49.4"
|
|
136
136
|
}
|
|
137
137
|
}
|
|
@@ -1957,7 +1957,7 @@ export class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V, N> = Bi
|
|
|
1957
1957
|
}
|
|
1958
1958
|
}
|
|
1959
1959
|
|
|
1960
|
-
protected _defaultOneParamCallback = (node: N) => node.key;
|
|
1960
|
+
protected _defaultOneParamCallback = (node: N | null | undefined) => node ? node.key : undefined;
|
|
1961
1961
|
|
|
1962
1962
|
/**
|
|
1963
1963
|
* Swap the data of two nodes in the binary tree.
|
|
@@ -173,19 +173,7 @@ export abstract class AbstractGraph<
|
|
|
173
173
|
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
|
|
174
174
|
*/
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
* Time Complexity: O(1) - Constant time for Map operations.
|
|
178
|
-
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
|
|
179
|
-
*
|
|
180
|
-
* The `deleteVertex` function removes a vertex from a graph by its ID or by the vertex object itself.
|
|
181
|
-
* @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
|
|
182
|
-
* (`VertexKey`).
|
|
183
|
-
* @returns The method is returning a boolean value.
|
|
184
|
-
*/
|
|
185
|
-
deleteVertex(vertexOrKey: VO | VertexKey): boolean {
|
|
186
|
-
const vertexKey = this._getVertexKey(vertexOrKey);
|
|
187
|
-
return this._vertexMap.delete(vertexKey);
|
|
188
|
-
}
|
|
176
|
+
abstract deleteVertex(vertexOrKey: VO | VertexKey): boolean;
|
|
189
177
|
|
|
190
178
|
/**
|
|
191
179
|
* Time Complexity: O(K), where K is the number of vertexMap to be removed.
|
|
@@ -240,7 +240,7 @@ export class DirectedGraph<
|
|
|
240
240
|
* (`VertexKey`).
|
|
241
241
|
* @returns The method is returning a boolean value.
|
|
242
242
|
*/
|
|
243
|
-
|
|
243
|
+
deleteVertex(vertexOrKey: VO | VertexKey): boolean {
|
|
244
244
|
let vertexKey: VertexKey;
|
|
245
245
|
let vertex: VO | undefined;
|
|
246
246
|
if (this.isVertexKey(vertexOrKey)) {
|
|
@@ -252,8 +252,12 @@ export class DirectedGraph<
|
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
if (vertex) {
|
|
255
|
-
this.
|
|
256
|
-
|
|
255
|
+
const neighbors = this.getNeighbors(vertex);
|
|
256
|
+
for (const neighbor of neighbors) {
|
|
257
|
+
this._inEdgeMap.delete(neighbor);
|
|
258
|
+
}
|
|
259
|
+
this._outEdgeMap.delete(vertex);
|
|
260
|
+
this._inEdgeMap.delete(vertex);
|
|
257
261
|
}
|
|
258
262
|
|
|
259
263
|
return this._vertexMap.delete(vertexKey);
|
|
@@ -212,7 +212,7 @@ export class UndirectedGraph<
|
|
|
212
212
|
* (`VertexKey`).
|
|
213
213
|
* @returns The method is returning a boolean value.
|
|
214
214
|
*/
|
|
215
|
-
|
|
215
|
+
deleteVertex(vertexOrKey: VO | VertexKey): boolean {
|
|
216
216
|
let vertexKey: VertexKey;
|
|
217
217
|
let vertex: VO | undefined;
|
|
218
218
|
if (this.isVertexKey(vertexOrKey)) {
|