data-structure-typed 1.45.0 → 1.45.2
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 +6 -6
- package/CHANGELOG.md +1 -1
- package/COMMANDS.md +6 -1
- package/README.md +18 -15
- package/benchmark/report.html +18 -15
- package/benchmark/report.json +157 -116
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/map-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
- package/dist/cjs/data-structures/hash/hash-map.d.ts +58 -58
- package/dist/cjs/data-structures/hash/hash-map.js +73 -73
- package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
- package/dist/cjs/data-structures/hash/tree-map.js.map +1 -1
- package/dist/cjs/data-structures/hash/tree-set.js.map +1 -1
- package/dist/cjs/data-structures/heap/heap.js +21 -12
- package/dist/cjs/data-structures/heap/heap.js.map +1 -1
- package/dist/cjs/data-structures/heap/max-heap.js.map +1 -1
- package/dist/cjs/data-structures/heap/min-heap.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/matrix/matrix.js.map +1 -1
- package/dist/cjs/data-structures/matrix/matrix2d.js.map +1 -1
- package/dist/cjs/data-structures/matrix/navigator.js.map +1 -1
- package/dist/cjs/data-structures/matrix/vector2d.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/queue/deque.js.map +1 -1
- package/dist/cjs/data-structures/queue/queue.js.map +1 -1
- package/dist/cjs/data-structures/tree/tree.js.map +1 -1
- package/dist/cjs/data-structures/trie/trie.js.map +1 -1
- package/dist/cjs/utils/utils.js.map +1 -1
- package/dist/mjs/data-structures/hash/hash-map.d.ts +58 -58
- package/dist/mjs/data-structures/hash/hash-map.js +76 -76
- package/dist/mjs/data-structures/heap/heap.js +21 -12
- package/dist/umd/data-structure-typed.js +83 -83
- 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 +7 -7
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -3
- package/src/data-structures/binary-tree/binary-tree.ts +39 -31
- package/src/data-structures/binary-tree/bst.ts +12 -8
- package/src/data-structures/binary-tree/rb-tree.ts +17 -6
- package/src/data-structures/binary-tree/segment-tree.ts +1 -1
- package/src/data-structures/binary-tree/tree-multimap.ts +12 -9
- package/src/data-structures/graph/abstract-graph.ts +46 -31
- package/src/data-structures/graph/directed-graph.ts +10 -5
- package/src/data-structures/graph/map-graph.ts +8 -8
- package/src/data-structures/graph/undirected-graph.ts +9 -9
- package/src/data-structures/hash/hash-map.ts +103 -103
- package/src/data-structures/hash/hash-table.ts +1 -1
- package/src/data-structures/hash/tree-map.ts +2 -1
- package/src/data-structures/hash/tree-set.ts +2 -1
- package/src/data-structures/heap/heap.ts +30 -17
- package/src/data-structures/heap/max-heap.ts +3 -3
- package/src/data-structures/heap/min-heap.ts +3 -3
- package/src/data-structures/linked-list/doubly-linked-list.ts +1 -1
- package/src/data-structures/linked-list/singly-linked-list.ts +1 -1
- package/src/data-structures/matrix/matrix.ts +2 -2
- package/src/data-structures/matrix/matrix2d.ts +1 -1
- package/src/data-structures/matrix/navigator.ts +3 -3
- package/src/data-structures/matrix/vector2d.ts +2 -1
- package/src/data-structures/priority-queue/max-priority-queue.ts +3 -3
- package/src/data-structures/priority-queue/min-priority-queue.ts +3 -3
- package/src/data-structures/priority-queue/priority-queue.ts +3 -3
- package/src/data-structures/queue/deque.ts +5 -4
- package/src/data-structures/queue/queue.ts +2 -2
- package/src/data-structures/tree/tree.ts +1 -1
- package/src/data-structures/trie/trie.ts +1 -1
- package/src/interfaces/binary-tree.ts +2 -2
- package/src/interfaces/graph.ts +1 -1
- package/src/types/data-structures/binary-tree/avl-tree.ts +2 -2
- package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
- package/src/types/data-structures/binary-tree/bst.ts +2 -2
- package/src/types/data-structures/binary-tree/rb-tree.ts +2 -2
- package/src/types/data-structures/binary-tree/tree-multimap.ts +2 -2
- package/src/types/data-structures/hash/hash-map.ts +6 -6
- package/src/types/data-structures/matrix/navigator.ts +1 -1
- package/src/types/utils/utils.ts +1 -1
- package/src/types/utils/validate-type.ts +18 -4
- package/src/utils/utils.ts +6 -6
- package/test/integration/all-in-one.ts +1 -1
- package/test/integration/avl-tree.test.ts +1 -1
- package/test/integration/bst.test.ts +19 -19
- package/test/integration/heap.test.js +1 -1
- package/test/integration/index.html +7 -7
- package/test/performance/data-structures/binary-tree/avl-tree.test.ts +4 -4
- package/test/performance/data-structures/binary-tree/binary-tree.test.ts +4 -4
- package/test/performance/data-structures/binary-tree/bst.test.ts +4 -4
- package/test/performance/data-structures/binary-tree/rb-tree.test.ts +9 -9
- package/test/performance/data-structures/comparation.test.ts +142 -0
- package/test/performance/data-structures/graph/directed-graph.test.ts +4 -4
- package/test/performance/data-structures/hash/hash-map.test.ts +8 -8
- package/test/performance/data-structures/heap/heap.test.ts +5 -5
- package/test/performance/data-structures/linked-list/doubly-linked-list.test.ts +7 -7
- package/test/performance/data-structures/linked-list/singly-linked-list.test.ts +4 -4
- package/test/performance/data-structures/priority-queue/max-priority-queue.test.ts +7 -5
- package/test/performance/data-structures/priority-queue/priority-queue.test.ts +8 -8
- package/test/performance/data-structures/queue/deque.test.ts +6 -6
- package/test/performance/data-structures/queue/queue.test.ts +7 -7
- package/test/performance/data-structures/stack/stack.test.ts +8 -8
- package/test/performance/data-structures/trie/trie.test.ts +4 -4
- package/test/performance/reportor.ts +48 -20
- package/test/performance/types/reportor.ts +1 -1
- package/test/types/utils/json2html.ts +1 -1
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +6 -6
- package/test/unit/data-structures/binary-tree/binary-index-tree.test.ts +12 -12
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +46 -76
- package/test/unit/data-structures/binary-tree/bst.test.ts +44 -40
- package/test/unit/data-structures/binary-tree/overall.test.ts +17 -17
- package/test/unit/data-structures/binary-tree/rb-tree.test.ts +9 -9
- package/test/unit/data-structures/binary-tree/segment-tree.test.ts +1 -1
- package/test/unit/data-structures/binary-tree/tree-multimap.test.ts +35 -35
- package/test/unit/data-structures/graph/abstract-graph.test.ts +7 -7
- package/test/unit/data-structures/graph/directed-graph.test.ts +34 -14
- package/test/unit/data-structures/graph/map-graph.test.ts +1 -1
- package/test/unit/data-structures/graph/overall.test.ts +1 -1
- package/test/unit/data-structures/graph/undirected-graph.test.ts +1 -1
- package/test/unit/data-structures/hash/coordinate-map.test.ts +1 -1
- package/test/unit/data-structures/hash/coordinate-set.test.ts +1 -1
- package/test/unit/data-structures/hash/hash-map.test.ts +10 -12
- package/test/unit/data-structures/hash/hash-table.test.ts +1 -1
- package/test/unit/data-structures/heap/heap.test.ts +73 -23
- package/test/unit/data-structures/heap/max-heap.test.ts +2 -2
- package/test/unit/data-structures/heap/min-heap.test.ts +2 -2
- package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +5 -5
- package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +5 -5
- package/test/unit/data-structures/linked-list/skip-list.test.ts +1 -1
- package/test/unit/data-structures/matrix/matrix.test.ts +5 -5
- package/test/unit/data-structures/matrix/matrix2d.test.ts +3 -3
- package/test/unit/data-structures/matrix/navigator.test.ts +2 -2
- package/test/unit/data-structures/matrix/vector2d.test.ts +1 -1
- package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +7 -7
- package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +1 -1
- package/test/unit/data-structures/priority-queue/priority-queue.test.ts +19 -19
- package/test/unit/data-structures/queue/deque.test.ts +3 -3
- package/test/unit/data-structures/queue/queue.test.ts +3 -3
- package/test/unit/data-structures/stack/stack.test.ts +1 -1
- package/test/unit/data-structures/tree/tree.test.ts +1 -1
- package/test/unit/data-structures/trie/trie.test.ts +1 -1
- package/test/utils/array.ts +1 -1
- package/test/utils/big-o.ts +4 -4
- package/test/utils/index.ts +1 -0
- package/test/utils/json2html.ts +7 -3
- package/test/utils/performanc.ts +7 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {BinaryTree, BinaryTreeNode, IterationType} from '../../../../src';
|
|
2
|
-
import {getRandomIntArray} from '../../../utils';
|
|
3
|
-
import {FamilyPosition} from 'binary-tree-typed';
|
|
1
|
+
import { BinaryTree, BinaryTreeNode, IterationType } from '../../../../src';
|
|
2
|
+
import { getRandomIntArray } from '../../../utils';
|
|
3
|
+
import { FamilyPosition } from 'binary-tree-typed';
|
|
4
4
|
// import {isDebugTest} from '../../../config';
|
|
5
5
|
|
|
6
6
|
// const isDebug = isDebugTest;
|
|
@@ -242,8 +242,12 @@ describe('BinaryTree', () => {
|
|
|
242
242
|
tree.addMany([4, 2, 6, null, 1, 3, null, 5, null, 7]);
|
|
243
243
|
expect(tree.subTreeTraverse(node => node.key, tree.getNode(6), IterationType.ITERATIVE)).toEqual([6, 3, 7]);
|
|
244
244
|
expect(tree.subTreeTraverse(node => node.key, tree.getNode(6), IterationType.RECURSIVE)).toEqual([6, 3, 7]);
|
|
245
|
-
expect(
|
|
246
|
-
|
|
245
|
+
expect(
|
|
246
|
+
tree.subTreeTraverse(node => (node ? node.key : null), tree.getNode(6), IterationType.ITERATIVE, true)
|
|
247
|
+
).toEqual([6, 3, 7, null]);
|
|
248
|
+
expect(
|
|
249
|
+
tree.subTreeTraverse(node => (node ? node.key : null), tree.getNode(6), IterationType.RECURSIVE, true)
|
|
250
|
+
).toEqual([6, 3, 7, null]);
|
|
247
251
|
});
|
|
248
252
|
|
|
249
253
|
it('should clear the tree', () => {
|
|
@@ -315,81 +319,41 @@ describe('BinaryTree traversals', () => {
|
|
|
315
319
|
|
|
316
320
|
const arr = [35, 20, 40, 15, 29, null, 50, null, 16, 28, 30, 45, 55];
|
|
317
321
|
tree.refill(arr);
|
|
318
|
-
expect(
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
45,
|
|
331
|
-
55
|
|
332
|
-
]);
|
|
333
|
-
expect(tree.bfs(node => node, tree.root, IterationType.RECURSIVE, true).map(node => (node ? node.key : null))).toEqual([
|
|
334
|
-
35,
|
|
335
|
-
20,
|
|
336
|
-
40,
|
|
337
|
-
15,
|
|
338
|
-
29,
|
|
339
|
-
null,
|
|
340
|
-
50,
|
|
341
|
-
null,
|
|
342
|
-
16,
|
|
343
|
-
28,
|
|
344
|
-
30,
|
|
345
|
-
45,
|
|
346
|
-
55
|
|
347
|
-
]);
|
|
348
|
-
expect(tree.bfs(node => node, tree.root, IterationType.ITERATIVE).map(node => (node === null ? null : node.key))).toEqual([
|
|
349
|
-
35, 20, 40, 15, 29, 50, 16, 28, 30, 45, 55
|
|
350
|
-
]);
|
|
351
|
-
expect(tree.bfs(node => node, tree.root, IterationType.RECURSIVE).map(node => (node === null ? null : node.key))).toEqual([
|
|
352
|
-
35, 20, 40, 15, 29, 50, 16, 28, 30, 45, 55
|
|
353
|
-
]);
|
|
322
|
+
expect(
|
|
323
|
+
tree.bfs(node => node, tree.root, IterationType.ITERATIVE, true).map(node => (node ? node.key : null))
|
|
324
|
+
).toEqual([35, 20, 40, 15, 29, null, 50, null, 16, 28, 30, 45, 55]);
|
|
325
|
+
expect(
|
|
326
|
+
tree.bfs(node => node, tree.root, IterationType.RECURSIVE, true).map(node => (node ? node.key : null))
|
|
327
|
+
).toEqual([35, 20, 40, 15, 29, null, 50, null, 16, 28, 30, 45, 55]);
|
|
328
|
+
expect(
|
|
329
|
+
tree.bfs(node => node, tree.root, IterationType.ITERATIVE).map(node => (node === null ? null : node.key))
|
|
330
|
+
).toEqual([35, 20, 40, 15, 29, 50, 16, 28, 30, 45, 55]);
|
|
331
|
+
expect(
|
|
332
|
+
tree.bfs(node => node, tree.root, IterationType.RECURSIVE).map(node => (node === null ? null : node.key))
|
|
333
|
+
).toEqual([35, 20, 40, 15, 29, 50, 16, 28, 30, 45, 55]);
|
|
354
334
|
|
|
355
335
|
expect(tree.dfs(node => node.key, 'pre')).toEqual([35, 20, 15, 16, 29, 28, 30, 40, 50, 45, 55]);
|
|
356
|
-
expect(tree.dfs(node => node.key, 'pre', tree.root, IterationType.RECURSIVE)).toEqual([
|
|
357
|
-
|
|
358
|
-
35,
|
|
359
|
-
20,
|
|
360
|
-
15,
|
|
361
|
-
null,
|
|
362
|
-
16,
|
|
363
|
-
29,
|
|
364
|
-
28,
|
|
365
|
-
30,
|
|
366
|
-
40,
|
|
367
|
-
null,
|
|
368
|
-
50,
|
|
369
|
-
45,
|
|
370
|
-
55
|
|
371
|
-
]);
|
|
372
|
-
expect(tree.dfs(node => node, 'pre', tree.root, IterationType.RECURSIVE, true).map(node => (node ? node.key : null))).toEqual([
|
|
373
|
-
35,
|
|
374
|
-
20,
|
|
375
|
-
15,
|
|
376
|
-
null,
|
|
377
|
-
16,
|
|
378
|
-
29,
|
|
379
|
-
28,
|
|
380
|
-
30,
|
|
381
|
-
40,
|
|
382
|
-
null,
|
|
383
|
-
50,
|
|
384
|
-
45,
|
|
385
|
-
55
|
|
336
|
+
expect(tree.dfs(node => node.key, 'pre', tree.root, IterationType.RECURSIVE)).toEqual([
|
|
337
|
+
35, 20, 15, 16, 29, 28, 30, 40, 50, 45, 55
|
|
386
338
|
]);
|
|
339
|
+
expect(
|
|
340
|
+
tree.dfs(node => node, 'pre', tree.root, IterationType.ITERATIVE, true).map(node => (node ? node.key : null))
|
|
341
|
+
).toEqual([35, 20, 15, null, 16, 29, 28, 30, 40, null, 50, 45, 55]);
|
|
342
|
+
expect(
|
|
343
|
+
tree.dfs(node => node, 'pre', tree.root, IterationType.RECURSIVE, true).map(node => (node ? node.key : null))
|
|
344
|
+
).toEqual([35, 20, 15, null, 16, 29, 28, 30, 40, null, 50, 45, 55]);
|
|
387
345
|
|
|
388
346
|
expect(tree.dfs(node => node.key, 'in')).toEqual([15, 16, 20, 28, 29, 30, 35, 40, 45, 50, 55]);
|
|
389
347
|
expect(tree.dfs(node => node.key, 'post')).toEqual([16, 15, 28, 30, 29, 20, 45, 55, 50, 40, 35]);
|
|
390
|
-
expect(tree.dfs(node => node.key, 'post', tree.root, IterationType.RECURSIVE)).toEqual([
|
|
391
|
-
|
|
392
|
-
|
|
348
|
+
expect(tree.dfs(node => node.key, 'post', tree.root, IterationType.RECURSIVE)).toEqual([
|
|
349
|
+
16, 15, 28, 30, 29, 20, 45, 55, 50, 40, 35
|
|
350
|
+
]);
|
|
351
|
+
expect(tree.bfs(node => node.key, tree.root, IterationType.RECURSIVE)).toEqual([
|
|
352
|
+
35, 20, 40, 15, 29, 50, 16, 28, 30, 45, 55
|
|
353
|
+
]);
|
|
354
|
+
expect(tree.bfs(node => node.key, tree.root, IterationType.ITERATIVE)).toEqual([
|
|
355
|
+
35, 20, 40, 15, 29, 50, 16, 28, 30, 45, 55
|
|
356
|
+
]);
|
|
393
357
|
|
|
394
358
|
expect(tree.listLevels(node => node.key)).toEqual([[35], [20, 40], [15, 29, 50], [16, 28, 30, 45, 55]]);
|
|
395
359
|
|
|
@@ -417,7 +381,7 @@ describe('BinaryTree', () => {
|
|
|
417
381
|
let tree: BinaryTree<string>;
|
|
418
382
|
|
|
419
383
|
beforeEach(() => {
|
|
420
|
-
tree = new BinaryTree<string>({iterationType: IterationType.RECURSIVE});
|
|
384
|
+
tree = new BinaryTree<string>({ iterationType: IterationType.RECURSIVE });
|
|
421
385
|
});
|
|
422
386
|
|
|
423
387
|
afterEach(() => {
|
|
@@ -560,7 +524,13 @@ describe('BinaryTree', () => {
|
|
|
560
524
|
expect(nodes.length).toBe(1);
|
|
561
525
|
expect(nodes[0].key).toBe(3);
|
|
562
526
|
|
|
563
|
-
const nodesRec = tree.getNodes(
|
|
527
|
+
const nodesRec = tree.getNodes(
|
|
528
|
+
'B',
|
|
529
|
+
(node: BinaryTreeNode<string>) => node.value,
|
|
530
|
+
false,
|
|
531
|
+
tree.root,
|
|
532
|
+
IterationType.RECURSIVE
|
|
533
|
+
);
|
|
564
534
|
|
|
565
535
|
expect(nodesRec.length).toBe(1);
|
|
566
536
|
expect(nodesRec[0].key).toBe(3);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {BST, BSTNode, CP, IterationType} from '../../../../src';
|
|
2
|
-
import {isDebugTest} from '../../../config';
|
|
1
|
+
import { BST, BSTNode, CP, IterationType } from '../../../../src';
|
|
2
|
+
import { isDebugTest } from '../../../config';
|
|
3
3
|
|
|
4
4
|
const isDebug = isDebugTest;
|
|
5
5
|
|
|
@@ -191,23 +191,23 @@ describe('BST operations test', () => {
|
|
|
191
191
|
it('should perform various operations on a Binary Search Tree with object values', () => {
|
|
192
192
|
const objBST = new BST<{ key: number; keyA: number }>();
|
|
193
193
|
expect(objBST).toBeInstanceOf(BST);
|
|
194
|
-
objBST.add(11, {key: 11, keyA: 11});
|
|
195
|
-
objBST.add(3, {key: 3, keyA: 3});
|
|
194
|
+
objBST.add(11, { key: 11, keyA: 11 });
|
|
195
|
+
objBST.add(3, { key: 3, keyA: 3 });
|
|
196
196
|
const values = [
|
|
197
|
-
{key: 15, keyA: 15},
|
|
198
|
-
{key: 1, keyA: 1},
|
|
199
|
-
{key: 8, keyA: 8},
|
|
200
|
-
{key: 13, keyA: 13},
|
|
201
|
-
{key: 16, keyA: 16},
|
|
202
|
-
{key: 2, keyA: 2},
|
|
203
|
-
{key: 6, keyA: 6},
|
|
204
|
-
{key: 9, keyA: 9},
|
|
205
|
-
{key: 12, keyA: 12},
|
|
206
|
-
{key: 14, keyA: 14},
|
|
207
|
-
{key: 4, keyA: 4},
|
|
208
|
-
{key: 7, keyA: 7},
|
|
209
|
-
{key: 10, keyA: 10},
|
|
210
|
-
{key: 5, keyA: 5}
|
|
197
|
+
{ key: 15, keyA: 15 },
|
|
198
|
+
{ key: 1, keyA: 1 },
|
|
199
|
+
{ key: 8, keyA: 8 },
|
|
200
|
+
{ key: 13, keyA: 13 },
|
|
201
|
+
{ key: 16, keyA: 16 },
|
|
202
|
+
{ key: 2, keyA: 2 },
|
|
203
|
+
{ key: 6, keyA: 6 },
|
|
204
|
+
{ key: 9, keyA: 9 },
|
|
205
|
+
{ key: 12, keyA: 12 },
|
|
206
|
+
{ key: 14, keyA: 14 },
|
|
207
|
+
{ key: 4, keyA: 4 },
|
|
208
|
+
{ key: 7, keyA: 7 },
|
|
209
|
+
{ key: 10, keyA: 10 },
|
|
210
|
+
{ key: 5, keyA: 5 }
|
|
211
211
|
];
|
|
212
212
|
|
|
213
213
|
objBST.addMany(
|
|
@@ -236,7 +236,7 @@ describe('BST operations test', () => {
|
|
|
236
236
|
expect(leftMost?.key).toBe(1);
|
|
237
237
|
|
|
238
238
|
const node15 = objBST.getNode(15);
|
|
239
|
-
expect(node15?.value).toEqual({key: 15, keyA: 15});
|
|
239
|
+
expect(node15?.value).toEqual({ key: 15, keyA: 15 });
|
|
240
240
|
const minNodeBySpecificNode = node15 && objBST.getLeftMost(node15);
|
|
241
241
|
expect(minNodeBySpecificNode?.key).toBe(12);
|
|
242
242
|
|
|
@@ -395,7 +395,7 @@ describe('BST operations test', () => {
|
|
|
395
395
|
|
|
396
396
|
describe('BST operations test recursively', () => {
|
|
397
397
|
it('should perform various operations on a Binary Search Tree with numeric values', () => {
|
|
398
|
-
const bst = new BST({iterationType: IterationType.RECURSIVE});
|
|
398
|
+
const bst = new BST({ iterationType: IterationType.RECURSIVE });
|
|
399
399
|
expect(bst).toBeInstanceOf(BST);
|
|
400
400
|
bst.add(11, 11);
|
|
401
401
|
bst.add(3, 3);
|
|
@@ -582,23 +582,23 @@ describe('BST operations test recursively', () => {
|
|
|
582
582
|
it('should perform various operations on a Binary Search Tree with object values', () => {
|
|
583
583
|
const objBST = new BST<{ key: number; keyA: number }>();
|
|
584
584
|
expect(objBST).toBeInstanceOf(BST);
|
|
585
|
-
objBST.add(11, {key: 11, keyA: 11});
|
|
586
|
-
objBST.add(3, {key: 3, keyA: 3});
|
|
585
|
+
objBST.add(11, { key: 11, keyA: 11 });
|
|
586
|
+
objBST.add(3, { key: 3, keyA: 3 });
|
|
587
587
|
const values = [
|
|
588
|
-
{key: 15, keyA: 15},
|
|
589
|
-
{key: 1, keyA: 1},
|
|
590
|
-
{key: 8, keyA: 8},
|
|
591
|
-
{key: 13, keyA: 13},
|
|
592
|
-
{key: 16, keyA: 16},
|
|
593
|
-
{key: 2, keyA: 2},
|
|
594
|
-
{key: 6, keyA: 6},
|
|
595
|
-
{key: 9, keyA: 9},
|
|
596
|
-
{key: 12, keyA: 12},
|
|
597
|
-
{key: 14, keyA: 14},
|
|
598
|
-
{key: 4, keyA: 4},
|
|
599
|
-
{key: 7, keyA: 7},
|
|
600
|
-
{key: 10, keyA: 10},
|
|
601
|
-
{key: 5, keyA: 5}
|
|
588
|
+
{ key: 15, keyA: 15 },
|
|
589
|
+
{ key: 1, keyA: 1 },
|
|
590
|
+
{ key: 8, keyA: 8 },
|
|
591
|
+
{ key: 13, keyA: 13 },
|
|
592
|
+
{ key: 16, keyA: 16 },
|
|
593
|
+
{ key: 2, keyA: 2 },
|
|
594
|
+
{ key: 6, keyA: 6 },
|
|
595
|
+
{ key: 9, keyA: 9 },
|
|
596
|
+
{ key: 12, keyA: 12 },
|
|
597
|
+
{ key: 14, keyA: 14 },
|
|
598
|
+
{ key: 4, keyA: 4 },
|
|
599
|
+
{ key: 7, keyA: 7 },
|
|
600
|
+
{ key: 10, keyA: 10 },
|
|
601
|
+
{ key: 5, keyA: 5 }
|
|
602
602
|
];
|
|
603
603
|
|
|
604
604
|
objBST.addMany(
|
|
@@ -614,7 +614,7 @@ describe('BST operations test recursively', () => {
|
|
|
614
614
|
expect(objBST.has(6)).toBe(true);
|
|
615
615
|
|
|
616
616
|
const node6 = objBST.getNode(6);
|
|
617
|
-
expect(objBST.get(6)).toEqual({key: 6, keyA: 6});
|
|
617
|
+
expect(objBST.get(6)).toEqual({ key: 6, keyA: 6 });
|
|
618
618
|
expect(node6 && objBST.getHeight(node6)).toBe(2);
|
|
619
619
|
expect(node6 && objBST.getDepth(node6)).toBe(3);
|
|
620
620
|
|
|
@@ -628,7 +628,7 @@ describe('BST operations test recursively', () => {
|
|
|
628
628
|
expect(leftMost?.key).toBe(1);
|
|
629
629
|
|
|
630
630
|
const node15 = objBST.getNode(15);
|
|
631
|
-
expect(node15?.value).toEqual({key: 15, keyA: 15});
|
|
631
|
+
expect(node15?.value).toEqual({ key: 15, keyA: 15 });
|
|
632
632
|
const minNodeBySpecificNode = node15 && objBST.getLeftMost(node15);
|
|
633
633
|
expect(minNodeBySpecificNode?.key).toBe(12);
|
|
634
634
|
|
|
@@ -843,7 +843,11 @@ describe('BST Performance test', function () {
|
|
|
843
843
|
bst.addMany([4, 2, 6, 1, 3, 5, 7]);
|
|
844
844
|
expect(bst.subTreeTraverse(node => node.key, bst.getNode(6), IterationType.ITERATIVE)).toEqual([6, 5, 7]);
|
|
845
845
|
expect(bst.subTreeTraverse(node => node.key, bst.getNode(6), IterationType.RECURSIVE)).toEqual([6, 5, 7]);
|
|
846
|
-
expect(bst.subTreeTraverse(node => node?.key ?? undefined, bst.getNode(6), IterationType.ITERATIVE, true)).toEqual([
|
|
847
|
-
|
|
846
|
+
expect(bst.subTreeTraverse(node => node?.key ?? undefined, bst.getNode(6), IterationType.ITERATIVE, true)).toEqual([
|
|
847
|
+
6, 5, 7
|
|
848
|
+
]);
|
|
849
|
+
expect(bst.subTreeTraverse(node => node?.key ?? undefined, bst.getNode(6), IterationType.RECURSIVE, true)).toEqual([
|
|
850
|
+
6, 5, 7
|
|
851
|
+
]);
|
|
848
852
|
});
|
|
849
853
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {AVLTree, BST} from '../../../../src';
|
|
1
|
+
import { AVLTree, BST } from '../../../../src';
|
|
2
2
|
|
|
3
3
|
describe('Overall BinaryTree Test', () => {
|
|
4
4
|
it('should perform various operations on BinaryTree', () => {
|
|
@@ -30,26 +30,26 @@ describe('Overall BinaryTree Test', () => {
|
|
|
30
30
|
expect(bfsIDs[0]).toBe(11);
|
|
31
31
|
|
|
32
32
|
const objBST = new BST<{ key: number; keyA: number }>();
|
|
33
|
-
objBST.add(11, {key: 11, keyA: 11});
|
|
34
|
-
objBST.add(3, {key: 3, keyA: 3});
|
|
33
|
+
objBST.add(11, { key: 11, keyA: 11 });
|
|
34
|
+
objBST.add(3, { key: 3, keyA: 3 });
|
|
35
35
|
|
|
36
36
|
objBST.addMany(
|
|
37
37
|
[15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5],
|
|
38
38
|
[
|
|
39
|
-
{key: 15, keyA: 15},
|
|
40
|
-
{key: 1, keyA: 1},
|
|
41
|
-
{key: 8, keyA: 8},
|
|
42
|
-
{key: 13, keyA: 13},
|
|
43
|
-
{key: 16, keyA: 16},
|
|
44
|
-
{key: 2, keyA: 2},
|
|
45
|
-
{key: 6, keyA: 6},
|
|
46
|
-
{key: 9, keyA: 9},
|
|
47
|
-
{key: 12, keyA: 12},
|
|
48
|
-
{key: 14, keyA: 14},
|
|
49
|
-
{key: 4, keyA: 4},
|
|
50
|
-
{key: 7, keyA: 7},
|
|
51
|
-
{key: 10, keyA: 10},
|
|
52
|
-
{key: 5, keyA: 5}
|
|
39
|
+
{ key: 15, keyA: 15 },
|
|
40
|
+
{ key: 1, keyA: 1 },
|
|
41
|
+
{ key: 8, keyA: 8 },
|
|
42
|
+
{ key: 13, keyA: 13 },
|
|
43
|
+
{ key: 16, keyA: 16 },
|
|
44
|
+
{ key: 2, keyA: 2 },
|
|
45
|
+
{ key: 6, keyA: 6 },
|
|
46
|
+
{ key: 9, keyA: 9 },
|
|
47
|
+
{ key: 12, keyA: 12 },
|
|
48
|
+
{ key: 14, keyA: 14 },
|
|
49
|
+
{ key: 4, keyA: 4 },
|
|
50
|
+
{ key: 7, keyA: 7 },
|
|
51
|
+
{ key: 10, keyA: 10 },
|
|
52
|
+
{ key: 5, keyA: 5 }
|
|
53
53
|
]
|
|
54
54
|
);
|
|
55
55
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {IterationType, RBTNColor, RedBlackTree, RedBlackTreeNode} from '../../../../src';
|
|
2
|
-
import {getRandomInt, getRandomIntArray, magnitude} from '../../../utils';
|
|
3
|
-
import {isDebugTest} from '../../../config';
|
|
4
|
-
import {OrderedMap} from 'js-sdsl';
|
|
1
|
+
import { IterationType, RBTNColor, RedBlackTree, RedBlackTreeNode } from '../../../../src';
|
|
2
|
+
import { getRandomInt, getRandomIntArray, magnitude } from '../../../utils';
|
|
3
|
+
import { isDebugTest } from '../../../config';
|
|
4
|
+
import { OrderedMap } from 'js-sdsl';
|
|
5
5
|
|
|
6
6
|
const isDebug = isDebugTest;
|
|
7
7
|
|
|
@@ -438,12 +438,12 @@ describe('RedBlackTree', () => {
|
|
|
438
438
|
expect(tree.size).toBe(51);
|
|
439
439
|
expect(tree.isBST()).toBe(true);
|
|
440
440
|
expect(tree.dfs(n => n.key, 'in', tree.root, IterationType.ITERATIVE)).toEqual([
|
|
441
|
-
49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
|
|
442
|
-
82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
|
|
441
|
+
49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
|
|
442
|
+
77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
|
|
443
443
|
]);
|
|
444
444
|
expect(tree.dfs(n => n.key, 'in', tree.root, IterationType.RECURSIVE)).toEqual([
|
|
445
|
-
49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
|
|
446
|
-
82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
|
|
445
|
+
49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
|
|
446
|
+
77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
|
|
447
447
|
]);
|
|
448
448
|
});
|
|
449
449
|
|
|
@@ -468,7 +468,7 @@ describe('RedBlackTree', () => {
|
|
|
468
468
|
// TODO there is a bug when dfs the tree with NIL node
|
|
469
469
|
// expect(tree.isBST()).toBe(true);
|
|
470
470
|
});
|
|
471
|
-
const {HUNDRED_THOUSAND} = magnitude;
|
|
471
|
+
const { HUNDRED_THOUSAND } = magnitude;
|
|
472
472
|
const arr = getRandomIntArray(HUNDRED_THOUSAND, 0, HUNDRED_THOUSAND, true);
|
|
473
473
|
const competitor = new OrderedMap<number, number>();
|
|
474
474
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {CP, IterationType, TreeMultimap, TreeMultimapNode} from '../../../../src';
|
|
2
|
-
import {isDebugTest} from '../../../config';
|
|
1
|
+
import { CP, IterationType, TreeMultimap, TreeMultimapNode } from '../../../../src';
|
|
2
|
+
import { isDebugTest } from '../../../config';
|
|
3
3
|
|
|
4
4
|
const isDebug = isDebugTest;
|
|
5
5
|
|
|
@@ -209,23 +209,23 @@ describe('TreeMultimap operations test', () => {
|
|
|
209
209
|
it('should perform various operations on a Binary Search Tree with object values', () => {
|
|
210
210
|
const objTreeMultimap = new TreeMultimap<{ key: number; keyA: number }>();
|
|
211
211
|
expect(objTreeMultimap).toBeInstanceOf(TreeMultimap);
|
|
212
|
-
objTreeMultimap.add(11, {key: 11, keyA: 11});
|
|
213
|
-
objTreeMultimap.add(3, {key: 3, keyA: 3});
|
|
212
|
+
objTreeMultimap.add(11, { key: 11, keyA: 11 });
|
|
213
|
+
objTreeMultimap.add(3, { key: 3, keyA: 3 });
|
|
214
214
|
const values = [
|
|
215
|
-
{key: 15, keyA: 15},
|
|
216
|
-
{key: 1, keyA: 1},
|
|
217
|
-
{key: 8, keyA: 8},
|
|
218
|
-
{key: 13, keyA: 13},
|
|
219
|
-
{key: 16, keyA: 16},
|
|
220
|
-
{key: 2, keyA: 2},
|
|
221
|
-
{key: 6, keyA: 6},
|
|
222
|
-
{key: 9, keyA: 9},
|
|
223
|
-
{key: 12, keyA: 12},
|
|
224
|
-
{key: 14, keyA: 14},
|
|
225
|
-
{key: 4, keyA: 4},
|
|
226
|
-
{key: 7, keyA: 7},
|
|
227
|
-
{key: 10, keyA: 10},
|
|
228
|
-
{key: 5, keyA: 5}
|
|
215
|
+
{ key: 15, keyA: 15 },
|
|
216
|
+
{ key: 1, keyA: 1 },
|
|
217
|
+
{ key: 8, keyA: 8 },
|
|
218
|
+
{ key: 13, keyA: 13 },
|
|
219
|
+
{ key: 16, keyA: 16 },
|
|
220
|
+
{ key: 2, keyA: 2 },
|
|
221
|
+
{ key: 6, keyA: 6 },
|
|
222
|
+
{ key: 9, keyA: 9 },
|
|
223
|
+
{ key: 12, keyA: 12 },
|
|
224
|
+
{ key: 14, keyA: 14 },
|
|
225
|
+
{ key: 4, keyA: 4 },
|
|
226
|
+
{ key: 7, keyA: 7 },
|
|
227
|
+
{ key: 10, keyA: 10 },
|
|
228
|
+
{ key: 5, keyA: 5 }
|
|
229
229
|
];
|
|
230
230
|
|
|
231
231
|
objTreeMultimap.addMany(
|
|
@@ -245,7 +245,7 @@ describe('TreeMultimap operations test', () => {
|
|
|
245
245
|
|
|
246
246
|
describe('TreeMultimap operations test recursively', () => {
|
|
247
247
|
it('should perform various operations on a Binary Search Tree with numeric values', () => {
|
|
248
|
-
const treeMultimap = new TreeMultimap({iterationType: IterationType.RECURSIVE});
|
|
248
|
+
const treeMultimap = new TreeMultimap({ iterationType: IterationType.RECURSIVE });
|
|
249
249
|
|
|
250
250
|
expect(treeMultimap instanceof TreeMultimap);
|
|
251
251
|
treeMultimap.add(11, 11);
|
|
@@ -449,23 +449,23 @@ describe('TreeMultimap operations test recursively', () => {
|
|
|
449
449
|
it('should perform various operations on a Binary Search Tree with object values', () => {
|
|
450
450
|
const objTreeMultimap = new TreeMultimap<{ key: number; keyA: number }>();
|
|
451
451
|
expect(objTreeMultimap).toBeInstanceOf(TreeMultimap);
|
|
452
|
-
objTreeMultimap.add(11, {key: 11, keyA: 11});
|
|
453
|
-
objTreeMultimap.add(3, {key: 3, keyA: 3});
|
|
452
|
+
objTreeMultimap.add(11, { key: 11, keyA: 11 });
|
|
453
|
+
objTreeMultimap.add(3, { key: 3, keyA: 3 });
|
|
454
454
|
const values = [
|
|
455
|
-
{key: 15, keyA: 15},
|
|
456
|
-
{key: 1, keyA: 1},
|
|
457
|
-
{key: 8, keyA: 8},
|
|
458
|
-
{key: 13, keyA: 13},
|
|
459
|
-
{key: 16, keyA: 16},
|
|
460
|
-
{key: 2, keyA: 2},
|
|
461
|
-
{key: 6, keyA: 6},
|
|
462
|
-
{key: 9, keyA: 9},
|
|
463
|
-
{key: 12, keyA: 12},
|
|
464
|
-
{key: 14, keyA: 14},
|
|
465
|
-
{key: 4, keyA: 4},
|
|
466
|
-
{key: 7, keyA: 7},
|
|
467
|
-
{key: 10, keyA: 10},
|
|
468
|
-
{key: 5, keyA: 5}
|
|
455
|
+
{ key: 15, keyA: 15 },
|
|
456
|
+
{ key: 1, keyA: 1 },
|
|
457
|
+
{ key: 8, keyA: 8 },
|
|
458
|
+
{ key: 13, keyA: 13 },
|
|
459
|
+
{ key: 16, keyA: 16 },
|
|
460
|
+
{ key: 2, keyA: 2 },
|
|
461
|
+
{ key: 6, keyA: 6 },
|
|
462
|
+
{ key: 9, keyA: 9 },
|
|
463
|
+
{ key: 12, keyA: 12 },
|
|
464
|
+
{ key: 14, keyA: 14 },
|
|
465
|
+
{ key: 4, keyA: 4 },
|
|
466
|
+
{ key: 7, keyA: 7 },
|
|
467
|
+
{ key: 10, keyA: 10 },
|
|
468
|
+
{ key: 5, keyA: 5 }
|
|
469
469
|
];
|
|
470
470
|
|
|
471
471
|
objTreeMultimap.addMany(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {AbstractEdge, AbstractGraph, AbstractVertex, VertexKey} from '../../../../src';
|
|
1
|
+
import { AbstractEdge, AbstractGraph, AbstractVertex, VertexKey } from '../../../../src';
|
|
2
2
|
|
|
3
3
|
class MyVertex<V = any> extends AbstractVertex<V> {
|
|
4
4
|
data?: V;
|
|
@@ -22,12 +22,12 @@ class MyEdge<E = any> extends AbstractEdge<E> {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
class MyGraph<
|
|
26
|
-
V,
|
|
27
|
-
E,
|
|
28
|
-
VO
|
|
29
|
-
EO
|
|
30
|
-
> {
|
|
25
|
+
class MyGraph<
|
|
26
|
+
V = any,
|
|
27
|
+
E = any,
|
|
28
|
+
VO extends MyVertex<V> = MyVertex<V>,
|
|
29
|
+
EO extends MyEdge<E> = MyEdge<E>
|
|
30
|
+
> extends AbstractGraph<V, E, VO, EO> {
|
|
31
31
|
createVertex(key: VertexKey, value?: V): VO {
|
|
32
32
|
return new MyVertex(key, value) as VO;
|
|
33
33
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {DirectedEdge, DirectedGraph, DirectedVertex, VertexKey} from '../../../../src';
|
|
1
|
+
import { DirectedEdge, DirectedGraph, DirectedVertex, VertexKey } from '../../../../src';
|
|
2
2
|
|
|
3
3
|
describe('DirectedGraph Operation Test', () => {
|
|
4
4
|
let graph: DirectedGraph;
|
|
@@ -126,12 +126,12 @@ class MyEdge<E = any> extends DirectedEdge<E> {
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
class MyDirectedGraph<
|
|
130
|
-
V,
|
|
131
|
-
E,
|
|
132
|
-
VO
|
|
133
|
-
EO
|
|
134
|
-
> {
|
|
129
|
+
class MyDirectedGraph<
|
|
130
|
+
V = any,
|
|
131
|
+
E = any,
|
|
132
|
+
VO extends MyVertex<V> = MyVertex<V>,
|
|
133
|
+
EO extends MyEdge<E> = MyEdge<E>
|
|
134
|
+
> extends DirectedGraph<V, E, VO, EO> {
|
|
135
135
|
createVertex(key: VertexKey, value: V): VO {
|
|
136
136
|
return new MyVertex(key, value) as VO;
|
|
137
137
|
}
|
|
@@ -319,7 +319,7 @@ describe('Inherit from DirectedGraph and perform operations test2.', () => {
|
|
|
319
319
|
const fordResult1 = myGraph.bellmanFord(1);
|
|
320
320
|
expect(fordResult1).toBeTruthy();
|
|
321
321
|
expect(fordResult1.hasNegativeCycle).toBeUndefined();
|
|
322
|
-
const {distMap, preMap, paths, min, minPath} = fordResult1;
|
|
322
|
+
const { distMap, preMap, paths, min, minPath } = fordResult1;
|
|
323
323
|
expect(distMap).toBeInstanceOf(Map);
|
|
324
324
|
expect(distMap.size).toBe(9);
|
|
325
325
|
expect(distMap.get(vertex1)).toBe(0);
|
|
@@ -343,7 +343,7 @@ describe('Inherit from DirectedGraph and perform operations test2.', () => {
|
|
|
343
343
|
const floydResult = myGraph.floydWarshall();
|
|
344
344
|
expect(floydResult).toBeTruthy();
|
|
345
345
|
if (floydResult) {
|
|
346
|
-
const {costs, predecessor} = floydResult;
|
|
346
|
+
const { costs, predecessor } = floydResult;
|
|
347
347
|
expect(costs).toBeInstanceOf(Array);
|
|
348
348
|
expect(costs.length).toBe(9);
|
|
349
349
|
expect(costs[0]).toEqual([32, 12, 35, 14, 70, Infinity, 61, Infinity, 19]);
|
|
@@ -351,9 +351,29 @@ describe('Inherit from DirectedGraph and perform operations test2.', () => {
|
|
|
351
351
|
expect(costs[2]).toEqual([3, 15, 38, 17, 35, Infinity, 64, Infinity, 22]);
|
|
352
352
|
expect(costs[3]).toEqual([123, 135, 120, 137, 155, Infinity, 47, Infinity, 126]);
|
|
353
353
|
expect(costs[4]).toEqual([133, 145, 130, 147, 165, Infinity, 57, Infinity, 136]);
|
|
354
|
-
expect(costs[5]).toEqual([
|
|
354
|
+
expect(costs[5]).toEqual([
|
|
355
|
+
Infinity,
|
|
356
|
+
Infinity,
|
|
357
|
+
Infinity,
|
|
358
|
+
Infinity,
|
|
359
|
+
Infinity,
|
|
360
|
+
Infinity,
|
|
361
|
+
Infinity,
|
|
362
|
+
Infinity,
|
|
363
|
+
Infinity
|
|
364
|
+
]);
|
|
355
365
|
expect(costs[6]).toEqual([76, 88, 73, 90, 108, Infinity, 137, Infinity, 79]);
|
|
356
|
-
expect(costs[7]).toEqual([
|
|
366
|
+
expect(costs[7]).toEqual([
|
|
367
|
+
Infinity,
|
|
368
|
+
Infinity,
|
|
369
|
+
Infinity,
|
|
370
|
+
Infinity,
|
|
371
|
+
Infinity,
|
|
372
|
+
Infinity,
|
|
373
|
+
Infinity,
|
|
374
|
+
Infinity,
|
|
375
|
+
Infinity
|
|
376
|
+
]);
|
|
357
377
|
expect(costs[8]).toEqual([173, 185, 170, 187, 205, Infinity, 97, Infinity, 176]);
|
|
358
378
|
|
|
359
379
|
expect(predecessor).toBeInstanceOf(Array);
|
|
@@ -369,7 +389,7 @@ describe('Inherit from DirectedGraph and perform operations test2.', () => {
|
|
|
369
389
|
|
|
370
390
|
expect(dijkstraRes12tt).toBeTruthy();
|
|
371
391
|
if (dijkstraRes12tt) {
|
|
372
|
-
const {distMap, minDist, minPath, paths} = dijkstraRes12tt;
|
|
392
|
+
const { distMap, minDist, minPath, paths } = dijkstraRes12tt;
|
|
373
393
|
expect(distMap).toBeInstanceOf(Map);
|
|
374
394
|
expect(distMap.size).toBe(9);
|
|
375
395
|
expect(distMap.get(vertex1)).toBe(0);
|
|
@@ -420,7 +440,7 @@ describe('Inherit from DirectedGraph and perform operations test2.', () => {
|
|
|
420
440
|
|
|
421
441
|
expect(dijkstraRes1ntt).toBeTruthy();
|
|
422
442
|
if (dijkstraRes1ntt) {
|
|
423
|
-
const {distMap, minDist, minPath, paths} = dijkstraRes1ntt;
|
|
443
|
+
const { distMap, minDist, minPath, paths } = dijkstraRes1ntt;
|
|
424
444
|
expect(distMap).toBeInstanceOf(Map);
|
|
425
445
|
expect(distMap.size).toBe(9);
|
|
426
446
|
expect(distMap.get(vertex1)).toBe(0);
|
|
@@ -482,7 +502,7 @@ describe('Inherit from DirectedGraph and perform operations test2.', () => {
|
|
|
482
502
|
const dijkstraWithoutHeapRes1ntt = myGraph.dijkstraWithoutHeap(1, null, true, true);
|
|
483
503
|
expect(dijkstraWithoutHeapRes1ntt).toBeTruthy();
|
|
484
504
|
if (dijkstraWithoutHeapRes1ntt) {
|
|
485
|
-
const {distMap, minDist, minPath, paths} = dijkstraWithoutHeapRes1ntt;
|
|
505
|
+
const { distMap, minDist, minPath, paths } = dijkstraWithoutHeapRes1ntt;
|
|
486
506
|
expect(distMap).toBeInstanceOf(Map);
|
|
487
507
|
expect(distMap.size).toBe(9);
|
|
488
508
|
expect(distMap.get(vertex1)).toBe(0);
|