data-structure-typed 1.43.1 → 1.43.3
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/.eslintrc.js +3 -1
- package/CHANGELOG.md +1 -1
- package/README.md +7 -0
- package/benchmark/report.html +30 -30
- package/benchmark/report.json +201 -147
- package/dist/cjs/src/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/src/data-structures/binary-tree/binary-tree.d.ts +8 -8
- package/dist/cjs/src/data-structures/binary-tree/binary-tree.js +62 -62
- package/dist/cjs/src/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/src/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/src/data-structures/binary-tree/rb-tree.d.ts +4 -4
- package/dist/cjs/src/data-structures/binary-tree/rb-tree.js +1 -1
- package/dist/cjs/src/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/cjs/src/data-structures/binary-tree/tree-multimap.d.ts +24 -24
- package/dist/cjs/src/data-structures/binary-tree/tree-multimap.js +50 -50
- package/dist/cjs/src/data-structures/binary-tree/tree-multimap.js.map +1 -1
- package/dist/cjs/src/data-structures/graph/abstract-graph.d.ts +37 -37
- package/dist/cjs/src/data-structures/graph/abstract-graph.js +37 -37
- package/dist/cjs/src/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/cjs/src/data-structures/graph/directed-graph.js.map +1 -1
- package/dist/cjs/src/data-structures/graph/map-graph.js.map +1 -1
- package/dist/cjs/src/data-structures/graph/undirected-graph.js.map +1 -1
- package/dist/cjs/src/data-structures/heap/heap.js.map +1 -1
- package/dist/cjs/src/interfaces/binary-tree.d.ts +1 -1
- package/dist/mjs/src/data-structures/binary-tree/binary-tree.d.ts +8 -8
- package/dist/mjs/src/data-structures/binary-tree/binary-tree.js +62 -62
- package/dist/mjs/src/data-structures/binary-tree/rb-tree.d.ts +4 -4
- package/dist/mjs/src/data-structures/binary-tree/rb-tree.js +1 -1
- package/dist/mjs/src/data-structures/binary-tree/tree-multimap.d.ts +24 -24
- package/dist/mjs/src/data-structures/binary-tree/tree-multimap.js +50 -50
- package/dist/mjs/src/data-structures/graph/abstract-graph.d.ts +37 -37
- package/dist/mjs/src/data-structures/graph/abstract-graph.js +37 -37
- package/dist/mjs/src/interfaces/binary-tree.d.ts +1 -1
- package/dist/umd/data-structure-typed.js +10497 -0
- package/dist/umd/data-structure-typed.min.js +1 -1
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +1 -1
- package/src/data-structures/binary-tree/avl-tree.ts +2 -3
- package/src/data-structures/binary-tree/binary-tree.ts +85 -92
- package/src/data-structures/binary-tree/bst.ts +14 -22
- package/src/data-structures/binary-tree/rb-tree.ts +11 -20
- package/src/data-structures/binary-tree/tree-multimap.ts +56 -58
- package/src/data-structures/graph/abstract-graph.ts +6 -22
- package/src/data-structures/graph/directed-graph.ts +3 -9
- package/src/data-structures/graph/map-graph.ts +6 -6
- package/src/data-structures/graph/undirected-graph.ts +1 -2
- package/src/data-structures/heap/heap.ts +1 -6
- package/src/data-structures/trie/trie.ts +1 -1
- package/src/interfaces/binary-tree.ts +1 -1
- package/src/types/utils/validate-type.ts +2 -16
- package/test/integration/index.html +50 -4
- package/test/performance/data-structures/binary-tree/rb-tree.test.ts +18 -19
- package/test/performance/data-structures/hash/hash-map.test.ts +10 -13
- package/test/performance/data-structures/linked-list/doubly-linked-list.test.ts +16 -16
- package/test/performance/data-structures/priority-queue/max-priority-queue.test.ts +1 -3
- package/test/performance/data-structures/priority-queue/priority-queue.test.ts +10 -12
- package/test/performance/data-structures/queue/deque.test.ts +18 -19
- package/test/performance/data-structures/queue/queue.test.ts +18 -19
- package/test/performance/data-structures/stack/stack.test.ts +10 -11
- package/test/performance/reportor.ts +4 -5
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +0 -1
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +83 -61
- package/test/unit/data-structures/binary-tree/bst.test.ts +2 -6
- package/test/unit/data-structures/binary-tree/rb-tree.test.ts +34 -25
- package/test/unit/data-structures/graph/abstract-graph.test.ts +6 -6
- package/test/unit/data-structures/graph/directed-graph.test.ts +8 -28
- package/test/unit/data-structures/heap/heap.test.ts +1 -8
- package/test/unit/data-structures/priority-queue/priority-queue.test.ts +34 -12
- package/test/utils/json2html.ts +2 -6
- package/tsup.config.js +19 -1
|
@@ -417,24 +417,24 @@ class AbstractGraph {
|
|
|
417
417
|
* Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
|
|
418
418
|
*/
|
|
419
419
|
/**
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
420
|
+
* Time Complexity: O(V^2 + E) - Quadratic time in the worst case (no heap optimization).
|
|
421
|
+
* Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
|
|
422
|
+
*
|
|
423
|
+
* The function `dijkstraWithoutHeap` implements Dijkstra's algorithm to find the shortest path between two vertices in
|
|
424
|
+
* a graph without using a heap data structure.
|
|
425
|
+
* @param {VO | VertexKey} src - The source vertex from which to start the Dijkstra's algorithm. It can be either a
|
|
426
|
+
* vertex object or a vertex ID.
|
|
427
|
+
* @param {VO | VertexKey | null} [dest] - The `dest` parameter in the `dijkstraWithoutHeap` function is an optional
|
|
428
|
+
* parameter that specifies the destination vertex for the Dijkstra algorithm. It can be either a vertex object or its
|
|
429
|
+
* identifier. If no destination is provided, the value is set to `null`.
|
|
430
|
+
* @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum
|
|
431
|
+
* distance from the source vertex to the destination vertex should be calculated and returned in the result. If
|
|
432
|
+
* `getMinDist` is set to `true`, the `minDist` property in the result will contain the minimum distance
|
|
433
|
+
* @param {boolean} [genPaths] - The `genPaths` parameter is a boolean flag that determines whether or not to generate
|
|
434
|
+
* paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
|
|
435
|
+
* shortest paths from the source vertex to all other vertices in the graph. If `genPaths
|
|
436
|
+
* @returns The function `dijkstraWithoutHeap` returns an object of type `DijkstraResult<VO>`.
|
|
437
|
+
*/
|
|
438
438
|
dijkstraWithoutHeap(src, dest, getMinDist, genPaths) {
|
|
439
439
|
if (getMinDist === undefined)
|
|
440
440
|
getMinDist = false;
|
|
@@ -551,25 +551,25 @@ class AbstractGraph {
|
|
|
551
551
|
* Space Complexity: O(V + E) - Depends on the implementation (using a binary heap).
|
|
552
552
|
*/
|
|
553
553
|
/**
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
554
|
+
* Time Complexity: O((V + E) * log(V)) - Depends on the implementation (using a binary heap).
|
|
555
|
+
* Space Complexity: O(V + E) - Depends on the implementation (using a binary heap).
|
|
556
|
+
*
|
|
557
|
+
* 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.
|
|
558
|
+
* The `dijkstra` function implements Dijkstra's algorithm to find the shortest path between a source vertex and an
|
|
559
|
+
* optional destination vertex, and optionally returns the minimum distance, the paths, and other information.
|
|
560
|
+
* @param {VO | VertexKey} src - The `src` parameter represents the source vertex from which the Dijkstra algorithm will
|
|
561
|
+
* start. It can be either a vertex object or a vertex ID.
|
|
562
|
+
* @param {VO | VertexKey | null} [dest] - The `dest` parameter is the destination vertex or vertex ID. It specifies the
|
|
563
|
+
* vertex to which the shortest path is calculated from the source vertex. If no destination is provided, the algorithm
|
|
564
|
+
* will calculate the shortest paths to all other vertices from the source vertex.
|
|
565
|
+
* @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum
|
|
566
|
+
* distance from the source vertex to the destination vertex should be calculated and returned in the result. If
|
|
567
|
+
* `getMinDist` is set to `true`, the `minDist` property in the result will contain the minimum distance
|
|
568
|
+
* @param {boolean} [genPaths] - The `genPaths` parameter is a boolean flag that determines whether or not to generate
|
|
569
|
+
* paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
|
|
570
|
+
* shortest paths from the source vertex to all other vertices in the graph. If `genPaths
|
|
571
|
+
* @returns The function `dijkstra` returns an object of type `DijkstraResult<VO>`.
|
|
572
|
+
*/
|
|
573
573
|
dijkstra(src, dest, getMinDist, genPaths) {
|
|
574
574
|
if (getMinDist === undefined)
|
|
575
575
|
getMinDist = false;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BinaryTreeNode } from '../data-structures';
|
|
2
|
-
import {
|
|
2
|
+
import { BinaryTreeNodeNested, BiTreeDeleteResult, BTNCallback, BTNKey } from '../types';
|
|
3
3
|
export interface IBinaryTree<V = any, N extends BinaryTreeNode<V, N> = BinaryTreeNodeNested<V>> {
|
|
4
4
|
createNode(key: BTNKey, value?: N['value']): N;
|
|
5
5
|
add(keyOrNode: BTNKey | N | null, value?: N['value']): N | null | undefined;
|