data-structure-typed 1.54.3 → 2.0.1
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/CHANGELOG.md +1 -1
- package/benchmark/report.html +26 -2
- package/benchmark/report.json +292 -42
- package/dist/cjs/data-structures/base/iterable-element-base.d.ts +14 -40
- package/dist/cjs/data-structures/base/iterable-element-base.js +14 -11
- package/dist/cjs/data-structures/base/iterable-element-base.js.map +1 -1
- package/dist/cjs/data-structures/base/linear-base.d.ts +277 -0
- package/dist/cjs/data-structures/base/linear-base.js +553 -0
- package/dist/cjs/data-structures/base/linear-base.js.map +1 -0
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +12 -8
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +50 -37
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +64 -0
- package/dist/cjs/data-structures/binary-tree/avl-tree.js +64 -0
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +62 -0
- package/dist/cjs/data-structures/binary-tree/binary-tree.js +67 -5
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/bst.d.ts +3 -3
- package/dist/cjs/data-structures/binary-tree/bst.js +14 -14
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/red-black-tree.d.ts +1 -7
- package/dist/cjs/data-structures/binary-tree/red-black-tree.js +1 -7
- package/dist/cjs/data-structures/binary-tree/red-black-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +175 -14
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +210 -40
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
- package/dist/cjs/data-structures/graph/abstract-graph.js +16 -16
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/cjs/data-structures/hash/hash-map.d.ts +46 -0
- package/dist/cjs/data-structures/hash/hash-map.js +46 -0
- package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
- package/dist/cjs/data-structures/heap/heap.d.ts +3 -11
- package/dist/cjs/data-structures/heap/heap.js +0 -10
- package/dist/cjs/data-structures/heap/heap.js.map +1 -1
- package/dist/cjs/data-structures/heap/max-heap.d.ts +2 -2
- package/dist/cjs/data-structures/heap/max-heap.js.map +1 -1
- package/dist/cjs/data-structures/heap/min-heap.d.ts +2 -2
- package/dist/cjs/data-structures/heap/min-heap.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +65 -94
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +131 -146
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +145 -75
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js +283 -169
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +2 -2
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +2 -2
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +2 -2
- package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/queue/deque.d.ts +130 -91
- package/dist/cjs/data-structures/queue/deque.js +269 -169
- package/dist/cjs/data-structures/queue/deque.js.map +1 -1
- package/dist/cjs/data-structures/queue/queue.d.ts +131 -40
- package/dist/cjs/data-structures/queue/queue.js +181 -50
- package/dist/cjs/data-structures/queue/queue.js.map +1 -1
- package/dist/cjs/data-structures/stack/stack.d.ts +124 -11
- package/dist/cjs/data-structures/stack/stack.js +121 -10
- package/dist/cjs/data-structures/stack/stack.js.map +1 -1
- package/dist/cjs/data-structures/trie/trie.d.ts +4 -3
- package/dist/cjs/data-structures/trie/trie.js +3 -0
- package/dist/cjs/data-structures/trie/trie.js.map +1 -1
- package/dist/cjs/types/data-structures/base/base.d.ts +9 -4
- package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -1
- package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.d.ts +1 -1
- package/dist/cjs/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -2
- package/dist/cjs/types/data-structures/linked-list/singly-linked-list.d.ts +2 -2
- package/dist/cjs/types/data-structures/queue/deque.d.ts +2 -3
- package/dist/cjs/types/data-structures/queue/queue.d.ts +2 -2
- package/dist/esm/data-structures/base/iterable-element-base.d.ts +14 -40
- package/dist/esm/data-structures/base/iterable-element-base.js +14 -11
- package/dist/esm/data-structures/base/iterable-element-base.js.map +1 -1
- package/dist/esm/data-structures/base/linear-base.d.ts +277 -0
- package/dist/esm/data-structures/base/linear-base.js +549 -0
- package/dist/esm/data-structures/base/linear-base.js.map +1 -0
- package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.d.ts +12 -8
- package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js +50 -36
- package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
- package/dist/esm/data-structures/binary-tree/avl-tree.d.ts +64 -0
- package/dist/esm/data-structures/binary-tree/avl-tree.js +64 -0
- package/dist/esm/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/esm/data-structures/binary-tree/binary-tree.d.ts +62 -0
- package/dist/esm/data-structures/binary-tree/binary-tree.js +67 -5
- package/dist/esm/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/esm/data-structures/binary-tree/bst.d.ts +3 -3
- package/dist/esm/data-structures/binary-tree/bst.js +14 -12
- package/dist/esm/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/esm/data-structures/binary-tree/red-black-tree.d.ts +1 -7
- package/dist/esm/data-structures/binary-tree/red-black-tree.js +1 -7
- package/dist/esm/data-structures/binary-tree/red-black-tree.js.map +1 -1
- package/dist/esm/data-structures/binary-tree/tree-multi-map.d.ts +175 -14
- package/dist/esm/data-structures/binary-tree/tree-multi-map.js +210 -39
- package/dist/esm/data-structures/binary-tree/tree-multi-map.js.map +1 -1
- package/dist/esm/data-structures/graph/abstract-graph.js +16 -16
- package/dist/esm/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/esm/data-structures/hash/hash-map.d.ts +46 -0
- package/dist/esm/data-structures/hash/hash-map.js +46 -0
- package/dist/esm/data-structures/hash/hash-map.js.map +1 -1
- package/dist/esm/data-structures/heap/heap.d.ts +3 -11
- package/dist/esm/data-structures/heap/heap.js +0 -10
- package/dist/esm/data-structures/heap/heap.js.map +1 -1
- package/dist/esm/data-structures/heap/max-heap.d.ts +2 -2
- package/dist/esm/data-structures/heap/max-heap.js.map +1 -1
- package/dist/esm/data-structures/heap/min-heap.d.ts +2 -2
- package/dist/esm/data-structures/heap/min-heap.js.map +1 -1
- package/dist/esm/data-structures/linked-list/doubly-linked-list.d.ts +65 -94
- package/dist/esm/data-structures/linked-list/doubly-linked-list.js +132 -148
- package/dist/esm/data-structures/linked-list/doubly-linked-list.js.map +1 -1
- package/dist/esm/data-structures/linked-list/singly-linked-list.d.ts +145 -75
- package/dist/esm/data-structures/linked-list/singly-linked-list.js +283 -170
- package/dist/esm/data-structures/linked-list/singly-linked-list.js.map +1 -1
- package/dist/esm/data-structures/priority-queue/max-priority-queue.d.ts +2 -2
- package/dist/esm/data-structures/priority-queue/max-priority-queue.js.map +1 -1
- package/dist/esm/data-structures/priority-queue/min-priority-queue.d.ts +2 -2
- package/dist/esm/data-structures/priority-queue/min-priority-queue.js.map +1 -1
- package/dist/esm/data-structures/priority-queue/priority-queue.d.ts +2 -2
- package/dist/esm/data-structures/priority-queue/priority-queue.js.map +1 -1
- package/dist/esm/data-structures/queue/deque.d.ts +130 -91
- package/dist/esm/data-structures/queue/deque.js +269 -169
- package/dist/esm/data-structures/queue/deque.js.map +1 -1
- package/dist/esm/data-structures/queue/queue.d.ts +131 -40
- package/dist/esm/data-structures/queue/queue.js +182 -51
- package/dist/esm/data-structures/queue/queue.js.map +1 -1
- package/dist/esm/data-structures/stack/stack.d.ts +124 -11
- package/dist/esm/data-structures/stack/stack.js +121 -10
- package/dist/esm/data-structures/stack/stack.js.map +1 -1
- package/dist/esm/data-structures/trie/trie.d.ts +4 -3
- package/dist/esm/data-structures/trie/trie.js +3 -0
- package/dist/esm/data-structures/trie/trie.js.map +1 -1
- package/dist/esm/types/data-structures/base/base.d.ts +9 -4
- package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -1
- package/dist/esm/types/data-structures/binary-tree/tree-multi-map.d.ts +1 -1
- package/dist/esm/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -2
- package/dist/esm/types/data-structures/linked-list/singly-linked-list.d.ts +2 -2
- package/dist/esm/types/data-structures/queue/deque.d.ts +2 -3
- package/dist/esm/types/data-structures/queue/queue.d.ts +2 -2
- package/dist/individuals/binary-tree/avl-tree-counter.mjs +4701 -0
- package/dist/individuals/binary-tree/avl-tree-multi-map.mjs +4514 -0
- package/dist/individuals/binary-tree/avl-tree.mjs +4321 -0
- package/dist/individuals/binary-tree/binary-tree.mjs +3097 -0
- package/dist/individuals/binary-tree/bst.mjs +3858 -0
- package/dist/individuals/binary-tree/red-black-tree.mjs +4391 -0
- package/dist/individuals/binary-tree/tree-counter.mjs +4806 -0
- package/dist/individuals/binary-tree/tree-multi-map.mjs +4582 -0
- package/dist/individuals/graph/directed-graph.mjs +2910 -0
- package/dist/individuals/graph/undirected-graph.mjs +2745 -0
- package/dist/individuals/hash/hash-map.mjs +1040 -0
- package/dist/individuals/heap/heap.mjs +909 -0
- package/dist/individuals/heap/max-heap.mjs +671 -0
- package/dist/individuals/heap/min-heap.mjs +659 -0
- package/dist/individuals/linked-list/doubly-linked-list.mjs +1495 -0
- package/dist/individuals/linked-list/singly-linked-list.mjs +1479 -0
- package/dist/individuals/priority-queue/max-priority-queue.mjs +768 -0
- package/dist/individuals/priority-queue/min-priority-queue.mjs +757 -0
- package/dist/individuals/priority-queue/priority-queue.mjs +670 -0
- package/dist/individuals/queue/deque.mjs +1262 -0
- package/dist/individuals/queue/queue.mjs +1865 -0
- package/dist/individuals/stack/stack.mjs +415 -0
- package/dist/individuals/trie/trie.mjs +687 -0
- package/dist/umd/data-structure-typed.js +1260 -649
- package/dist/umd/data-structure-typed.min.js +3 -3
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +7 -7
- package/src/data-structures/base/iterable-element-base.ts +29 -20
- package/src/data-structures/base/linear-base.ts +649 -0
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +51 -36
- package/src/data-structures/binary-tree/avl-tree.ts +64 -0
- package/src/data-structures/binary-tree/binary-tree.ts +5 -5
- package/src/data-structures/binary-tree/bst.ts +9 -9
- package/src/data-structures/binary-tree/tree-multi-map.ts +214 -40
- package/src/data-structures/graph/abstract-graph.ts +16 -16
- package/src/data-structures/hash/hash-map.ts +46 -0
- package/src/data-structures/heap/heap.ts +3 -14
- package/src/data-structures/heap/max-heap.ts +2 -2
- package/src/data-structures/heap/min-heap.ts +2 -2
- package/src/data-structures/linked-list/doubly-linked-list.ts +144 -160
- package/src/data-structures/linked-list/singly-linked-list.ts +307 -185
- package/src/data-structures/priority-queue/max-priority-queue.ts +2 -5
- package/src/data-structures/priority-queue/min-priority-queue.ts +2 -5
- package/src/data-structures/priority-queue/priority-queue.ts +2 -2
- package/src/data-structures/queue/deque.ts +286 -183
- package/src/data-structures/queue/queue.ts +196 -63
- package/src/data-structures/stack/stack.ts +124 -18
- package/src/data-structures/trie/trie.ts +7 -3
- package/src/types/data-structures/base/base.ts +17 -8
- package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +1 -1
- package/src/types/data-structures/binary-tree/tree-multi-map.ts +1 -1
- package/src/types/data-structures/linked-list/doubly-linked-list.ts +2 -2
- package/src/types/data-structures/linked-list/singly-linked-list.ts +2 -2
- package/src/types/data-structures/queue/deque.ts +2 -3
- package/src/types/data-structures/queue/queue.ts +2 -2
- package/test/integration/all-in-one.test.ts +1 -1
- package/test/integration/avl-tree.test.ts +1 -1
- package/test/integration/bst.test.ts +2 -2
- package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +168 -0
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +15 -14
- package/test/unit/data-structures/binary-tree/red-black-tree.test.ts +1 -1
- package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +165 -7
- package/test/unit/data-structures/graph/directed-graph.test.ts +37 -37
- package/test/unit/data-structures/graph/undirected-graph.test.ts +2 -2
- package/test/unit/data-structures/hash/hash-map.test.ts +135 -0
- package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +135 -27
- package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +183 -12
- package/test/unit/data-structures/queue/deque.test.ts +241 -60
- package/test/unit/data-structures/queue/queue.test.ts +332 -19
- package/test/unit/data-structures/stack/stack.test.ts +165 -0
- package/test/unit/unrestricted-interconversion.test.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LinearBaseOptions } from '../base';
|
|
2
2
|
|
|
3
|
-
export type QueueOptions<E, R> =
|
|
3
|
+
export type QueueOptions<E, R> = LinearBaseOptions<E, R> & {
|
|
4
4
|
autoCompactRatio?: number;
|
|
5
5
|
};
|
|
@@ -23,7 +23,7 @@ describe('AVL Tree Test from data-structure-typed', () => {
|
|
|
23
23
|
expect(getMinNodeBySpecificNode?.key).toBe(12);
|
|
24
24
|
|
|
25
25
|
let subTreeSum = 0;
|
|
26
|
-
if (node15) tree.dfs(node => (subTreeSum += node.key), 'PRE', 15);
|
|
26
|
+
if (node15) tree.dfs(node => (subTreeSum += node.key), 'PRE', false, 15);
|
|
27
27
|
expect(subTreeSum).toBe(70);
|
|
28
28
|
|
|
29
29
|
let lesserSum = 0;
|
|
@@ -40,7 +40,7 @@ describe('AVL Tree Test', () => {
|
|
|
40
40
|
expect(getMinNodeBySpecificNode?.key).toBe(12);
|
|
41
41
|
|
|
42
42
|
let subTreeSum = 0;
|
|
43
|
-
if (node15) tree.dfs(node => (subTreeSum += node.key), 'IN', 15);
|
|
43
|
+
if (node15) tree.dfs(node => (subTreeSum += node.key), 'IN', false, 15);
|
|
44
44
|
expect(subTreeSum).toBe(70);
|
|
45
45
|
|
|
46
46
|
let lesserSum = 0;
|
|
@@ -37,7 +37,7 @@ describe('Individual package BST operations test', () => {
|
|
|
37
37
|
expect(minNodeBySpecificNode?.key).toBe(14);
|
|
38
38
|
|
|
39
39
|
let subTreeSum = 0;
|
|
40
|
-
if (node15) bst.dfs(node => (subTreeSum += node.key), 'IN', 15);
|
|
40
|
+
if (node15) bst.dfs(node => (subTreeSum += node.key), 'IN', false, 15);
|
|
41
41
|
expect(subTreeSum).toBe(45);
|
|
42
42
|
|
|
43
43
|
let lesserSum = 0;
|
|
@@ -236,7 +236,7 @@ describe('Individual package BST operations test', () => {
|
|
|
236
236
|
expect(minNodeBySpecificNode?.key).toBe(14);
|
|
237
237
|
|
|
238
238
|
let subTreeSum = 0;
|
|
239
|
-
if (node15) objBST.dfs(node => (subTreeSum += node.key), 'IN', node15);
|
|
239
|
+
if (node15) objBST.dfs(node => (subTreeSum += node.key), 'IN', false, node15);
|
|
240
240
|
expect(subTreeSum).toBe(45);
|
|
241
241
|
|
|
242
242
|
let lesserSum = 0;
|
|
@@ -570,3 +570,171 @@ describe('AVLTreeMultiMap iterative methods not map mode', () => {
|
|
|
570
570
|
expect(cloned.get(cloned.root?.right?.key)).toEqual(['c']);
|
|
571
571
|
});
|
|
572
572
|
});
|
|
573
|
+
|
|
574
|
+
describe('classic use', () => {
|
|
575
|
+
// Test suite for TreeMultiMap with player ranking and equipment
|
|
576
|
+
it('players ranked by score with their equipment', () => {
|
|
577
|
+
type Equipment = {
|
|
578
|
+
name: string; // Equipment name
|
|
579
|
+
quality: 'legendary' | 'epic' | 'rare' | 'common';
|
|
580
|
+
level: number;
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
type Player = {
|
|
584
|
+
name: string;
|
|
585
|
+
score: number;
|
|
586
|
+
equipments: Equipment[];
|
|
587
|
+
};
|
|
588
|
+
|
|
589
|
+
// Mock player data with their scores and equipment
|
|
590
|
+
const players: Player[] = [
|
|
591
|
+
{
|
|
592
|
+
name: 'DragonSlayer',
|
|
593
|
+
score: 8750,
|
|
594
|
+
equipments: [
|
|
595
|
+
{ name: 'AWM', quality: 'legendary', level: 85 },
|
|
596
|
+
{ name: 'Level 3 Helmet', quality: 'epic', level: 80 },
|
|
597
|
+
{ name: 'Extended Quickdraw Mag', quality: 'rare', level: 75 },
|
|
598
|
+
{ name: 'Compensator', quality: 'epic', level: 78 },
|
|
599
|
+
{ name: 'Vertical Grip', quality: 'rare', level: 72 }
|
|
600
|
+
]
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
name: 'ShadowNinja',
|
|
604
|
+
score: 7200,
|
|
605
|
+
equipments: [
|
|
606
|
+
{ name: 'M416', quality: 'epic', level: 75 },
|
|
607
|
+
{ name: 'Ghillie Suit', quality: 'rare', level: 70 },
|
|
608
|
+
{ name: 'Red Dot Sight', quality: 'common', level: 65 },
|
|
609
|
+
{ name: 'Extended QuickDraw Mag', quality: 'rare', level: 68 }
|
|
610
|
+
]
|
|
611
|
+
},
|
|
612
|
+
{
|
|
613
|
+
name: 'RuneMaster',
|
|
614
|
+
score: 9100,
|
|
615
|
+
equipments: [
|
|
616
|
+
{ name: 'KAR98K', quality: 'legendary', level: 90 },
|
|
617
|
+
{ name: 'Level 3 Vest', quality: 'legendary', level: 85 },
|
|
618
|
+
{ name: 'Holographic Sight', quality: 'epic', level: 82 },
|
|
619
|
+
{ name: 'Suppressor', quality: 'legendary', level: 88 },
|
|
620
|
+
{ name: 'Level 3 Backpack', quality: 'epic', level: 80 }
|
|
621
|
+
]
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
name: 'BattleKing',
|
|
625
|
+
score: 8500,
|
|
626
|
+
equipments: [
|
|
627
|
+
{ name: 'AUG', quality: 'epic', level: 82 },
|
|
628
|
+
{ name: 'Red Dot Sight', quality: 'rare', level: 75 },
|
|
629
|
+
{ name: 'Extended Mag', quality: 'common', level: 70 },
|
|
630
|
+
{ name: 'Tactical Stock', quality: 'rare', level: 76 }
|
|
631
|
+
]
|
|
632
|
+
},
|
|
633
|
+
{
|
|
634
|
+
name: 'SniperElite',
|
|
635
|
+
score: 7800,
|
|
636
|
+
equipments: [
|
|
637
|
+
{ name: 'M24', quality: 'legendary', level: 88 },
|
|
638
|
+
{ name: 'Compensator', quality: 'epic', level: 80 },
|
|
639
|
+
{ name: 'Scope 8x', quality: 'legendary', level: 85 },
|
|
640
|
+
{ name: 'Level 2 Helmet', quality: 'rare', level: 75 }
|
|
641
|
+
]
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
name: 'RushMaster',
|
|
645
|
+
score: 7500,
|
|
646
|
+
equipments: [
|
|
647
|
+
{ name: 'Vector', quality: 'rare', level: 72 },
|
|
648
|
+
{ name: 'Level 2 Helmet', quality: 'common', level: 65 },
|
|
649
|
+
{ name: 'Quickdraw Mag', quality: 'common', level: 60 },
|
|
650
|
+
{ name: 'Laser Sight', quality: 'rare', level: 68 }
|
|
651
|
+
]
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
name: 'GhostWarrior',
|
|
655
|
+
score: 8200,
|
|
656
|
+
equipments: [
|
|
657
|
+
{ name: 'SCAR-L', quality: 'epic', level: 78 },
|
|
658
|
+
{ name: 'Extended Quickdraw Mag', quality: 'rare', level: 70 },
|
|
659
|
+
{ name: 'Holographic Sight', quality: 'epic', level: 75 },
|
|
660
|
+
{ name: 'Suppressor', quality: 'rare', level: 72 },
|
|
661
|
+
{ name: 'Vertical Grip', quality: 'common', level: 65 }
|
|
662
|
+
]
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
name: 'DeathDealer',
|
|
666
|
+
score: 7300,
|
|
667
|
+
equipments: [
|
|
668
|
+
{ name: 'SKS', quality: 'epic', level: 76 },
|
|
669
|
+
{ name: 'Holographic Sight', quality: 'rare', level: 68 },
|
|
670
|
+
{ name: 'Extended Mag', quality: 'common', level: 65 }
|
|
671
|
+
]
|
|
672
|
+
},
|
|
673
|
+
{
|
|
674
|
+
name: 'StormRider',
|
|
675
|
+
score: 8900,
|
|
676
|
+
equipments: [
|
|
677
|
+
{ name: 'MK14', quality: 'legendary', level: 92 },
|
|
678
|
+
{ name: 'Level 3 Backpack', quality: 'legendary', level: 85 },
|
|
679
|
+
{ name: 'Scope 8x', quality: 'epic', level: 80 },
|
|
680
|
+
{ name: 'Suppressor', quality: 'legendary', level: 88 },
|
|
681
|
+
{ name: 'Tactical Stock', quality: 'rare', level: 75 }
|
|
682
|
+
]
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
name: 'CombatLegend',
|
|
686
|
+
score: 7600,
|
|
687
|
+
equipments: [
|
|
688
|
+
{ name: 'UMP45', quality: 'rare', level: 74 },
|
|
689
|
+
{ name: 'Level 2 Vest', quality: 'common', level: 67 },
|
|
690
|
+
{ name: 'Red Dot Sight', quality: 'common', level: 62 },
|
|
691
|
+
{ name: 'Extended Mag', quality: 'rare', level: 70 }
|
|
692
|
+
]
|
|
693
|
+
}
|
|
694
|
+
];
|
|
695
|
+
|
|
696
|
+
// Create a TreeMultiMap for player rankings
|
|
697
|
+
const playerRankings = new AVLTreeMultiMap<number, Equipment, Player>(players, {
|
|
698
|
+
toEntryFn: ({ score, equipments }) => [score, equipments],
|
|
699
|
+
isMapMode: false
|
|
700
|
+
});
|
|
701
|
+
|
|
702
|
+
const topPlayersEquipments = playerRankings.rangeSearch([8900, 10000], node => playerRankings.get(node));
|
|
703
|
+
expect(topPlayersEquipments).toEqual([
|
|
704
|
+
[
|
|
705
|
+
{
|
|
706
|
+
name: 'MK14',
|
|
707
|
+
quality: 'legendary',
|
|
708
|
+
level: 92
|
|
709
|
+
},
|
|
710
|
+
{ name: 'Level 3 Backpack', quality: 'legendary', level: 85 },
|
|
711
|
+
{
|
|
712
|
+
name: 'Scope 8x',
|
|
713
|
+
quality: 'epic',
|
|
714
|
+
level: 80
|
|
715
|
+
},
|
|
716
|
+
{ name: 'Suppressor', quality: 'legendary', level: 88 },
|
|
717
|
+
{
|
|
718
|
+
name: 'Tactical Stock',
|
|
719
|
+
quality: 'rare',
|
|
720
|
+
level: 75
|
|
721
|
+
}
|
|
722
|
+
],
|
|
723
|
+
[
|
|
724
|
+
{ name: 'KAR98K', quality: 'legendary', level: 90 },
|
|
725
|
+
{
|
|
726
|
+
name: 'Level 3 Vest',
|
|
727
|
+
quality: 'legendary',
|
|
728
|
+
level: 85
|
|
729
|
+
},
|
|
730
|
+
{ name: 'Holographic Sight', quality: 'epic', level: 82 },
|
|
731
|
+
{
|
|
732
|
+
name: 'Suppressor',
|
|
733
|
+
quality: 'legendary',
|
|
734
|
+
level: 88
|
|
735
|
+
},
|
|
736
|
+
{ name: 'Level 3 Backpack', quality: 'epic', level: 80 }
|
|
737
|
+
]
|
|
738
|
+
]);
|
|
739
|
+
});
|
|
740
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AVLTree, AVLTreeNode, BinaryTreeNode, BSTNode
|
|
1
|
+
import { AVLTree, AVLTreeNode, BinaryTreeNode, BSTNode } from '../../../../src';
|
|
2
2
|
|
|
3
3
|
describe('AVL Tree Test', () => {
|
|
4
4
|
it('should perform various operations on a AVL Tree', () => {
|
|
@@ -546,6 +546,7 @@ describe('AVLTree iterative methods not map mode', () => {
|
|
|
546
546
|
describe('classic use', () => {
|
|
547
547
|
// Test case for finding elements in a given range
|
|
548
548
|
it('@example Find elements in a range', () => {
|
|
549
|
+
// In interval queries, AVL trees, with their strictly balanced structure and lower height, offer better query efficiency, making them ideal for frequent and high-performance interval queries. In contrast, Red-Black trees, with lower update costs, are more suitable for scenarios involving frequent insertions and deletions where the requirements for interval queries are less demanding.
|
|
549
550
|
type Datum = { timestamp: Date; temperature: number };
|
|
550
551
|
// Fixed dataset of CPU temperature readings
|
|
551
552
|
const cpuData: Datum[] = [
|
|
@@ -594,18 +595,18 @@ describe('classic use', () => {
|
|
|
594
595
|
temperature: cpuTemperatureTree.get(node ? node.key : undefined)
|
|
595
596
|
}));
|
|
596
597
|
|
|
597
|
-
expect(rangeResults).toEqual(
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
598
|
+
expect(rangeResults).toEqual([
|
|
599
|
+
{ minute: 5, temperature: 59.4 },
|
|
600
|
+
{ minute: 6, temperature: 60.1 },
|
|
601
|
+
{ minute: 7, temperature: 61.3 },
|
|
602
|
+
{ minute: 8, temperature: 62 },
|
|
603
|
+
{ minute: 9, temperature: 63.5 },
|
|
604
|
+
{ minute: 10, temperature: 64 },
|
|
605
|
+
{ minute: 11, temperature: 62.8 },
|
|
606
|
+
{ minute: 12, temperature: 61.5 },
|
|
607
|
+
{ minute: 13, temperature: 60.2 },
|
|
608
|
+
{ minute: 14, temperature: 59.8 },
|
|
609
|
+
{ minute: 15, temperature: 58.6 }
|
|
610
|
+
]);
|
|
610
611
|
});
|
|
611
612
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BinaryTreeNode, BSTNode,
|
|
1
|
+
import { BinaryTreeNode, BSTNode, RedBlackTree, RedBlackTreeNode } from '../../../../src';
|
|
2
2
|
import { getRandomInt, getRandomIntArray, magnitude } from '../../../utils';
|
|
3
3
|
import { OrderedMap } from 'js-sdsl';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BinaryTreeNode, BSTNode,
|
|
1
|
+
import { BinaryTreeNode, BSTNode, TreeMultiMap, TreeMultiMapNode } from '../../../../src';
|
|
2
2
|
import { getRandomInt } from '../../../utils';
|
|
3
3
|
|
|
4
4
|
import { isDebugTest } from '../../../config';
|
|
@@ -837,11 +837,169 @@ describe('real world data', () => {
|
|
|
837
837
|
});
|
|
838
838
|
|
|
839
839
|
describe('classic use', () => {
|
|
840
|
-
// Test
|
|
841
|
-
it('@example
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
840
|
+
// Test suite for TreeMultiMap with player ranking and equipment
|
|
841
|
+
it('@example players ranked by score with their equipment', () => {
|
|
842
|
+
type Equipment = {
|
|
843
|
+
name: string; // Equipment name
|
|
844
|
+
quality: 'legendary' | 'epic' | 'rare' | 'common';
|
|
845
|
+
level: number;
|
|
846
|
+
};
|
|
847
|
+
|
|
848
|
+
type Player = {
|
|
849
|
+
name: string;
|
|
850
|
+
score: number;
|
|
851
|
+
equipments: Equipment[];
|
|
852
|
+
};
|
|
853
|
+
|
|
854
|
+
// Mock player data with their scores and equipment
|
|
855
|
+
const players: Player[] = [
|
|
856
|
+
{
|
|
857
|
+
name: 'DragonSlayer',
|
|
858
|
+
score: 8750,
|
|
859
|
+
equipments: [
|
|
860
|
+
{ name: 'AWM', quality: 'legendary', level: 85 },
|
|
861
|
+
{ name: 'Level 3 Helmet', quality: 'epic', level: 80 },
|
|
862
|
+
{ name: 'Extended Quickdraw Mag', quality: 'rare', level: 75 },
|
|
863
|
+
{ name: 'Compensator', quality: 'epic', level: 78 },
|
|
864
|
+
{ name: 'Vertical Grip', quality: 'rare', level: 72 }
|
|
865
|
+
]
|
|
866
|
+
},
|
|
867
|
+
{
|
|
868
|
+
name: 'ShadowNinja',
|
|
869
|
+
score: 7200,
|
|
870
|
+
equipments: [
|
|
871
|
+
{ name: 'M416', quality: 'epic', level: 75 },
|
|
872
|
+
{ name: 'Ghillie Suit', quality: 'rare', level: 70 },
|
|
873
|
+
{ name: 'Red Dot Sight', quality: 'common', level: 65 },
|
|
874
|
+
{ name: 'Extended QuickDraw Mag', quality: 'rare', level: 68 }
|
|
875
|
+
]
|
|
876
|
+
},
|
|
877
|
+
{
|
|
878
|
+
name: 'RuneMaster',
|
|
879
|
+
score: 9100,
|
|
880
|
+
equipments: [
|
|
881
|
+
{ name: 'KAR98K', quality: 'legendary', level: 90 },
|
|
882
|
+
{ name: 'Level 3 Vest', quality: 'legendary', level: 85 },
|
|
883
|
+
{ name: 'Holographic Sight', quality: 'epic', level: 82 },
|
|
884
|
+
{ name: 'Suppressor', quality: 'legendary', level: 88 },
|
|
885
|
+
{ name: 'Level 3 Backpack', quality: 'epic', level: 80 }
|
|
886
|
+
]
|
|
887
|
+
},
|
|
888
|
+
{
|
|
889
|
+
name: 'BattleKing',
|
|
890
|
+
score: 8500,
|
|
891
|
+
equipments: [
|
|
892
|
+
{ name: 'AUG', quality: 'epic', level: 82 },
|
|
893
|
+
{ name: 'Red Dot Sight', quality: 'rare', level: 75 },
|
|
894
|
+
{ name: 'Extended Mag', quality: 'common', level: 70 },
|
|
895
|
+
{ name: 'Tactical Stock', quality: 'rare', level: 76 }
|
|
896
|
+
]
|
|
897
|
+
},
|
|
898
|
+
{
|
|
899
|
+
name: 'SniperElite',
|
|
900
|
+
score: 7800,
|
|
901
|
+
equipments: [
|
|
902
|
+
{ name: 'M24', quality: 'legendary', level: 88 },
|
|
903
|
+
{ name: 'Compensator', quality: 'epic', level: 80 },
|
|
904
|
+
{ name: 'Scope 8x', quality: 'legendary', level: 85 },
|
|
905
|
+
{ name: 'Level 2 Helmet', quality: 'rare', level: 75 }
|
|
906
|
+
]
|
|
907
|
+
},
|
|
908
|
+
{
|
|
909
|
+
name: 'RushMaster',
|
|
910
|
+
score: 7500,
|
|
911
|
+
equipments: [
|
|
912
|
+
{ name: 'Vector', quality: 'rare', level: 72 },
|
|
913
|
+
{ name: 'Level 2 Helmet', quality: 'common', level: 65 },
|
|
914
|
+
{ name: 'Quickdraw Mag', quality: 'common', level: 60 },
|
|
915
|
+
{ name: 'Laser Sight', quality: 'rare', level: 68 }
|
|
916
|
+
]
|
|
917
|
+
},
|
|
918
|
+
{
|
|
919
|
+
name: 'GhostWarrior',
|
|
920
|
+
score: 8200,
|
|
921
|
+
equipments: [
|
|
922
|
+
{ name: 'SCAR-L', quality: 'epic', level: 78 },
|
|
923
|
+
{ name: 'Extended Quickdraw Mag', quality: 'rare', level: 70 },
|
|
924
|
+
{ name: 'Holographic Sight', quality: 'epic', level: 75 },
|
|
925
|
+
{ name: 'Suppressor', quality: 'rare', level: 72 },
|
|
926
|
+
{ name: 'Vertical Grip', quality: 'common', level: 65 }
|
|
927
|
+
]
|
|
928
|
+
},
|
|
929
|
+
{
|
|
930
|
+
name: 'DeathDealer',
|
|
931
|
+
score: 7300,
|
|
932
|
+
equipments: [
|
|
933
|
+
{ name: 'SKS', quality: 'epic', level: 76 },
|
|
934
|
+
{ name: 'Holographic Sight', quality: 'rare', level: 68 },
|
|
935
|
+
{ name: 'Extended Mag', quality: 'common', level: 65 }
|
|
936
|
+
]
|
|
937
|
+
},
|
|
938
|
+
{
|
|
939
|
+
name: 'StormRider',
|
|
940
|
+
score: 8900,
|
|
941
|
+
equipments: [
|
|
942
|
+
{ name: 'MK14', quality: 'legendary', level: 92 },
|
|
943
|
+
{ name: 'Level 3 Backpack', quality: 'legendary', level: 85 },
|
|
944
|
+
{ name: 'Scope 8x', quality: 'epic', level: 80 },
|
|
945
|
+
{ name: 'Suppressor', quality: 'legendary', level: 88 },
|
|
946
|
+
{ name: 'Tactical Stock', quality: 'rare', level: 75 }
|
|
947
|
+
]
|
|
948
|
+
},
|
|
949
|
+
{
|
|
950
|
+
name: 'CombatLegend',
|
|
951
|
+
score: 7600,
|
|
952
|
+
equipments: [
|
|
953
|
+
{ name: 'UMP45', quality: 'rare', level: 74 },
|
|
954
|
+
{ name: 'Level 2 Vest', quality: 'common', level: 67 },
|
|
955
|
+
{ name: 'Red Dot Sight', quality: 'common', level: 62 },
|
|
956
|
+
{ name: 'Extended Mag', quality: 'rare', level: 70 }
|
|
957
|
+
]
|
|
958
|
+
}
|
|
959
|
+
];
|
|
960
|
+
|
|
961
|
+
// Create a TreeMultiMap for player rankings
|
|
962
|
+
const playerRankings = new TreeMultiMap<number, Equipment, Player>(players, {
|
|
963
|
+
toEntryFn: ({ score, equipments }) => [score, equipments],
|
|
964
|
+
isMapMode: false
|
|
965
|
+
});
|
|
966
|
+
|
|
967
|
+
const topPlayersEquipments = playerRankings.rangeSearch([8900, 10000], node => playerRankings.get(node));
|
|
968
|
+
expect(topPlayersEquipments).toEqual([
|
|
969
|
+
[
|
|
970
|
+
{
|
|
971
|
+
name: 'MK14',
|
|
972
|
+
quality: 'legendary',
|
|
973
|
+
level: 92
|
|
974
|
+
},
|
|
975
|
+
{ name: 'Level 3 Backpack', quality: 'legendary', level: 85 },
|
|
976
|
+
{
|
|
977
|
+
name: 'Scope 8x',
|
|
978
|
+
quality: 'epic',
|
|
979
|
+
level: 80
|
|
980
|
+
},
|
|
981
|
+
{ name: 'Suppressor', quality: 'legendary', level: 88 },
|
|
982
|
+
{
|
|
983
|
+
name: 'Tactical Stock',
|
|
984
|
+
quality: 'rare',
|
|
985
|
+
level: 75
|
|
986
|
+
}
|
|
987
|
+
],
|
|
988
|
+
[
|
|
989
|
+
{ name: 'KAR98K', quality: 'legendary', level: 90 },
|
|
990
|
+
{
|
|
991
|
+
name: 'Level 3 Vest',
|
|
992
|
+
quality: 'legendary',
|
|
993
|
+
level: 85
|
|
994
|
+
},
|
|
995
|
+
{ name: 'Holographic Sight', quality: 'epic', level: 82 },
|
|
996
|
+
{
|
|
997
|
+
name: 'Suppressor',
|
|
998
|
+
quality: 'legendary',
|
|
999
|
+
level: 88
|
|
1000
|
+
},
|
|
1001
|
+
{ name: 'Level 3 Backpack', quality: 'epic', level: 80 }
|
|
1002
|
+
]
|
|
1003
|
+
]);
|
|
846
1004
|
});
|
|
847
1005
|
});
|
|
@@ -341,9 +341,9 @@ describe('Inherit from DirectedGraph and perform operations test2.', () => {
|
|
|
341
341
|
expect(distMap.get(vertex3)).toBe(35);
|
|
342
342
|
expect(distMap.get(vertex4)).toBe(14);
|
|
343
343
|
expect(distMap.get(vertex5)).toBe(70);
|
|
344
|
-
expect(distMap.get(vertex6)).toBe(
|
|
344
|
+
expect(distMap.get(vertex6)).toBe(Number.MAX_SAFE_INTEGER);
|
|
345
345
|
expect(distMap.get(vertex7)).toBe(61);
|
|
346
|
-
expect(distMap.get(vertex8)).toBe(
|
|
346
|
+
expect(distMap.get(vertex8)).toBe(Number.MAX_SAFE_INTEGER);
|
|
347
347
|
expect(distMap.get(vertex9)).toBe(19);
|
|
348
348
|
|
|
349
349
|
expect(preMap).toBeInstanceOf(Map);
|
|
@@ -351,7 +351,7 @@ describe('Inherit from DirectedGraph and perform operations test2.', () => {
|
|
|
351
351
|
|
|
352
352
|
expect(paths).toBeInstanceOf(Array);
|
|
353
353
|
expect(paths.length).toBe(0);
|
|
354
|
-
expect(min).toBe(
|
|
354
|
+
expect(min).toBe(Number.MAX_SAFE_INTEGER);
|
|
355
355
|
expect(minPath).toBeInstanceOf(Array);
|
|
356
356
|
|
|
357
357
|
const floydResult = myGraph.floydWarshall();
|
|
@@ -360,35 +360,35 @@ describe('Inherit from DirectedGraph and perform operations test2.', () => {
|
|
|
360
360
|
const { costs, predecessor } = floydResult;
|
|
361
361
|
expect(costs).toBeInstanceOf(Array);
|
|
362
362
|
expect(costs.length).toBe(9);
|
|
363
|
-
expect(costs[0]).toEqual([32, 12, 35, 14, 70,
|
|
364
|
-
expect(costs[1]).toEqual([20, 32, 23, 34, 58,
|
|
365
|
-
expect(costs[2]).toEqual([3, 15, 38, 17, 35,
|
|
366
|
-
expect(costs[3]).toEqual([123, 135, 120, 137, 155,
|
|
367
|
-
expect(costs[4]).toEqual([133, 145, 130, 147, 165,
|
|
363
|
+
expect(costs[0]).toEqual([32, 12, 35, 14, 70, Number.MAX_SAFE_INTEGER, 61, Number.MAX_SAFE_INTEGER, 19]);
|
|
364
|
+
expect(costs[1]).toEqual([20, 32, 23, 34, 58, Number.MAX_SAFE_INTEGER, 81, Number.MAX_SAFE_INTEGER, 39]);
|
|
365
|
+
expect(costs[2]).toEqual([3, 15, 38, 17, 35, Number.MAX_SAFE_INTEGER, 64, Number.MAX_SAFE_INTEGER, 22]);
|
|
366
|
+
expect(costs[3]).toEqual([123, 135, 120, 137, 155, Number.MAX_SAFE_INTEGER, 47, Number.MAX_SAFE_INTEGER, 126]);
|
|
367
|
+
expect(costs[4]).toEqual([133, 145, 130, 147, 165, Number.MAX_SAFE_INTEGER, 57, Number.MAX_SAFE_INTEGER, 136]);
|
|
368
368
|
expect(costs[5]).toEqual([
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
369
|
+
Number.MAX_SAFE_INTEGER,
|
|
370
|
+
Number.MAX_SAFE_INTEGER,
|
|
371
|
+
Number.MAX_SAFE_INTEGER,
|
|
372
|
+
Number.MAX_SAFE_INTEGER,
|
|
373
|
+
Number.MAX_SAFE_INTEGER,
|
|
374
|
+
Number.MAX_SAFE_INTEGER,
|
|
375
|
+
Number.MAX_SAFE_INTEGER,
|
|
376
|
+
Number.MAX_SAFE_INTEGER,
|
|
377
|
+
Number.MAX_SAFE_INTEGER
|
|
378
378
|
]);
|
|
379
|
-
expect(costs[6]).toEqual([76, 88, 73, 90, 108,
|
|
379
|
+
expect(costs[6]).toEqual([76, 88, 73, 90, 108, Number.MAX_SAFE_INTEGER, 137, Number.MAX_SAFE_INTEGER, 79]);
|
|
380
380
|
expect(costs[7]).toEqual([
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
381
|
+
Number.MAX_SAFE_INTEGER,
|
|
382
|
+
Number.MAX_SAFE_INTEGER,
|
|
383
|
+
Number.MAX_SAFE_INTEGER,
|
|
384
|
+
Number.MAX_SAFE_INTEGER,
|
|
385
|
+
Number.MAX_SAFE_INTEGER,
|
|
386
|
+
Number.MAX_SAFE_INTEGER,
|
|
387
|
+
Number.MAX_SAFE_INTEGER,
|
|
388
|
+
Number.MAX_SAFE_INTEGER,
|
|
389
|
+
Number.MAX_SAFE_INTEGER
|
|
390
390
|
]);
|
|
391
|
-
expect(costs[8]).toEqual([173, 185, 170, 187, 205,
|
|
391
|
+
expect(costs[8]).toEqual([173, 185, 170, 187, 205, Number.MAX_SAFE_INTEGER, 97, Number.MAX_SAFE_INTEGER, 176]);
|
|
392
392
|
|
|
393
393
|
expect(predecessor).toBeInstanceOf(Array);
|
|
394
394
|
expect(predecessor.length).toBe(9);
|
|
@@ -458,12 +458,12 @@ describe('Inherit from DirectedGraph and perform operations test2.', () => {
|
|
|
458
458
|
expect(distMap.size).toBe(9);
|
|
459
459
|
expect(distMap.get(vertex1)).toBe(0);
|
|
460
460
|
expect(distMap.get(vertex2)).toBe(12);
|
|
461
|
-
expect(distMap.get(vertex3)).toBe(
|
|
461
|
+
expect(distMap.get(vertex3)).toBe(Number.MAX_SAFE_INTEGER);
|
|
462
462
|
expect(distMap.get(vertex4)).toBe(14);
|
|
463
|
-
expect(distMap.get(vertex5)).toBe(
|
|
464
|
-
expect(distMap.get(vertex6)).toBe(
|
|
465
|
-
expect(distMap.get(vertex7)).toBe(
|
|
466
|
-
expect(distMap.get(vertex8)).toBe(
|
|
463
|
+
expect(distMap.get(vertex5)).toBe(Number.MAX_SAFE_INTEGER);
|
|
464
|
+
expect(distMap.get(vertex6)).toBe(Number.MAX_SAFE_INTEGER);
|
|
465
|
+
expect(distMap.get(vertex7)).toBe(Number.MAX_SAFE_INTEGER);
|
|
466
|
+
expect(distMap.get(vertex8)).toBe(Number.MAX_SAFE_INTEGER);
|
|
467
467
|
expect(distMap.get(vertex9)).toBe(19);
|
|
468
468
|
|
|
469
469
|
expect(minDist).toBe(12);
|
|
@@ -512,9 +512,9 @@ describe('Inherit from DirectedGraph and perform operations test2.', () => {
|
|
|
512
512
|
expect(distMap.get(vertex3)).toBe(35);
|
|
513
513
|
expect(distMap.get(vertex4)).toBe(14);
|
|
514
514
|
expect(distMap.get(vertex5)).toBe(70);
|
|
515
|
-
expect(distMap.get(vertex6)).toBe(
|
|
515
|
+
expect(distMap.get(vertex6)).toBe(Number.MAX_SAFE_INTEGER);
|
|
516
516
|
expect(distMap.get(vertex7)).toBe(61);
|
|
517
|
-
expect(distMap.get(vertex8)).toBe(
|
|
517
|
+
expect(distMap.get(vertex8)).toBe(Number.MAX_SAFE_INTEGER);
|
|
518
518
|
expect(distMap.get(vertex9)).toBe(19);
|
|
519
519
|
|
|
520
520
|
expect(minDist).toBe(12);
|
|
@@ -574,9 +574,9 @@ describe('Inherit from DirectedGraph and perform operations test2.', () => {
|
|
|
574
574
|
expect(distMap.get(vertex3)).toBe(35);
|
|
575
575
|
expect(distMap.get(vertex4)).toBe(14);
|
|
576
576
|
expect(distMap.get(vertex5)).toBe(70);
|
|
577
|
-
expect(distMap.get(vertex6)).toBe(
|
|
577
|
+
expect(distMap.get(vertex6)).toBe(Number.MAX_SAFE_INTEGER);
|
|
578
578
|
expect(distMap.get(vertex7)).toBe(61);
|
|
579
|
-
expect(distMap.get(vertex8)).toBe(
|
|
579
|
+
expect(distMap.get(vertex8)).toBe(Number.MAX_SAFE_INTEGER);
|
|
580
580
|
expect(distMap.get(vertex9)).toBe(19);
|
|
581
581
|
|
|
582
582
|
expect(minDist).toBe(12);
|
|
@@ -264,7 +264,7 @@ describe('cycles, strongly connected components, bridges, articular points in Un
|
|
|
264
264
|
expect(lowMap.size).toBe(8);
|
|
265
265
|
});
|
|
266
266
|
|
|
267
|
-
it('Should return
|
|
267
|
+
it('Should return Number.MAX_SAFE_INTEGER if dest is not found', () => {
|
|
268
268
|
const graph = new UndirectedGraph<string>();
|
|
269
269
|
|
|
270
270
|
for (let i = 0; i < 3; ++i) {
|
|
@@ -274,7 +274,7 @@ it('Should return Infinity if dest is not found', () => {
|
|
|
274
274
|
graph.addEdge(0, 1, 1);
|
|
275
275
|
|
|
276
276
|
const minCost02 = graph.getMinCostBetween(0, 2, true);
|
|
277
|
-
expect(minCost02).toBe(
|
|
277
|
+
expect(minCost02).toBe(Number.MAX_SAFE_INTEGER);
|
|
278
278
|
|
|
279
279
|
const minCost01 = graph.getMinCostBetween(0, 1, true);
|
|
280
280
|
expect(minCost01).toBe(1);
|