data-structure-typed 1.18.6 → 1.18.7

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 (143) hide show
  1. package/dist/data-structures/binary-tree/abstract-binary-tree.d.ts +48 -24
  2. package/dist/data-structures/binary-tree/abstract-binary-tree.js +51 -26
  3. package/dist/data-structures/binary-tree/avl-tree.d.ts +5 -4
  4. package/dist/data-structures/binary-tree/avl-tree.js +5 -3
  5. package/dist/data-structures/binary-tree/binary-tree.d.ts +13 -3
  6. package/dist/data-structures/binary-tree/binary-tree.js +14 -5
  7. package/dist/data-structures/binary-tree/bst.d.ts +26 -5
  8. package/dist/data-structures/binary-tree/bst.js +26 -4
  9. package/dist/data-structures/binary-tree/rb-tree.d.ts +30 -1
  10. package/dist/data-structures/binary-tree/rb-tree.js +27 -14
  11. package/dist/data-structures/binary-tree/tree-multiset.d.ts +15 -4
  12. package/dist/data-structures/binary-tree/tree-multiset.js +15 -3
  13. package/dist/data-structures/graph/abstract-graph.d.ts +20 -21
  14. package/dist/data-structures/graph/abstract-graph.js +24 -19
  15. package/dist/data-structures/graph/directed-graph.d.ts +10 -9
  16. package/dist/data-structures/graph/directed-graph.js +18 -18
  17. package/dist/data-structures/graph/undirected-graph.d.ts +5 -11
  18. package/dist/data-structures/graph/undirected-graph.js +4 -17
  19. package/dist/data-structures/interfaces/abstract-binary-tree.d.ts +101 -0
  20. package/dist/data-structures/interfaces/abstract-binary-tree.js +2 -0
  21. package/dist/data-structures/interfaces/abstract-graph.d.ts +1 -4
  22. package/dist/data-structures/interfaces/avl-tree.d.ts +16 -1
  23. package/dist/data-structures/interfaces/binary-tree.d.ts +4 -24
  24. package/dist/data-structures/interfaces/bst.d.ts +18 -1
  25. package/dist/data-structures/interfaces/directed-graph.d.ts +4 -1
  26. package/dist/data-structures/interfaces/index.d.ts +1 -1
  27. package/dist/data-structures/interfaces/index.js +1 -1
  28. package/dist/data-structures/interfaces/rb-tree.d.ts +9 -0
  29. package/dist/data-structures/interfaces/rb-tree.js +2 -0
  30. package/dist/data-structures/interfaces/undirected-graph.d.ts +4 -1
  31. package/dist/data-structures/types/abstract-binary-tree.d.ts +2 -2
  32. package/dist/utils/utils.js +62 -0
  33. package/docs/assets/search.js +1 -1
  34. package/docs/classes/AVLTree.html +292 -180
  35. package/docs/classes/AVLTreeNode.html +126 -77
  36. package/docs/classes/AaTree.html +12 -6
  37. package/docs/classes/AbstractBinaryTree.html +258 -163
  38. package/docs/classes/AbstractBinaryTreeNode.html +117 -84
  39. package/docs/classes/AbstractEdge.html +22 -16
  40. package/docs/classes/AbstractGraph.html +137 -140
  41. package/docs/classes/AbstractVertex.html +19 -13
  42. package/docs/classes/ArrayDeque.html +25 -19
  43. package/docs/classes/BST.html +275 -174
  44. package/docs/classes/BSTNode.html +127 -77
  45. package/docs/classes/BTree.html +12 -6
  46. package/docs/classes/BinaryIndexedTree.html +20 -14
  47. package/docs/classes/BinaryTree.html +265 -169
  48. package/docs/classes/BinaryTreeNode.html +110 -61
  49. package/docs/classes/Character.html +15 -9
  50. package/docs/classes/CoordinateMap.html +20 -14
  51. package/docs/classes/CoordinateSet.html +19 -13
  52. package/docs/classes/Deque.html +45 -39
  53. package/docs/classes/DirectedEdge.html +26 -20
  54. package/docs/classes/DirectedGraph.html +189 -154
  55. package/docs/classes/DirectedVertex.html +17 -11
  56. package/docs/classes/DoublyLinkedList.html +48 -42
  57. package/docs/classes/DoublyLinkedListNode.html +22 -16
  58. package/docs/classes/HashTable.html +12 -6
  59. package/docs/classes/Heap.html +26 -20
  60. package/docs/classes/HeapItem.html +19 -13
  61. package/docs/classes/Matrix2D.html +27 -21
  62. package/docs/classes/MatrixNTI2D.html +15 -9
  63. package/docs/classes/MaxHeap.html +26 -20
  64. package/docs/classes/MaxPriorityQueue.html +45 -39
  65. package/docs/classes/MinHeap.html +26 -20
  66. package/docs/classes/MinPriorityQueue.html +45 -39
  67. package/docs/classes/Navigator.html +21 -15
  68. package/docs/classes/ObjectDeque.html +36 -30
  69. package/docs/classes/Pair.html +12 -6
  70. package/docs/classes/PriorityQueue.html +43 -37
  71. package/docs/classes/Queue.html +25 -19
  72. package/docs/classes/RBTree.html +2388 -0
  73. package/docs/classes/RBTreeNode.html +516 -0
  74. package/docs/classes/SegmentTree.html +28 -22
  75. package/docs/classes/SegmentTreeNode.html +31 -25
  76. package/docs/classes/SinglyLinkedList.html +45 -39
  77. package/docs/classes/SinglyLinkedListNode.html +19 -13
  78. package/docs/classes/SkipLinkedList.html +12 -6
  79. package/docs/classes/SplayTree.html +12 -6
  80. package/docs/classes/Stack.html +23 -17
  81. package/docs/classes/TreeMap.html +12 -6
  82. package/docs/classes/TreeMultiSet.html +273 -172
  83. package/docs/classes/TreeMultiSetNode.html +126 -77
  84. package/docs/classes/TreeNode.html +27 -21
  85. package/docs/classes/TreeSet.html +12 -6
  86. package/docs/classes/Trie.html +24 -18
  87. package/docs/classes/TrieNode.html +22 -16
  88. package/docs/classes/TwoThreeTree.html +12 -6
  89. package/docs/classes/UndirectedEdge.html +23 -17
  90. package/docs/classes/UndirectedGraph.html +160 -146
  91. package/docs/classes/UndirectedVertex.html +17 -11
  92. package/docs/classes/Vector2D.html +39 -33
  93. package/docs/enums/CP.html +15 -9
  94. package/docs/enums/FamilyPosition.html +15 -9
  95. package/docs/enums/LoopType.html +14 -8
  96. package/docs/enums/RBColor.html +14 -8
  97. package/docs/enums/TopologicalProperty.html +15 -9
  98. package/docs/index.html +11 -5
  99. package/docs/interfaces/IAVLTree.html +1378 -0
  100. package/docs/interfaces/IAVLTreeNode.html +405 -0
  101. package/docs/interfaces/IAbstractBinaryTree.html +1124 -0
  102. package/docs/interfaces/{IBinaryTreeNode.html → IAbstractBinaryTreeNode.html} +61 -73
  103. package/docs/interfaces/{IGraph.html → IAbstractGraph.html} +52 -90
  104. package/docs/interfaces/IBST.html +1271 -0
  105. package/docs/interfaces/IBSTNode.html +408 -0
  106. package/docs/interfaces/IDirectedGraph.html +329 -16
  107. package/docs/interfaces/IUNDirectedGraph.html +322 -8
  108. package/docs/modules.html +22 -10
  109. package/docs/types/AVLTreeOptions.html +12 -6
  110. package/docs/types/{AbstractResultsByProperty.html → AbstractBinaryTreeNodeProperties.html} +16 -10
  111. package/docs/types/{AbstractResultByProperty.html → AbstractBinaryTreeNodeProperty.html} +16 -10
  112. package/docs/types/AbstractBinaryTreeOptions.html +12 -6
  113. package/docs/types/AbstractRecursiveBinaryTreeNode.html +12 -6
  114. package/docs/types/BSTComparator.html +12 -6
  115. package/docs/types/BSTOptions.html +12 -6
  116. package/docs/types/BinaryTreeDeletedResult.html +12 -6
  117. package/docs/types/BinaryTreeNodeId.html +12 -6
  118. package/docs/types/BinaryTreeNodePropertyName.html +12 -6
  119. package/docs/types/BinaryTreeOptions.html +12 -6
  120. package/docs/types/DFSOrderPattern.html +12 -6
  121. package/docs/types/DijkstraResult.html +12 -6
  122. package/docs/types/Direction.html +12 -6
  123. package/docs/types/EdgeId.html +12 -6
  124. package/docs/types/HeapOptions.html +12 -6
  125. package/docs/types/IdObject.html +12 -6
  126. package/docs/types/KeyValObject.html +12 -6
  127. package/docs/types/NavigatorParams.html +12 -6
  128. package/docs/types/NodeOrPropertyName.html +12 -6
  129. package/docs/types/PriorityQueueComparator.html +12 -6
  130. package/docs/types/PriorityQueueDFSOrderPattern.html +12 -6
  131. package/docs/types/PriorityQueueOptions.html +12 -6
  132. package/docs/types/RBTreeOptions.html +12 -6
  133. package/docs/types/RecursiveAVLTreeNode.html +12 -6
  134. package/docs/types/RecursiveBSTNode.html +12 -6
  135. package/docs/types/RecursiveBinaryTreeNode.html +12 -6
  136. package/docs/types/RecursiveTreeMultiSetNode.html +12 -6
  137. package/docs/types/SegmentTreeNodeVal.html +12 -6
  138. package/docs/types/TopologicalStatus.html +12 -6
  139. package/docs/types/TreeMultiSetOptions.html +12 -6
  140. package/docs/types/Turning.html +12 -6
  141. package/docs/types/VertexId.html +12 -6
  142. package/package.json +2 -2
  143. package/docs/interfaces/IBinaryTree.html +0 -189
@@ -7,13 +7,24 @@
7
7
  */
8
8
  import { BST, BSTNode } from './bst';
9
9
  import type { BinaryTreeNodeId, RecursiveTreeMultiSetNode, TreeMultiSetOptions } from '../types';
10
- import { IBinaryTree, IBinaryTreeNode } from '../interfaces';
11
- export declare class TreeMultiSetNode<T, FAMILY extends TreeMultiSetNode<T, FAMILY> = RecursiveTreeMultiSetNode<T>> extends BSTNode<T, FAMILY> implements IBinaryTreeNode<T, FAMILY> {
10
+ import { IBST, IBSTNode } from '../interfaces';
11
+ export declare class TreeMultiSetNode<T, FAMILY extends TreeMultiSetNode<T, FAMILY> = RecursiveTreeMultiSetNode<T>> extends BSTNode<T, FAMILY> implements IBSTNode<T, FAMILY> {
12
+ /**
13
+ * The function creates a new node in a binary tree with an optional value and count.
14
+ * @param {BinaryTreeNodeId} id - The `id` parameter is the identifier for the binary tree node. It is used to uniquely
15
+ * identify each node in the tree.
16
+ * @param {T} [val] - The `val` parameter represents the value to be stored in the node. It is an optional parameter,
17
+ * meaning it can be omitted when calling the `createNode` method.
18
+ * @param {number} [count] - The `count` parameter represents the number of occurrences of the value in the binary tree
19
+ * node. It is an optional parameter, so it can be omitted when calling the `createNode` method.
20
+ * @returns The method is returning a new instance of the TreeMultiSetNode class, casted as the FAMILY type.
21
+ */
22
+ createNode(id: BinaryTreeNodeId, val?: T, count?: number): FAMILY;
12
23
  }
13
24
  /**
14
25
  * The only distinction between a TreeMultiSet and a BST lies in the ability of the former to store duplicate nodes through the utilization of counters.
15
26
  */
16
- export declare class TreeMultiSet<N extends BSTNode<N['val'], N> = BSTNode<number>> extends BST<N> implements IBinaryTree<N> {
27
+ export declare class TreeMultiSet<N extends BSTNode<N['val'], N> = BSTNode<number>> extends BST<N> implements IBST<N> {
17
28
  constructor(options?: TreeMultiSetOptions);
18
29
  /**
19
30
  * The function creates a new BSTNode with the given id, value, and count.
@@ -24,5 +35,5 @@ export declare class TreeMultiSet<N extends BSTNode<N['val'], N> = BSTNode<numbe
24
35
  * occurrences of the value in the binary search tree node. If not provided, the count will default to 1.
25
36
  * @returns A new instance of the BSTNode class with the specified id, value, and count (if provided).
26
37
  */
27
- _createNode(id: BinaryTreeNodeId, val: N['val'], count?: number): N;
38
+ createNode(id: BinaryTreeNodeId, val?: N['val'], count?: number): N;
28
39
  }
@@ -40,6 +40,19 @@ var TreeMultiSetNode = /** @class */ (function (_super) {
40
40
  function TreeMultiSetNode() {
41
41
  return _super !== null && _super.apply(this, arguments) || this;
42
42
  }
43
+ /**
44
+ * The function creates a new node in a binary tree with an optional value and count.
45
+ * @param {BinaryTreeNodeId} id - The `id` parameter is the identifier for the binary tree node. It is used to uniquely
46
+ * identify each node in the tree.
47
+ * @param {T} [val] - The `val` parameter represents the value to be stored in the node. It is an optional parameter,
48
+ * meaning it can be omitted when calling the `createNode` method.
49
+ * @param {number} [count] - The `count` parameter represents the number of occurrences of the value in the binary tree
50
+ * node. It is an optional parameter, so it can be omitted when calling the `createNode` method.
51
+ * @returns The method is returning a new instance of the TreeMultiSetNode class, casted as the FAMILY type.
52
+ */
53
+ TreeMultiSetNode.prototype.createNode = function (id, val, count) {
54
+ return new TreeMultiSetNode(id, (val === undefined ? id : val), count);
55
+ };
43
56
  return TreeMultiSetNode;
44
57
  }(bst_1.BSTNode));
45
58
  exports.TreeMultiSetNode = TreeMultiSetNode;
@@ -60,9 +73,8 @@ var TreeMultiSet = /** @class */ (function (_super) {
60
73
  * occurrences of the value in the binary search tree node. If not provided, the count will default to 1.
61
74
  * @returns A new instance of the BSTNode class with the specified id, value, and count (if provided).
62
75
  */
63
- TreeMultiSet.prototype._createNode = function (id, val, count) {
64
- var node = new TreeMultiSetNode(id, val, count);
65
- return node;
76
+ TreeMultiSet.prototype.createNode = function (id, val, count) {
77
+ return new TreeMultiSetNode(id, val === undefined ? id : val, count);
66
78
  };
67
79
  return TreeMultiSet;
68
80
  }(bst_1.BST));
@@ -1,5 +1,5 @@
1
1
  import type { DijkstraResult, VertexId } from '../types';
2
- import { IGraph } from '../interfaces';
2
+ import { IAbstractGraph } from '../interfaces';
3
3
  export declare abstract class AbstractVertex<T = number> {
4
4
  protected constructor(id: VertexId, val?: T);
5
5
  private _id;
@@ -21,7 +21,7 @@ export declare abstract class AbstractEdge<T = number> {
21
21
  get hashCode(): string;
22
22
  protected _setHashCode(v: string): void;
23
23
  }
24
- export declare abstract class AbstractGraph<V extends AbstractVertex<any>, E extends AbstractEdge<any>> implements IGraph<V, E> {
24
+ export declare abstract class AbstractGraph<V extends AbstractVertex<any>, E extends AbstractEdge<any>> implements IAbstractGraph<V, E> {
25
25
  private _vertices;
26
26
  get vertices(): Map<VertexId, V>;
27
27
  /**
@@ -30,7 +30,7 @@ export declare abstract class AbstractGraph<V extends AbstractVertex<any>, E ext
30
30
  * @param id
31
31
  * @param val
32
32
  */
33
- abstract _createVertex(id: VertexId, val?: V): V;
33
+ abstract createVertex(id: VertexId, val?: V): V;
34
34
  /**
35
35
  * In TypeScript, a subclass inherits the interface implementation of its parent class, without needing to implement the same interface again in the subclass. This behavior differs from Java's approach. In Java, if a parent class implements an interface, the subclass needs to explicitly implement the same interface, even if the parent class has already implemented it.
36
36
  * 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.
@@ -39,12 +39,9 @@ export declare abstract class AbstractGraph<V extends AbstractVertex<any>, E ext
39
39
  * @param weight
40
40
  * @param val
41
41
  */
42
- abstract _createEdge(srcOrV1: VertexId | string, destOrV2: VertexId | string, weight?: number, val?: E): E;
43
- abstract removeEdgeBetween(srcOrId: V | VertexId, destOrId: V | VertexId): E | null;
42
+ abstract createEdge(srcOrV1: VertexId | string, destOrV2: VertexId | string, weight?: number, val?: E): E;
44
43
  abstract removeEdge(edge: E): E | null;
45
- _getVertex(vertexOrId: VertexId | V): V | null;
46
44
  getVertex(vertexId: VertexId): V | null;
47
- _getVertexId(vertexOrId: V | VertexId): VertexId;
48
45
  /**
49
46
  * The function checks if a vertex exists in a graph.
50
47
  * @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can accept either a vertex object (`V`) or a vertex ID
@@ -179,11 +176,6 @@ export declare abstract class AbstractGraph<V extends AbstractVertex<any>, E ext
179
176
  * @returns The function `dijkstra` returns an object of type `DijkstraResult<V>`.
180
177
  */
181
178
  dijkstra(src: V | VertexId, dest?: V | VertexId | null, getMinDist?: boolean, genPaths?: boolean): DijkstraResult<V>;
182
- /**
183
- * Dijkstra's algorithm only solves the single-source shortest path problem, while the Bellman-Ford algorithm and Floyd-Warshall algorithm can address shortest paths between all pairs of nodes.
184
- * Dijkstra's algorithm is suitable for graphs with non-negative edge weights, whereas the Bellman-Ford algorithm and Floyd-Warshall algorithm can handle negative-weight edges.
185
- * The time complexity of Dijkstra's algorithm and the Bellman-Ford algorithm depends on the size of the graph, while the time complexity of the Floyd-Warshall algorithm is O(V^3), where V is the number of nodes. For dense graphs, Floyd-Warshall might become slower.
186
- */
187
179
  /**
188
180
  * Dijkstra algorithm time: O(logVE) space: O(V + E)
189
181
  * Dijkstra's algorithm is used to find the shortest paths from a source node to all other nodes in a graph. Its basic idea is to repeatedly choose the node closest to the source node and update the distances of other nodes using this node as an intermediary. Dijkstra's algorithm requires that the edge weights in the graph are non-negative.
@@ -214,10 +206,9 @@ export declare abstract class AbstractGraph<V extends AbstractVertex<any>, E ext
214
206
  minPath: V[];
215
207
  };
216
208
  /**
217
- * BellmanFord time:O(VE) space:O(V)
218
- * one to rest pairs
219
- * The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edges for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edges, the Bellman-Ford algorithm is more flexible in some scenarios.
220
- * The `bellmanFord` function implements the Bellman-Ford algorithm to find the shortest path from a source vertex to
209
+ * Dijkstra's algorithm only solves the single-source shortest path problem, while the Bellman-Ford algorithm and Floyd-Warshall algorithm can address shortest paths between all pairs of nodes.
210
+ * Dijkstra's algorithm is suitable for graphs with non-negative edge weights, whereas the Bellman-Ford algorithm and Floyd-Warshall algorithm can handle negative-weight edges.
211
+ * The time complexity of Dijkstra's algorithm and the Bellman-Ford algorithm depends on the size of the graph, while the time complexity of the Floyd-Warshall algorithm is O(V^3), where V is the number of nodes. For dense graphs, Floyd-Warshall might become slower.
221
212
  */
222
213
  /**
223
214
  * Floyd algorithm time: O(V^3) space: O(V^2), not support graph with negative weight cycle
@@ -234,11 +225,6 @@ export declare abstract class AbstractGraph<V extends AbstractVertex<any>, E ext
234
225
  costs: number[][];
235
226
  predecessor: (V | null)[][];
236
227
  };
237
- /**
238
- * Floyd algorithm time: O(V^3) space: O(V^2), not support graph with negative weight cycle
239
- * all pairs
240
- * The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edges, and it can simultaneously compute shortest paths between any two nodes.
241
- */
242
228
  /**
243
229
  * Tarjan is an algorithm based on DFS,which is used to solve the connectivity problem of graphs.
244
230
  * Tarjan can find cycles in directed or undirected graph
@@ -268,6 +254,19 @@ export declare abstract class AbstractGraph<V extends AbstractVertex<any>, E ext
268
254
  SCCs: Map<number, V[]>;
269
255
  cycles: Map<number, V[]>;
270
256
  };
257
+ /**
258
+ * BellmanFord time:O(VE) space:O(V)
259
+ * one to rest pairs
260
+ * The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edges for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edges, the Bellman-Ford algorithm is more flexible in some scenarios.
261
+ * The `bellmanFord` function implements the Bellman-Ford algorithm to find the shortest path from a source vertex to
262
+ */
263
+ protected _getVertex(vertexOrId: VertexId | V): V | null;
264
+ /**
265
+ * Floyd algorithm time: O(V^3) space: O(V^2), not support graph with negative weight cycle
266
+ * all pairs
267
+ * The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edges, and it can simultaneously compute shortest paths between any two nodes.
268
+ */
269
+ protected _getVertexId(vertexOrId: V | VertexId): VertexId;
271
270
  /**--- start find cycles --- */
272
271
  protected _setVertices(value: Map<VertexId, V>): void;
273
272
  }
@@ -115,7 +115,7 @@ var AbstractEdge = /** @class */ (function () {
115
115
  // * @param weight
116
116
  // * @param val
117
117
  // */
118
- // abstract _createEdge(srcOrV1: VertexId | string, destOrV2: VertexId | string, weight?: number, val?: E): E;
118
+ // abstract createEdge(srcOrV1: VertexId | string, destOrV2: VertexId | string, weight?: number, val?: E): E;
119
119
  AbstractEdge.prototype._setHashCode = function (v) {
120
120
  this._hashCode = v;
121
121
  };
@@ -137,16 +137,9 @@ var AbstractGraph = /** @class */ (function () {
137
137
  enumerable: false,
138
138
  configurable: true
139
139
  });
140
- AbstractGraph.prototype._getVertex = function (vertexOrId) {
141
- var vertexId = this._getVertexId(vertexOrId);
142
- return this._vertices.get(vertexId) || null;
143
- };
144
140
  AbstractGraph.prototype.getVertex = function (vertexId) {
145
141
  return this._vertices.get(vertexId) || null;
146
142
  };
147
- AbstractGraph.prototype._getVertexId = function (vertexOrId) {
148
- return vertexOrId instanceof AbstractVertex ? vertexOrId.id : vertexOrId;
149
- };
150
143
  /**
151
144
  * The function checks if a vertex exists in a graph.
152
145
  * @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can accept either a vertex object (`V`) or a vertex ID
@@ -157,7 +150,7 @@ var AbstractGraph = /** @class */ (function () {
157
150
  return this._vertices.has(this._getVertexId(vertexOrId));
158
151
  };
159
152
  AbstractGraph.prototype.createAddVertex = function (id, val) {
160
- var newVertex = this._createVertex(id, val);
153
+ var newVertex = this.createVertex(id, val);
161
154
  return this.addVertex(newVertex);
162
155
  };
163
156
  AbstractGraph.prototype.addVertex = function (newVertex) {
@@ -221,7 +214,7 @@ var AbstractGraph = /** @class */ (function () {
221
214
  src = src.id;
222
215
  if (dest instanceof AbstractVertex)
223
216
  dest = dest.id;
224
- var newEdge = this._createEdge(src, dest, weight, val);
217
+ var newEdge = this.createEdge(src, dest, weight, val);
225
218
  return this.addEdge(newEdge);
226
219
  };
227
220
  /**
@@ -892,10 +885,9 @@ var AbstractGraph = /** @class */ (function () {
892
885
  return { hasNegativeCycle: hasNegativeCycle, distMap: distMap, preMap: preMap, paths: paths, min: min, minPath: minPath };
893
886
  };
894
887
  /**
895
- * BellmanFord time:O(VE) space:O(V)
896
- * one to rest pairs
897
- * The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edges for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edges, the Bellman-Ford algorithm is more flexible in some scenarios.
898
- * The `bellmanFord` function implements the Bellman-Ford algorithm to find the shortest path from a source vertex to
888
+ * Dijkstra's algorithm only solves the single-source shortest path problem, while the Bellman-Ford algorithm and Floyd-Warshall algorithm can address shortest paths between all pairs of nodes.
889
+ * Dijkstra's algorithm is suitable for graphs with non-negative edge weights, whereas the Bellman-Ford algorithm and Floyd-Warshall algorithm can handle negative-weight edges.
890
+ * The time complexity of Dijkstra's algorithm and the Bellman-Ford algorithm depends on the size of the graph, while the time complexity of the Floyd-Warshall algorithm is O(V^3), where V is the number of nodes. For dense graphs, Floyd-Warshall might become slower.
899
891
  */
900
892
  /**
901
893
  * Floyd algorithm time: O(V^3) space: O(V^2), not support graph with negative weight cycle
@@ -939,11 +931,6 @@ var AbstractGraph = /** @class */ (function () {
939
931
  }
940
932
  return { costs: costs, predecessor: predecessor };
941
933
  };
942
- /**
943
- * Floyd algorithm time: O(V^3) space: O(V^2), not support graph with negative weight cycle
944
- * all pairs
945
- * The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edges, and it can simultaneously compute shortest paths between any two nodes.
946
- */
947
934
  /**
948
935
  * Tarjan is an algorithm based on DFS,which is used to solve the connectivity problem of graphs.
949
936
  * Tarjan can find cycles in directed or undirected graph
@@ -1071,6 +1058,24 @@ var AbstractGraph = /** @class */ (function () {
1071
1058
  }
1072
1059
  return { dfnMap: dfnMap, lowMap: lowMap, bridges: bridges, articulationPoints: articulationPoints, SCCs: SCCs, cycles: cycles };
1073
1060
  };
1061
+ /**
1062
+ * BellmanFord time:O(VE) space:O(V)
1063
+ * one to rest pairs
1064
+ * The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edges for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edges, the Bellman-Ford algorithm is more flexible in some scenarios.
1065
+ * The `bellmanFord` function implements the Bellman-Ford algorithm to find the shortest path from a source vertex to
1066
+ */
1067
+ AbstractGraph.prototype._getVertex = function (vertexOrId) {
1068
+ var vertexId = this._getVertexId(vertexOrId);
1069
+ return this._vertices.get(vertexId) || null;
1070
+ };
1071
+ /**
1072
+ * Floyd algorithm time: O(V^3) space: O(V^2), not support graph with negative weight cycle
1073
+ * all pairs
1074
+ * The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edges, and it can simultaneously compute shortest paths between any two nodes.
1075
+ */
1076
+ AbstractGraph.prototype._getVertexId = function (vertexOrId) {
1077
+ return vertexOrId instanceof AbstractVertex ? vertexOrId.id : vertexOrId;
1078
+ };
1074
1079
  /**--- start find cycles --- */
1075
1080
  AbstractGraph.prototype._setVertices = function (value) {
1076
1081
  this._vertices = value;
@@ -44,7 +44,7 @@ export declare class DirectedGraph<V extends DirectedVertex<any> = DirectedVerte
44
44
  * @param id
45
45
  * @param val
46
46
  */
47
- _createVertex(id: VertexId, val?: V['val']): V;
47
+ createVertex(id: VertexId, val?: V['val']): V;
48
48
  /**
49
49
  * In TypeScript, a subclass inherits the interface implementation of its parent class, without needing to implement the same interface again in the subclass. This behavior differs from Java's approach. In Java, if a parent class implements an interface, the subclass needs to explicitly implement the same interface, even if the parent class has already implemented it.
50
50
  * 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.
@@ -53,7 +53,7 @@ export declare class DirectedGraph<V extends DirectedVertex<any> = DirectedVerte
53
53
  * @param weight
54
54
  * @param val
55
55
  */
56
- _createEdge(src: VertexId, dest: VertexId, weight?: number, val?: E['val']): E;
56
+ createEdge(src: VertexId, dest: VertexId, weight?: number, val?: E['val']): E;
57
57
  /**
58
58
  * The function `getEdge` returns the directed edge between two vertices, given their source and destination.
59
59
  * @param {V | null | VertexId} srcOrId - The source vertex or its ID. It can be either a
@@ -81,7 +81,7 @@ export declare class DirectedGraph<V extends DirectedVertex<any> = DirectedVerte
81
81
  * @returns The function `removeEdgeBetween` returns the removed edge (`E`) if it exists, or `null` if
82
82
  * the edge does not exist.
83
83
  */
84
- removeEdgeBetween(srcOrId: V | VertexId, destOrId: V | VertexId): E | null;
84
+ removeEdgeSrcToDest(srcOrId: V | VertexId, destOrId: V | VertexId): E | null;
85
85
  /**
86
86
  * The `removeEdge` function removes a directed edge from a graph and returns the removed edge, or null if the edge was
87
87
  * not found.
@@ -92,13 +92,14 @@ export declare class DirectedGraph<V extends DirectedVertex<any> = DirectedVerte
92
92
  */
93
93
  removeEdge(edge: E): E | null;
94
94
  /**
95
- * The function removeAllEdges removes all edges between two vertices.
96
- * @param {VertexId | V} src - The `src` parameter can be either a `VertexId` or a `V`.
97
- * @param {VertexId | V} dest - The `dest` parameter represents the destination vertex of an edge. It
98
- * can be either a `VertexId` or a `V`.
99
- * @returns An empty array of DirectedEdge objects is being returned.
95
+ * The function removes all edges between two vertices and returns the removed edges.
96
+ * @param {VertexId | V} v1 - The parameter `v1` represents either a `VertexId` or a `V` object. It is used to identify
97
+ * the first vertex in the graph.
98
+ * @param {VertexId | V} v2 - The parameter `v2` represents either a `VertexId` or a `V`. It is used to identify the
99
+ * second vertex involved in the edges that need to be removed.
100
+ * @returns The function `removeEdgesBetween` returns an array of removed edges (`E[]`).
100
101
  */
101
- removeAllEdges(src: VertexId | V, dest: VertexId | V): E[];
102
+ removeEdgesBetween(v1: VertexId | V, v2: VertexId | V): E[];
102
103
  /**
103
104
  * The function returns an array of incoming edges of a given vertex or vertex ID.
104
105
  * @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can be either a `V`
@@ -148,7 +148,7 @@ var DirectedGraph = /** @class */ (function (_super) {
148
148
  * @param id
149
149
  * @param val
150
150
  */
151
- DirectedGraph.prototype._createVertex = function (id, val) {
151
+ DirectedGraph.prototype.createVertex = function (id, val) {
152
152
  return new DirectedVertex(id, val !== null && val !== void 0 ? val : id);
153
153
  };
154
154
  /**
@@ -159,7 +159,7 @@ var DirectedGraph = /** @class */ (function (_super) {
159
159
  * @param weight
160
160
  * @param val
161
161
  */
162
- DirectedGraph.prototype._createEdge = function (src, dest, weight, val) {
162
+ DirectedGraph.prototype.createEdge = function (src, dest, weight, val) {
163
163
  return new DirectedEdge(src, dest, weight !== null && weight !== void 0 ? weight : 1, val);
164
164
  };
165
165
  /**
@@ -229,7 +229,7 @@ var DirectedGraph = /** @class */ (function (_super) {
229
229
  * @returns The function `removeEdgeBetween` returns the removed edge (`E`) if it exists, or `null` if
230
230
  * the edge does not exist.
231
231
  */
232
- DirectedGraph.prototype.removeEdgeBetween = function (srcOrId, destOrId) {
232
+ DirectedGraph.prototype.removeEdgeSrcToDest = function (srcOrId, destOrId) {
233
233
  var src = this._getVertex(srcOrId);
234
234
  var dest = this._getVertex(destOrId);
235
235
  var removed = null;
@@ -238,14 +238,6 @@ var DirectedGraph = /** @class */ (function (_super) {
238
238
  }
239
239
  var srcOutEdges = this._outEdgeMap.get(src);
240
240
  if (srcOutEdges) {
241
- /**
242
- * The removeEdge function removes an edge from a graph and returns the removed edge, or null if the edge was not
243
- * found.
244
- * @param {E} edge - The `edge` parameter represents the edge that you want to remove from the graph. It should be an
245
- * object that has `src` and `dest` properties, which represent the source and destination vertices of the edge,
246
- * respectively.
247
- * @returns The method `removeEdge` returns the removed edge (`E`) if it exists, or `null` if the edge does not exist.
248
- */
249
241
  (0, utils_1.arrayRemove)(srcOutEdges, function (edge) { return edge.dest === dest.id; });
250
242
  }
251
243
  var destInEdges = this._inEdgeMap.get(dest);
@@ -279,14 +271,22 @@ var DirectedGraph = /** @class */ (function (_super) {
279
271
  return removed;
280
272
  };
281
273
  /**
282
- * The function removeAllEdges removes all edges between two vertices.
283
- * @param {VertexId | V} src - The `src` parameter can be either a `VertexId` or a `V`.
284
- * @param {VertexId | V} dest - The `dest` parameter represents the destination vertex of an edge. It
285
- * can be either a `VertexId` or a `V`.
286
- * @returns An empty array of DirectedEdge objects is being returned.
274
+ * The function removes all edges between two vertices and returns the removed edges.
275
+ * @param {VertexId | V} v1 - The parameter `v1` represents either a `VertexId` or a `V` object. It is used to identify
276
+ * the first vertex in the graph.
277
+ * @param {VertexId | V} v2 - The parameter `v2` represents either a `VertexId` or a `V`. It is used to identify the
278
+ * second vertex involved in the edges that need to be removed.
279
+ * @returns The function `removeEdgesBetween` returns an array of removed edges (`E[]`).
287
280
  */
288
- DirectedGraph.prototype.removeAllEdges = function (src, dest) {
289
- return [];
281
+ DirectedGraph.prototype.removeEdgesBetween = function (v1, v2) {
282
+ var removed = [];
283
+ if (v1 && v2) {
284
+ var v1ToV2 = this.removeEdgeSrcToDest(v1, v2);
285
+ var v2ToV1 = this.removeEdgeSrcToDest(v2, v1);
286
+ v1ToV2 && removed.push(v1ToV2);
287
+ v2ToV1 && removed.push(v2ToV1);
288
+ }
289
+ return removed;
290
290
  };
291
291
  /**
292
292
  * The function returns an array of incoming edges of a given vertex or vertex ID.
@@ -1,5 +1,6 @@
1
1
  import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';
2
2
  import type { VertexId } from '../types';
3
+ import { IUNDirectedGraph } from '../interfaces';
3
4
  export declare class UndirectedVertex<T = number> extends AbstractVertex<T> {
4
5
  /**
5
6
  * The constructor function initializes a vertex with an optional value.
@@ -26,7 +27,7 @@ export declare class UndirectedEdge<T = number> extends AbstractEdge<T> {
26
27
  get vertices(): [VertexId, VertexId];
27
28
  set vertices(v: [VertexId, VertexId]);
28
29
  }
29
- export declare class UndirectedGraph<V extends UndirectedVertex<any> = UndirectedVertex, E extends UndirectedEdge<any> = UndirectedEdge> extends AbstractGraph<V, E> {
30
+ export declare class UndirectedGraph<V extends UndirectedVertex<any> = UndirectedVertex, E extends UndirectedEdge<any> = UndirectedEdge> extends AbstractGraph<V, E> implements IUNDirectedGraph<V, E> {
30
31
  constructor();
31
32
  protected _edges: Map<V, E[]>;
32
33
  get edges(): Map<V, E[]>;
@@ -36,9 +37,9 @@ export declare class UndirectedGraph<V extends UndirectedVertex<any> = Undirecte
36
37
  * @param id
37
38
  * @param val
38
39
  */
39
- _createVertex(id: VertexId, val?: V['val']): V;
40
+ createVertex(id: VertexId, val?: V['val']): V;
40
41
  /**
41
- * The function _createEdge creates an undirected edge between two vertices with an optional weight and value.
42
+ * The function createEdge creates an undirected edge between two vertices with an optional weight and value.
42
43
  * @param {VertexId} v1 - The parameter `v1` represents the first vertex of the edge. It is of type `VertexId`, which
43
44
  * could be a unique identifier or label for the vertex.
44
45
  * @param {VertexId} v2 - The parameter `v2` represents the second vertex of the edge. It is of type `VertexId`, which
@@ -49,7 +50,7 @@ export declare class UndirectedGraph<V extends UndirectedVertex<any> = Undirecte
49
50
  * is used to store additional information or data associated with the edge.
50
51
  * @returns an instance of the UndirectedEdge class, casted as type E.
51
52
  */
52
- _createEdge(v1: VertexId, v2: VertexId, weight?: number, val?: E['val']): E;
53
+ createEdge(v1: VertexId, v2: VertexId, weight?: number, val?: E['val']): E;
53
54
  /**
54
55
  * The function `getEdge` returns the first undirected edge that connects two given vertices, or null if no such edge
55
56
  * exists.
@@ -105,13 +106,6 @@ export declare class UndirectedGraph<V extends UndirectedVertex<any> = Undirecte
105
106
  * @returns The method `edgeSet()` returns an array of `E` objects.
106
107
  */
107
108
  edgeSet(): E[];
108
- /**
109
- * The function "getEdgesOf" returns an array of undirected edges connected to a given vertex or vertex ID.
110
- * @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can be either an
111
- * `V` object or a `VertexId`.
112
- * @returns The function `getEdgesOf` returns an array of `E` objects.
113
- */
114
- getEdgesOf(vertexOrId: V | VertexId): E[];
115
109
  /**
116
110
  * The function `getNeighbors` returns an array of neighboring vertices of a given vertex in an undirected graph.
117
111
  * @param {V | VertexId} vertexOrId - The `vertexOrId` parameter can be either an
@@ -126,11 +126,11 @@ var UndirectedGraph = /** @class */ (function (_super) {
126
126
  * @param id
127
127
  * @param val
128
128
  */
129
- UndirectedGraph.prototype._createVertex = function (id, val) {
129
+ UndirectedGraph.prototype.createVertex = function (id, val) {
130
130
  return new UndirectedVertex(id, val !== null && val !== void 0 ? val : id);
131
131
  };
132
132
  /**
133
- * The function _createEdge creates an undirected edge between two vertices with an optional weight and value.
133
+ * The function createEdge creates an undirected edge between two vertices with an optional weight and value.
134
134
  * @param {VertexId} v1 - The parameter `v1` represents the first vertex of the edge. It is of type `VertexId`, which
135
135
  * could be a unique identifier or label for the vertex.
136
136
  * @param {VertexId} v2 - The parameter `v2` represents the second vertex of the edge. It is of type `VertexId`, which
@@ -141,7 +141,7 @@ var UndirectedGraph = /** @class */ (function (_super) {
141
141
  * is used to store additional information or data associated with the edge.
142
142
  * @returns an instance of the UndirectedEdge class, casted as type E.
143
143
  */
144
- UndirectedGraph.prototype._createEdge = function (v1, v2, weight, val) {
144
+ UndirectedGraph.prototype.createEdge = function (v1, v2, weight, val) {
145
145
  return new UndirectedEdge(v1, v2, weight !== null && weight !== void 0 ? weight : 1, val);
146
146
  };
147
147
  /**
@@ -280,19 +280,6 @@ var UndirectedGraph = /** @class */ (function (_super) {
280
280
  });
281
281
  return __spreadArray([], __read(edgeSet), false);
282
282
  };
283
- /**
284
- * The function "getEdgesOf" returns an array of undirected edges connected to a given vertex or vertex ID.
285
- * @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can be either an
286
- * `V` object or a `VertexId`.
287
- * @returns The function `getEdgesOf` returns an array of `E` objects.
288
- */
289
- UndirectedGraph.prototype.getEdgesOf = function (vertexOrId) {
290
- var vertex = this._getVertex(vertexOrId);
291
- if (!vertex) {
292
- return [];
293
- }
294
- return this._edges.get(vertex) || [];
295
- };
296
283
  /**
297
284
  * The function `getNeighbors` returns an array of neighboring vertices of a given vertex in an undirected graph.
298
285
  * @param {V | VertexId} vertexOrId - The `vertexOrId` parameter can be either an
@@ -304,7 +291,7 @@ var UndirectedGraph = /** @class */ (function (_super) {
304
291
  var neighbors = [];
305
292
  var vertex = this._getVertex(vertexOrId);
306
293
  if (vertex) {
307
- var neighborEdges = this.getEdgesOf(vertex);
294
+ var neighborEdges = this.edgesOf(vertex);
308
295
  try {
309
296
  for (var neighborEdges_1 = __values(neighborEdges), neighborEdges_1_1 = neighborEdges_1.next(); !neighborEdges_1_1.done; neighborEdges_1_1 = neighborEdges_1.next()) {
310
297
  var edge = neighborEdges_1_1.value;
@@ -0,0 +1,101 @@
1
+ import { AbstractBinaryTreeNodeProperties, AbstractBinaryTreeNodeProperty, BinaryTreeDeletedResult, BinaryTreeNodeId, BinaryTreeNodePropertyName, DFSOrderPattern, FamilyPosition, LoopType, NodeOrPropertyName } from '../types';
2
+ import { AbstractBinaryTreeNode } from '../binary-tree';
3
+ export interface IAbstractBinaryTreeNode<T, FAMILY extends IAbstractBinaryTreeNode<T, FAMILY>> {
4
+ createNode(id: BinaryTreeNodeId, val?: T, count?: number): FAMILY;
5
+ get id(): BinaryTreeNodeId;
6
+ set id(v: BinaryTreeNodeId);
7
+ get val(): T | undefined;
8
+ set val(v: T | undefined);
9
+ get left(): FAMILY | null | undefined;
10
+ set left(v: FAMILY | null | undefined);
11
+ get right(): FAMILY | null | undefined;
12
+ set right(v: FAMILY | null | undefined);
13
+ get parent(): FAMILY | null | undefined;
14
+ set parent(v: FAMILY | null | undefined);
15
+ get familyPosition(): FamilyPosition;
16
+ set familyPosition(v: FamilyPosition);
17
+ get count(): number;
18
+ set count(v: number);
19
+ get height(): number;
20
+ set height(v: number);
21
+ swapLocation(swapNode: FAMILY): FAMILY;
22
+ clone(): FAMILY | null;
23
+ }
24
+ export interface IAbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val'], N>> {
25
+ createNode(id: BinaryTreeNodeId, val: N['val'] | null, count?: number): N | null;
26
+ get loopType(): LoopType;
27
+ get visitedId(): BinaryTreeNodeId[];
28
+ get visitedVal(): Array<N['val']>;
29
+ get visitedNode(): N[];
30
+ get visitedCount(): number[];
31
+ get visitedLeftSum(): number[];
32
+ get autoIncrementId(): boolean;
33
+ get maxId(): number;
34
+ get isDuplicatedVal(): boolean;
35
+ get root(): N | null;
36
+ get size(): number;
37
+ get count(): number;
38
+ clear(): void;
39
+ isEmpty(): boolean;
40
+ add(id: BinaryTreeNodeId, val?: N['val'], count?: number): N | null | undefined;
41
+ addTo(newNode: N | null, parent: N): N | null | undefined;
42
+ addMany(data: N[] | Array<N['val']>): (N | null | undefined)[];
43
+ fill(data: N[] | Array<N['val']>): boolean;
44
+ remove(id: BinaryTreeNodeId, ignoreCount?: boolean): BinaryTreeDeletedResult<N>[];
45
+ getDepth(node: N): number;
46
+ getHeight(beginRoot?: N | null): number;
47
+ getMinHeight(beginRoot?: N | null): number;
48
+ isBalanced(beginRoot?: N | null): boolean;
49
+ getNodes(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): N[];
50
+ has(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName): boolean;
51
+ get(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName): N | null;
52
+ getPathToRoot(node: N): N[];
53
+ getLeftMost(): N | null;
54
+ getLeftMost(node: N): N;
55
+ getLeftMost(node?: N | null): N | null;
56
+ getRightMost(): N | null;
57
+ getRightMost(node: N): N;
58
+ getRightMost(node?: N | null): N | null;
59
+ isBSTByRooted(node: N | null): boolean;
60
+ isBST(node?: N | null): boolean;
61
+ getSubTreeSizeAndCount(subTreeRoot: N | null | undefined): [number, number];
62
+ subTreeSum(subTreeRoot: N, propertyName?: BinaryTreeNodePropertyName): number;
63
+ subTreeAdd(subTreeRoot: N, delta: number, propertyName?: BinaryTreeNodePropertyName): boolean;
64
+ BFS(): BinaryTreeNodeId[];
65
+ BFS(nodeOrPropertyName: 'id'): BinaryTreeNodeId[];
66
+ BFS(nodeOrPropertyName: 'val'): N['val'][];
67
+ BFS(nodeOrPropertyName: 'node'): N[];
68
+ BFS(nodeOrPropertyName: 'count'): number[];
69
+ BFS(nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
70
+ DFS(): BinaryTreeNodeId[];
71
+ DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
72
+ DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
73
+ DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
74
+ DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'count'): number[];
75
+ DFS(pattern?: 'in' | 'pre' | 'post', nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
76
+ DFSIterative(): BinaryTreeNodeId[];
77
+ DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
78
+ DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
79
+ DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
80
+ DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'count'): number[];
81
+ DFSIterative(pattern?: 'in' | 'pre' | 'post', nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
82
+ levelIterative(node: N | null): BinaryTreeNodeId[];
83
+ levelIterative(node: N | null, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
84
+ levelIterative(node: N | null, nodeOrPropertyName?: 'val'): N['val'][];
85
+ levelIterative(node: N | null, nodeOrPropertyName?: 'node'): N[];
86
+ levelIterative(node: N | null, nodeOrPropertyName?: 'count'): number[];
87
+ levelIterative(node: N | null, nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
88
+ listLevels(node: N | null): BinaryTreeNodeId[][];
89
+ listLevels(node: N | null, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[][];
90
+ listLevels(node: N | null, nodeOrPropertyName?: 'val'): N['val'][][];
91
+ listLevels(node: N | null, nodeOrPropertyName?: 'node'): N[][];
92
+ listLevels(node: N | null, nodeOrPropertyName?: 'count'): number[][];
93
+ listLevels(node: N | null, nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperty<N>[][];
94
+ getPredecessor(node: N): N;
95
+ morris(): BinaryTreeNodeId[];
96
+ morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
97
+ morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
98
+ morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
99
+ morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'count'): number[];
100
+ morris(pattern?: 'in' | 'pre' | 'post', nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
101
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,8 +1,6 @@
1
1
  import { VertexId } from '../types';
2
- export interface IGraph<V, E> {
2
+ export interface IAbstractGraph<V, E> {
3
3
  hasVertex(vertexOrId: V | VertexId): boolean;
4
- _getVertex(vertexOrId: VertexId | V): V | null;
5
- _getVertexId(vertexOrId: V | VertexId): VertexId;
6
4
  createAddVertex(id: VertexId, val?: V): boolean;
7
5
  addVertex(newVertex: V): boolean;
8
6
  removeVertex(vertexOrId: V | VertexId): boolean;
@@ -14,7 +12,6 @@ export interface IGraph<V, E> {
14
12
  edgeSet(): E[];
15
13
  createAddEdge(src: V | VertexId, dest: V | VertexId, weight: number, val: E): boolean;
16
14
  addEdge(edge: E): boolean;
17
- removeEdgeBetween(src: V | VertexId, dest: V | VertexId): E | null;
18
15
  removeEdge(edge: E): E | null;
19
16
  setEdgeWeight(srcOrId: V | VertexId, destOrId: V | VertexId, weight: number): boolean;
20
17
  getMinPathBetween(v1: V | VertexId, v2: V | VertexId, isWeight?: boolean): V[] | null;
@@ -1 +1,16 @@
1
- export {};
1
+ import { AVLTreeNode } from '../binary-tree';
2
+ import { IBST, IBSTNode } from './bst';
3
+ import { BinaryTreeDeletedResult, BinaryTreeNodeId } from '../types';
4
+ export interface IAVLTreeNode<T, FAMILY extends IAVLTreeNode<T, FAMILY>> extends IBSTNode<T, FAMILY> {
5
+ }
6
+ export interface IAVLTree<N extends AVLTreeNode<N['val'], N>> extends IBST<N> {
7
+ add(id: BinaryTreeNodeId, val: N['val'] | null, count?: number): N | null;
8
+ remove(id: BinaryTreeNodeId, isUpdateAllLeftSum?: boolean): BinaryTreeDeletedResult<N>[];
9
+ balanceFactor(node: N): number;
10
+ updateHeight(node: N): void;
11
+ balancePath(node: N): void;
12
+ balanceLL(A: N): void;
13
+ balanceLR(A: N): void;
14
+ balanceRR(A: N): void;
15
+ balanceRL(A: N): void;
16
+ }