data-structure-typed 1.52.4 → 1.52.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 (181) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +13 -13
  3. package/README_zh-CN.md +216 -26
  4. package/benchmark/report.html +13 -13
  5. package/benchmark/report.json +158 -158
  6. package/dist/cjs/data-structures/base/iterable-element-base.d.ts +1 -37
  7. package/dist/cjs/data-structures/base/iterable-element-base.js +1 -37
  8. package/dist/cjs/data-structures/base/iterable-element-base.js.map +1 -1
  9. package/dist/cjs/data-structures/base/iterable-entry-base.d.ts +2 -54
  10. package/dist/cjs/data-structures/base/iterable-entry-base.js +1 -49
  11. package/dist/cjs/data-structures/base/iterable-entry-base.js.map +1 -1
  12. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -32
  13. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +9 -41
  14. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  15. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +0 -46
  16. package/dist/cjs/data-structures/binary-tree/avl-tree.js +0 -46
  17. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  18. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +82 -147
  19. package/dist/cjs/data-structures/binary-tree/binary-tree.js +299 -331
  20. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  21. package/dist/cjs/data-structures/binary-tree/bst.d.ts +1 -40
  22. package/dist/cjs/data-structures/binary-tree/bst.js +12 -44
  23. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  24. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +0 -48
  25. package/dist/cjs/data-structures/binary-tree/rb-tree.js +2 -50
  26. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  27. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +0 -32
  28. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +9 -41
  29. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  30. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +0 -75
  31. package/dist/cjs/data-structures/graph/abstract-graph.js +0 -75
  32. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  33. package/dist/cjs/data-structures/graph/directed-graph.d.ts +0 -98
  34. package/dist/cjs/data-structures/graph/directed-graph.js +0 -98
  35. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  36. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +0 -50
  37. package/dist/cjs/data-structures/graph/undirected-graph.js +0 -50
  38. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  39. package/dist/cjs/data-structures/hash/hash-map.d.ts +5 -92
  40. package/dist/cjs/data-structures/hash/hash-map.js +27 -111
  41. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  42. package/dist/cjs/data-structures/heap/heap.d.ts +0 -32
  43. package/dist/cjs/data-structures/heap/heap.js +0 -32
  44. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  45. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +5 -88
  46. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +5 -88
  47. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  48. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +1 -83
  49. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +2 -84
  50. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  51. package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +1 -35
  52. package/dist/cjs/data-structures/linked-list/skip-linked-list.js +1 -35
  53. package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +1 -1
  54. package/dist/cjs/data-structures/queue/deque.d.ts +1 -98
  55. package/dist/cjs/data-structures/queue/deque.js +3 -99
  56. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  57. package/dist/cjs/data-structures/queue/queue.d.ts +1 -54
  58. package/dist/cjs/data-structures/queue/queue.js +0 -53
  59. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  60. package/dist/cjs/data-structures/stack/stack.d.ts +1 -34
  61. package/dist/cjs/data-structures/stack/stack.js +1 -34
  62. package/dist/cjs/data-structures/stack/stack.js.map +1 -1
  63. package/dist/cjs/data-structures/tree/tree.js +0 -1
  64. package/dist/cjs/data-structures/tree/tree.js.map +1 -1
  65. package/dist/cjs/data-structures/trie/trie.d.ts +0 -64
  66. package/dist/cjs/data-structures/trie/trie.js +0 -64
  67. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  68. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +8 -0
  69. package/dist/cjs/types/data-structures/binary-tree/binary-tree.js +6 -0
  70. package/dist/cjs/types/data-structures/binary-tree/binary-tree.js.map +1 -1
  71. package/dist/cjs/types/utils/utils.d.ts +13 -12
  72. package/dist/cjs/utils/number.d.ts +13 -0
  73. package/dist/cjs/utils/number.js +13 -0
  74. package/dist/cjs/utils/number.js.map +1 -1
  75. package/dist/cjs/utils/utils.d.ts +125 -3
  76. package/dist/cjs/utils/utils.js +177 -21
  77. package/dist/cjs/utils/utils.js.map +1 -1
  78. package/dist/mjs/data-structures/base/iterable-element-base.d.ts +1 -37
  79. package/dist/mjs/data-structures/base/iterable-element-base.js +1 -37
  80. package/dist/mjs/data-structures/base/iterable-entry-base.d.ts +2 -54
  81. package/dist/mjs/data-structures/base/iterable-entry-base.js +1 -49
  82. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -32
  83. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js +9 -41
  84. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +0 -46
  85. package/dist/mjs/data-structures/binary-tree/avl-tree.js +0 -46
  86. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +82 -147
  87. package/dist/mjs/data-structures/binary-tree/binary-tree.js +298 -332
  88. package/dist/mjs/data-structures/binary-tree/bst.d.ts +1 -40
  89. package/dist/mjs/data-structures/binary-tree/bst.js +12 -44
  90. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +0 -48
  91. package/dist/mjs/data-structures/binary-tree/rb-tree.js +2 -50
  92. package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +0 -32
  93. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +9 -41
  94. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +0 -75
  95. package/dist/mjs/data-structures/graph/abstract-graph.js +0 -75
  96. package/dist/mjs/data-structures/graph/directed-graph.d.ts +0 -98
  97. package/dist/mjs/data-structures/graph/directed-graph.js +0 -98
  98. package/dist/mjs/data-structures/graph/undirected-graph.d.ts +0 -50
  99. package/dist/mjs/data-structures/graph/undirected-graph.js +0 -50
  100. package/dist/mjs/data-structures/hash/hash-map.d.ts +5 -92
  101. package/dist/mjs/data-structures/hash/hash-map.js +27 -111
  102. package/dist/mjs/data-structures/heap/heap.d.ts +0 -32
  103. package/dist/mjs/data-structures/heap/heap.js +0 -32
  104. package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +5 -88
  105. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +5 -88
  106. package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +1 -83
  107. package/dist/mjs/data-structures/linked-list/singly-linked-list.js +2 -84
  108. package/dist/mjs/data-structures/linked-list/skip-linked-list.d.ts +1 -35
  109. package/dist/mjs/data-structures/linked-list/skip-linked-list.js +1 -35
  110. package/dist/mjs/data-structures/queue/deque.d.ts +1 -98
  111. package/dist/mjs/data-structures/queue/deque.js +3 -99
  112. package/dist/mjs/data-structures/queue/queue.d.ts +1 -54
  113. package/dist/mjs/data-structures/queue/queue.js +0 -53
  114. package/dist/mjs/data-structures/stack/stack.d.ts +1 -34
  115. package/dist/mjs/data-structures/stack/stack.js +1 -34
  116. package/dist/mjs/data-structures/tree/tree.js +0 -1
  117. package/dist/mjs/data-structures/trie/trie.d.ts +0 -64
  118. package/dist/mjs/data-structures/trie/trie.js +0 -64
  119. package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +8 -0
  120. package/dist/mjs/types/data-structures/binary-tree/binary-tree.js +5 -1
  121. package/dist/mjs/types/utils/utils.d.ts +13 -12
  122. package/dist/mjs/utils/number.d.ts +13 -0
  123. package/dist/mjs/utils/number.js +13 -0
  124. package/dist/mjs/utils/utils.d.ts +125 -3
  125. package/dist/mjs/utils/utils.js +177 -21
  126. package/dist/umd/data-structure-typed.js +408 -1474
  127. package/dist/umd/data-structure-typed.min.js +5 -4
  128. package/dist/umd/data-structure-typed.min.js.map +1 -1
  129. package/package.json +6 -6
  130. package/src/data-structures/base/iterable-element-base.ts +2 -42
  131. package/src/data-structures/base/iterable-entry-base.ts +3 -62
  132. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +8 -48
  133. package/src/data-structures/binary-tree/avl-tree.ts +0 -57
  134. package/src/data-structures/binary-tree/binary-tree.ts +329 -358
  135. package/src/data-structures/binary-tree/bst.ts +11 -54
  136. package/src/data-structures/binary-tree/rb-tree.ts +2 -62
  137. package/src/data-structures/binary-tree/tree-multi-map.ts +8 -48
  138. package/src/data-structures/graph/abstract-graph.ts +0 -92
  139. package/src/data-structures/graph/directed-graph.ts +0 -122
  140. package/src/data-structures/graph/undirected-graph.ts +0 -62
  141. package/src/data-structures/hash/hash-map.ts +29 -133
  142. package/src/data-structures/heap/heap.ts +0 -40
  143. package/src/data-structures/linked-list/doubly-linked-list.ts +5 -112
  144. package/src/data-structures/linked-list/singly-linked-list.ts +2 -104
  145. package/src/data-structures/linked-list/skip-linked-list.ts +1 -44
  146. package/src/data-structures/queue/deque.ts +2 -125
  147. package/src/data-structures/queue/queue.ts +1 -68
  148. package/src/data-structures/stack/stack.ts +1 -43
  149. package/src/data-structures/tree/tree.ts +1 -1
  150. package/src/data-structures/trie/trie.ts +0 -80
  151. package/src/types/data-structures/binary-tree/binary-tree.ts +8 -1
  152. package/src/types/utils/utils.ts +17 -15
  153. package/src/utils/number.ts +13 -0
  154. package/src/utils/utils.ts +174 -18
  155. package/test/config.ts +8 -0
  156. package/test/integration/all-in-one.test.ts +1 -1
  157. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +13 -13
  158. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +18 -13
  159. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +471 -64
  160. package/test/unit/data-structures/binary-tree/bst.test.ts +167 -23
  161. package/test/unit/data-structures/binary-tree/overall.test.ts +1 -1
  162. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +136 -13
  163. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +18 -13
  164. package/test/unit/data-structures/graph/directed-graph.test.ts +46 -32
  165. package/test/unit/data-structures/graph/map-graph.test.ts +24 -2
  166. package/test/unit/data-structures/graph/undirected-graph.test.ts +24 -24
  167. package/test/unit/data-structures/hash/hash-map.test.ts +225 -35
  168. package/test/unit/data-structures/heap/heap.test.ts +47 -39
  169. package/test/unit/data-structures/heap/min-heap.test.ts +5 -5
  170. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +34 -4
  171. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +32 -0
  172. package/test/unit/data-structures/matrix/matrix.test.ts +35 -5
  173. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +31 -0
  174. package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +18 -0
  175. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +17 -0
  176. package/test/unit/data-structures/queue/deque.test.ts +288 -47
  177. package/test/unit/data-structures/queue/queue.test.ts +62 -37
  178. package/test/unit/data-structures/stack/stack.test.ts +30 -5
  179. package/test/unit/data-structures/tree/tree.test.ts +58 -0
  180. package/test/unit/data-structures/trie/trie.test.ts +46 -5
  181. package/test/unit/utils/utils.test.ts +169 -0
@@ -45,10 +45,6 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
45
45
  protected _inEdgeMap: Map<VO, EO[]>;
46
46
  get inEdgeMap(): Map<VO, EO[]>;
47
47
  set inEdgeMap(v: Map<VO, EO[]>);
48
- /**
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
- * 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.
51
- */
52
48
  /**
53
49
  * The function creates a new vertex with an optional value and returns it.
54
50
  * @param {VertexKey} key - The `key` parameter is the unique identifier for the vertex. It is of type `VertexKey`, which
@@ -59,10 +55,6 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
59
55
  * @returns a new instance of a DirectedVertex object, casted as type VO.
60
56
  */
61
57
  createVertex(key: VertexKey, value?: V): VO;
62
- /**
63
- * 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.
64
- * 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.
65
- */
66
58
  /**
67
59
  * The function creates a directed edge between two vertexMap with an optional weight and value.
68
60
  * @param {VertexKey} src - The source vertex ID of the edge. It represents the starting point of the edge.
@@ -74,10 +66,6 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
74
66
  * @returns a new instance of a DirectedEdge object, casted as type EO.
75
67
  */
76
68
  createEdge(src: VertexKey, dest: VertexKey, weight?: number, value?: E): EO;
77
- /**
78
- * Time Complexity: O(|V|) where |V| is the number of vertexMap
79
- * Space Complexity: O(1)
80
- */
81
69
  /**
82
70
  * Time Complexity: O(|V|) where |V| is the number of vertexMap
83
71
  * Space Complexity: O(1)
@@ -90,10 +78,6 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
90
78
  * @returns the first edge found between the source and destination vertexMap, or undefined if no such edge is found.
91
79
  */
92
80
  getEdge(srcOrKey: VO | VertexKey | undefined, destOrKey: VO | VertexKey | undefined): EO | undefined;
93
- /**
94
- * Time Complexity: O(|E|) where |E| is the number of edgeMap
95
- * Space Complexity: O(1)
96
- */
97
81
  /**
98
82
  * Time Complexity: O(|E|) where |E| is the number of edgeMap
99
83
  * Space Complexity: O(1)
@@ -104,10 +88,6 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
104
88
  * @returns the removed edge (EO) if it exists, or undefined if either the source or destination vertex does not exist.
105
89
  */
106
90
  deleteEdgeSrcToDest(srcOrKey: VO | VertexKey, destOrKey: VO | VertexKey): EO | undefined;
107
- /**
108
- * Time Complexity: O(E) where E is the number of edgeMap
109
- * Space Complexity: O(1)
110
- */
111
91
  /**
112
92
  * Time Complexity: O(E) where E is the number of edgeMap
113
93
  * Space Complexity: O(1)
@@ -122,10 +102,6 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
122
102
  * @returns the removed edge (EO) or undefined if no edge was removed.
123
103
  */
124
104
  deleteEdge(edgeOrSrcVertexKey: EO | VertexKey, destVertexKey?: VertexKey): EO | undefined;
125
- /**
126
- * Time Complexity: O(1) - Constant time for Map operations.
127
- * Space Complexity: O(1) - Constant space, as it creates only a few variables.
128
- */
129
105
  /**
130
106
  * Time Complexity: O(1) - Constant time for Map operations.
131
107
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
@@ -136,10 +112,6 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
136
112
  * @returns The method is returning a boolean value.
137
113
  */
138
114
  deleteVertex(vertexOrKey: VO | VertexKey): boolean;
139
- /**
140
- * Time Complexity: O(|E|) where |E| is the number of edgeMap
141
- * Space Complexity: O(1)
142
- */
143
115
  /**
144
116
  * Time Complexity: O(|E|) where |E| is the number of edgeMap
145
117
  * Space Complexity: O(1)
@@ -152,10 +124,6 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
152
124
  * @returns an array of removed edgeMap (EO[]).
153
125
  */
154
126
  deleteEdgesBetween(v1: VertexKey | VO, v2: VertexKey | VO): EO[];
155
- /**
156
- * Time Complexity: O(1)
157
- * Space Complexity: O(1)
158
- */
159
127
  /**
160
128
  * Time Complexity: O(1)
161
129
  * Space Complexity: O(1)
@@ -166,10 +134,6 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
166
134
  * @returns The method `incomingEdgesOf` returns an array of edgeMap (`EO[]`).
167
135
  */
168
136
  incomingEdgesOf(vertexOrKey: VO | VertexKey): EO[];
169
- /**
170
- * Time Complexity: O(1)
171
- * Space Complexity: O(1)
172
- */
173
137
  /**
174
138
  * Time Complexity: O(1)
175
139
  * Space Complexity: O(1)
@@ -180,10 +144,6 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
180
144
  * @returns The method `outgoingEdgesOf` returns an array of edgeMap (`EO[]`).
181
145
  */
182
146
  outgoingEdgesOf(vertexOrKey: VO | VertexKey): EO[];
183
- /**
184
- * Time Complexity: O(1)
185
- * Space Complexity: O(1)
186
- */
187
147
  /**
188
148
  * Time Complexity: O(1)
189
149
  * Space Complexity: O(1)
@@ -193,10 +153,6 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
193
153
  * @returns The sum of the out-degree and in-degree of the specified vertex or vertex ID.
194
154
  */
195
155
  degreeOf(vertexOrKey: VertexKey | VO): number;
196
- /**
197
- * Time Complexity: O(1)
198
- * Space Complexity: O(1)
199
- */
200
156
  /**
201
157
  * Time Complexity: O(1)
202
158
  * Space Complexity: O(1)
@@ -206,10 +162,6 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
206
162
  * @returns The number of incoming edgeMap of the specified vertex or vertex ID.
207
163
  */
208
164
  inDegreeOf(vertexOrKey: VertexKey | VO): number;
209
- /**
210
- * Time Complexity: O(1)
211
- * Space Complexity: O(1)
212
- */
213
165
  /**
214
166
  * Time Complexity: O(1)
215
167
  * Space Complexity: O(1)
@@ -219,10 +171,6 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
219
171
  * @returns The number of outgoing edgeMap from the specified vertex or vertex ID.
220
172
  */
221
173
  outDegreeOf(vertexOrKey: VertexKey | VO): number;
222
- /**
223
- * Time Complexity: O(1)
224
- * Space Complexity: O(1)
225
- */
226
174
  /**
227
175
  * Time Complexity: O(1)
228
176
  * Space Complexity: O(1)
@@ -232,10 +180,6 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
232
180
  * @returns The function `edgesOf` returns an array of edgeMap.
233
181
  */
234
182
  edgesOf(vertexOrKey: VertexKey | VO): EO[];
235
- /**
236
- * Time Complexity: O(1)
237
- * Space Complexity: O(1)
238
- */
239
183
  /**
240
184
  * Time Complexity: O(1)
241
185
  * Space Complexity: O(1)
@@ -245,10 +189,6 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
245
189
  * @returns either a vertex object (VO) or undefined.
246
190
  */
247
191
  getEdgeSrc(e: EO): VO | undefined;
248
- /**
249
- * Time Complexity: O(1)
250
- * Space Complexity: O(1)
251
- */
252
192
  /**
253
193
  * Time Complexity: O(1)
254
194
  * Space Complexity: O(1)
@@ -258,10 +198,6 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
258
198
  * @returns either a vertex object of type VO or undefined.
259
199
  */
260
200
  getEdgeDest(e: EO): VO | undefined;
261
- /**
262
- * Time Complexity: O(|E|) where |E| is the number of edgeMap
263
- * Space Complexity: O(1)
264
- */
265
201
  /**
266
202
  * Time Complexity: O(|E|) where |E| is the number of edgeMap
267
203
  * Space Complexity: O(1)
@@ -272,10 +208,6 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
272
208
  * @returns an array of vertexMap (VO[]).
273
209
  */
274
210
  getDestinations(vertex: VO | VertexKey | undefined): VO[];
275
- /**
276
- * Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
277
- * Space Complexity: O(|V|)
278
- */
279
211
  /**
280
212
  * Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
281
213
  * Space Complexity: O(|V|)
@@ -288,10 +220,6 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
288
220
  * @returns an array of vertexMap or vertex IDs in topological order. If there is a cycle in the graph, it returns undefined.
289
221
  */
290
222
  topologicalSort(propertyName?: 'vertex' | 'key'): Array<VO | VertexKey> | undefined;
291
- /**
292
- * Time Complexity: O(|E|) where |E| is the number of edgeMap
293
- * Space Complexity: O(|E|)
294
- */
295
223
  /**
296
224
  * Time Complexity: O(|E|) where |E| is the number of edgeMap
297
225
  * Space Complexity: O(|E|)
@@ -300,10 +228,6 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
300
228
  * @returns The `edgeSet()` method returns an array of edgeMap (`EO[]`).
301
229
  */
302
230
  edgeSet(): EO[];
303
- /**
304
- * Time Complexity: O(|E|) where |E| is the number of edgeMap
305
- * Space Complexity: O(1)
306
- */
307
231
  /**
308
232
  * Time Complexity: O(|E|) where |E| is the number of edgeMap
309
233
  * Space Complexity: O(1)
@@ -314,10 +238,6 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
314
238
  * @returns an array of vertexMap (VO[]).
315
239
  */
316
240
  getNeighbors(vertexOrKey: VO | VertexKey): VO[];
317
- /**
318
- * Time Complexity: O(1)
319
- * Space Complexity: O(1)
320
- */
321
241
  /**
322
242
  * Time Complexity: O(1)
323
243
  * Space Complexity: O(1)
@@ -335,10 +255,6 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
335
255
  * @return A boolean value
336
256
  */
337
257
  isEmpty(): boolean;
338
- /**
339
- * Time Complexity: O(1)
340
- * Space Complexity: O(1)
341
- */
342
258
  /**
343
259
  * Time Complexity: O(1)
344
260
  * Space Complexity: O(1)
@@ -352,12 +268,6 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
352
268
  * @return A new instance of the directedgraph class
353
269
  */
354
270
  clone(): DirectedGraph<V, E, VO, EO>;
355
- /**
356
- * Time Complexity: O(V + E)
357
- * Space Complexity: O(V)
358
- * Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
359
- * Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs.
360
- */
361
271
  /**
362
272
  * Time Complexity: O(V + E)
363
273
  * Space Complexity: O(V)
@@ -374,10 +284,6 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
374
284
  lowMap: Map<VO, number>;
375
285
  SCCs: Map<number, VO[]>;
376
286
  };
377
- /**
378
- * Time Complexity: O(V + E) - Depends on the implementation (Tarjan's algorithm).
379
- * Space Complexity: O(V) - Depends on the implementation (Tarjan's algorithm).
380
- */
381
287
  /**
382
288
  * Time Complexity: O(V + E) - Depends on the implementation (Tarjan's algorithm).
383
289
  * Space Complexity: O(V) - Depends on the implementation (Tarjan's algorithm).
@@ -400,10 +306,6 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
400
306
  * @returns a map where the keys are numbers and the values are arrays of VO objects.
401
307
  */
402
308
  getSCCs(): Map<number, VO[]>;
403
- /**
404
- * Time Complexity: O(1)
405
- * Space Complexity: O(1)
406
- */
407
309
  /**
408
310
  * Time Complexity: O(1)
409
311
  * Space Complexity: O(1)
@@ -53,10 +53,6 @@ export class DirectedGraph extends AbstractGraph {
53
53
  set inEdgeMap(v) {
54
54
  this._inEdgeMap = v;
55
55
  }
56
- /**
57
- * 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.
58
- * 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.
59
- */
60
56
  /**
61
57
  * The function creates a new vertex with an optional value and returns it.
62
58
  * @param {VertexKey} key - The `key` parameter is the unique identifier for the vertex. It is of type `VertexKey`, which
@@ -69,10 +65,6 @@ export class DirectedGraph extends AbstractGraph {
69
65
  createVertex(key, value) {
70
66
  return new DirectedVertex(key, value);
71
67
  }
72
- /**
73
- * 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.
74
- * 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.
75
- */
76
68
  /**
77
69
  * The function creates a directed edge between two vertexMap with an optional weight and value.
78
70
  * @param {VertexKey} src - The source vertex ID of the edge. It represents the starting point of the edge.
@@ -86,10 +78,6 @@ export class DirectedGraph extends AbstractGraph {
86
78
  createEdge(src, dest, weight, value) {
87
79
  return new DirectedEdge(src, dest, weight ?? 1, value);
88
80
  }
89
- /**
90
- * Time Complexity: O(|V|) where |V| is the number of vertexMap
91
- * Space Complexity: O(1)
92
- */
93
81
  /**
94
82
  * Time Complexity: O(|V|) where |V| is the number of vertexMap
95
83
  * Space Complexity: O(1)
@@ -115,10 +103,6 @@ export class DirectedGraph extends AbstractGraph {
115
103
  }
116
104
  return edgeMap[0] || undefined;
117
105
  }
118
- /**
119
- * Time Complexity: O(|E|) where |E| is the number of edgeMap
120
- * Space Complexity: O(1)
121
- */
122
106
  /**
123
107
  * Time Complexity: O(|E|) where |E| is the number of edgeMap
124
108
  * Space Complexity: O(1)
@@ -145,10 +129,6 @@ export class DirectedGraph extends AbstractGraph {
145
129
  }
146
130
  return removed;
147
131
  }
148
- /**
149
- * Time Complexity: O(E) where E is the number of edgeMap
150
- * Space Complexity: O(1)
151
- */
152
132
  /**
153
133
  * Time Complexity: O(E) where E is the number of edgeMap
154
134
  * Space Complexity: O(1)
@@ -190,10 +170,6 @@ export class DirectedGraph extends AbstractGraph {
190
170
  }
191
171
  return removed;
192
172
  }
193
- /**
194
- * Time Complexity: O(1) - Constant time for Map operations.
195
- * Space Complexity: O(1) - Constant space, as it creates only a few variables.
196
- */
197
173
  /**
198
174
  * Time Complexity: O(1) - Constant time for Map operations.
199
175
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
@@ -225,10 +201,6 @@ export class DirectedGraph extends AbstractGraph {
225
201
  }
226
202
  return this._vertexMap.delete(vertexKey);
227
203
  }
228
- /**
229
- * Time Complexity: O(|E|) where |E| is the number of edgeMap
230
- * Space Complexity: O(1)
231
- */
232
204
  /**
233
205
  * Time Complexity: O(|E|) where |E| is the number of edgeMap
234
206
  * Space Complexity: O(1)
@@ -250,10 +222,6 @@ export class DirectedGraph extends AbstractGraph {
250
222
  }
251
223
  return removed;
252
224
  }
253
- /**
254
- * Time Complexity: O(1)
255
- * Space Complexity: O(1)
256
- */
257
225
  /**
258
226
  * Time Complexity: O(1)
259
227
  * Space Complexity: O(1)
@@ -270,10 +238,6 @@ export class DirectedGraph extends AbstractGraph {
270
238
  }
271
239
  return [];
272
240
  }
273
- /**
274
- * Time Complexity: O(1)
275
- * Space Complexity: O(1)
276
- */
277
241
  /**
278
242
  * Time Complexity: O(1)
279
243
  * Space Complexity: O(1)
@@ -290,10 +254,6 @@ export class DirectedGraph extends AbstractGraph {
290
254
  }
291
255
  return [];
292
256
  }
293
- /**
294
- * Time Complexity: O(1)
295
- * Space Complexity: O(1)
296
- */
297
257
  /**
298
258
  * Time Complexity: O(1)
299
259
  * Space Complexity: O(1)
@@ -305,10 +265,6 @@ export class DirectedGraph extends AbstractGraph {
305
265
  degreeOf(vertexOrKey) {
306
266
  return this.outDegreeOf(vertexOrKey) + this.inDegreeOf(vertexOrKey);
307
267
  }
308
- /**
309
- * Time Complexity: O(1)
310
- * Space Complexity: O(1)
311
- */
312
268
  /**
313
269
  * Time Complexity: O(1)
314
270
  * Space Complexity: O(1)
@@ -320,10 +276,6 @@ export class DirectedGraph extends AbstractGraph {
320
276
  inDegreeOf(vertexOrKey) {
321
277
  return this.incomingEdgesOf(vertexOrKey).length;
322
278
  }
323
- /**
324
- * Time Complexity: O(1)
325
- * Space Complexity: O(1)
326
- */
327
279
  /**
328
280
  * Time Complexity: O(1)
329
281
  * Space Complexity: O(1)
@@ -335,10 +287,6 @@ export class DirectedGraph extends AbstractGraph {
335
287
  outDegreeOf(vertexOrKey) {
336
288
  return this.outgoingEdgesOf(vertexOrKey).length;
337
289
  }
338
- /**
339
- * Time Complexity: O(1)
340
- * Space Complexity: O(1)
341
- */
342
290
  /**
343
291
  * Time Complexity: O(1)
344
292
  * Space Complexity: O(1)
@@ -350,10 +298,6 @@ export class DirectedGraph extends AbstractGraph {
350
298
  edgesOf(vertexOrKey) {
351
299
  return [...this.outgoingEdgesOf(vertexOrKey), ...this.incomingEdgesOf(vertexOrKey)];
352
300
  }
353
- /**
354
- * Time Complexity: O(1)
355
- * Space Complexity: O(1)
356
- */
357
301
  /**
358
302
  * Time Complexity: O(1)
359
303
  * Space Complexity: O(1)
@@ -365,10 +309,6 @@ export class DirectedGraph extends AbstractGraph {
365
309
  getEdgeSrc(e) {
366
310
  return this._getVertex(e.src);
367
311
  }
368
- /**
369
- * Time Complexity: O(1)
370
- * Space Complexity: O(1)
371
- */
372
312
  /**
373
313
  * Time Complexity: O(1)
374
314
  * Space Complexity: O(1)
@@ -380,10 +320,6 @@ export class DirectedGraph extends AbstractGraph {
380
320
  getEdgeDest(e) {
381
321
  return this._getVertex(e.dest);
382
322
  }
383
- /**
384
- * Time Complexity: O(|E|) where |E| is the number of edgeMap
385
- * Space Complexity: O(1)
386
- */
387
323
  /**
388
324
  * Time Complexity: O(|E|) where |E| is the number of edgeMap
389
325
  * Space Complexity: O(1)
@@ -407,10 +343,6 @@ export class DirectedGraph extends AbstractGraph {
407
343
  }
408
344
  return destinations;
409
345
  }
410
- /**
411
- * Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
412
- * Space Complexity: O(|V|)
413
- */
414
346
  /**
415
347
  * Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
416
348
  * Space Complexity: O(|V|)
@@ -458,10 +390,6 @@ export class DirectedGraph extends AbstractGraph {
458
390
  sorted = sorted.map(vertex => (vertex instanceof DirectedVertex ? vertex.key : vertex));
459
391
  return sorted.reverse();
460
392
  }
461
- /**
462
- * Time Complexity: O(|E|) where |E| is the number of edgeMap
463
- * Space Complexity: O(|E|)
464
- */
465
393
  /**
466
394
  * Time Complexity: O(|E|) where |E| is the number of edgeMap
467
395
  * Space Complexity: O(|E|)
@@ -476,10 +404,6 @@ export class DirectedGraph extends AbstractGraph {
476
404
  });
477
405
  return edgeMap;
478
406
  }
479
- /**
480
- * Time Complexity: O(|E|) where |E| is the number of edgeMap
481
- * Space Complexity: O(1)
482
- */
483
407
  /**
484
408
  * Time Complexity: O(|E|) where |E| is the number of edgeMap
485
409
  * Space Complexity: O(1)
@@ -504,10 +428,6 @@ export class DirectedGraph extends AbstractGraph {
504
428
  }
505
429
  return neighbors;
506
430
  }
507
- /**
508
- * Time Complexity: O(1)
509
- * Space Complexity: O(1)
510
- */
511
431
  /**
512
432
  * Time Complexity: O(1)
513
433
  * Space Complexity: O(1)
@@ -539,10 +459,6 @@ export class DirectedGraph extends AbstractGraph {
539
459
  isEmpty() {
540
460
  return this.vertexMap.size === 0 && this.inEdgeMap.size === 0 && this.outEdgeMap.size === 0;
541
461
  }
542
- /**
543
- * Time Complexity: O(1)
544
- * Space Complexity: O(1)
545
- */
546
462
  /**
547
463
  * Time Complexity: O(1)
548
464
  * Space Complexity: O(1)
@@ -566,12 +482,6 @@ export class DirectedGraph extends AbstractGraph {
566
482
  cloned.outEdgeMap = new Map(this.outEdgeMap);
567
483
  return cloned;
568
484
  }
569
- /**
570
- * Time Complexity: O(V + E)
571
- * Space Complexity: O(V)
572
- * Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
573
- * Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs.
574
- */
575
485
  /**
576
486
  * Time Complexity: O(V + E)
577
487
  * Space Complexity: O(V)
@@ -624,10 +534,6 @@ export class DirectedGraph extends AbstractGraph {
624
534
  }
625
535
  return { dfnMap, lowMap, SCCs };
626
536
  }
627
- /**
628
- * Time Complexity: O(V + E) - Depends on the implementation (Tarjan's algorithm).
629
- * Space Complexity: O(V) - Depends on the implementation (Tarjan's algorithm).
630
- */
631
537
  /**
632
538
  * Time Complexity: O(V + E) - Depends on the implementation (Tarjan's algorithm).
633
539
  * Space Complexity: O(V) - Depends on the implementation (Tarjan's algorithm).
@@ -656,10 +562,6 @@ export class DirectedGraph extends AbstractGraph {
656
562
  getSCCs() {
657
563
  return this.tarjan().SCCs;
658
564
  }
659
- /**
660
- * Time Complexity: O(1)
661
- * Space Complexity: O(1)
662
- */
663
565
  /**
664
566
  * Time Complexity: O(1)
665
567
  * Space Complexity: O(1)
@@ -61,10 +61,6 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
61
61
  * @returns a new instance of the `UndirectedEdge` class, which is casted as type `EO`.
62
62
  */
63
63
  createEdge(v1: VertexKey, v2: VertexKey, weight?: number, value?: EO['value']): EO;
64
- /**
65
- * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
66
- * Space Complexity: O(1)
67
- */
68
64
  /**
69
65
  * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
70
66
  * Space Complexity: O(1)
@@ -77,10 +73,6 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
77
73
  * @returns an edge (EO) or undefined.
78
74
  */
79
75
  getEdge(v1: VO | VertexKey | undefined, v2: VO | VertexKey | undefined): EO | undefined;
80
- /**
81
- * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
82
- * Space Complexity: O(1)
83
- */
84
76
  /**
85
77
  * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
86
78
  * Space Complexity: O(1)
@@ -92,10 +84,6 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
92
84
  * @returns the removed edge (EO) if it exists, or undefined if either of the endpoints (VO) does not exist.
93
85
  */
94
86
  deleteEdgeBetween(v1: VO | VertexKey, v2: VO | VertexKey): EO | undefined;
95
- /**
96
- * Time Complexity: O(E), where E is the number of edgeMap incident to the given vertex.
97
- * Space Complexity: O(1)
98
- */
99
87
  /**
100
88
  * Time Complexity: O(E), where E is the number of edgeMap incident to the given vertex.
101
89
  * Space Complexity: O(1)
@@ -110,10 +98,6 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
110
98
  * @returns The `deleteEdge` function returns either the deleted edge object (EO) or `undefined`.
111
99
  */
112
100
  deleteEdge(edgeOrOneSideVertexKey: EO | VertexKey, otherSideVertexKey?: VertexKey): EO | undefined;
113
- /**
114
- * Time Complexity: O(1) - Constant time for Map operations.
115
- * Space Complexity: O(1) - Constant space, as it creates only a few variables.
116
- */
117
101
  /**
118
102
  * Time Complexity: O(1) - Constant time for Map operations.
119
103
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
@@ -124,10 +108,6 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
124
108
  * @returns The method is returning a boolean value.
125
109
  */
126
110
  deleteVertex(vertexOrKey: VO | VertexKey): boolean;
127
- /**
128
- * Time Complexity: O(1)
129
- * Space Complexity: O(1)
130
- */
131
111
  /**
132
112
  * Time Complexity: O(1)
133
113
  * Space Complexity: O(1)
@@ -139,10 +119,6 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
139
119
  * edgeMap connected to that vertex.
140
120
  */
141
121
  degreeOf(vertexOrKey: VertexKey | VO): number;
142
- /**
143
- * Time Complexity: O(1)
144
- * Space Complexity: O(1)
145
- */
146
122
  /**
147
123
  * Time Complexity: O(1)
148
124
  * Space Complexity: O(1)
@@ -153,10 +129,6 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
153
129
  * @returns an array of edgeMap.
154
130
  */
155
131
  edgesOf(vertexOrKey: VertexKey | VO): EO[];
156
- /**
157
- * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
158
- * Space Complexity: O(|E|)
159
- */
160
132
  /**
161
133
  * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
162
134
  * Space Complexity: O(|E|)
@@ -165,10 +137,6 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
165
137
  * @returns The method `edgeSet()` returns an array of type `EO[]`.
166
138
  */
167
139
  edgeSet(): EO[];
168
- /**
169
- * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
170
- * Space Complexity: O(|E|)
171
- */
172
140
  /**
173
141
  * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
174
142
  * Space Complexity: O(|E|)
@@ -179,10 +147,6 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
179
147
  * @returns an array of vertexMap (VO[]).
180
148
  */
181
149
  getNeighbors(vertexOrKey: VO | VertexKey): VO[];
182
- /**
183
- * Time Complexity: O(1)
184
- * Space Complexity: O(1)
185
- */
186
150
  /**
187
151
  * Time Complexity: O(1)
188
152
  * Space Complexity: O(1)
@@ -199,10 +163,6 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
199
163
  * @return True if the graph is empty and false otherwise
200
164
  */
201
165
  isEmpty(): boolean;
202
- /**
203
- * Time Complexity: O(1)
204
- * Space Complexity: O(1)
205
- */
206
166
  /**
207
167
  * Time Complexity: O(1)
208
168
  * Space Complexity: O(1)
@@ -220,10 +180,6 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
220
180
  * @return A new instance of the undirectedgraph class
221
181
  */
222
182
  clone(): UndirectedGraph<V, E, VO, EO>;
223
- /**
224
- * Time Complexity: O(1)
225
- * Space Complexity: O(1)
226
- */
227
183
  /**
228
184
  * Time Complexity: O(V + E)
229
185
  * Space Complexity: O(V)
@@ -240,12 +196,6 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
240
196
  bridges: EO[];
241
197
  cutVertices: VO[];
242
198
  };
243
- /**
244
- * Time Complexity: O(V + E)
245
- * Space Complexity: O(V)
246
- * Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
247
- * 1. Tarjan can find the articulation points and bridges(critical edgeMap) of undirected graphs in linear time
248
- */
249
199
  /**
250
200
  * The function "getBridges" returns an array of bridges in a graph using the Tarjan's algorithm.
251
201
  * @returns The function `getBridges()` is returning the bridges found using the Tarjan's algorithm.