graph-typed 2.5.0 → 2.5.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/dist/cjs/index.cjs +1314 -227
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +1297 -210
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +1314 -228
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +1297 -211
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/common/error.d.ts +9 -0
- package/dist/types/common/index.d.ts +1 -1
- package/dist/types/data-structures/base/index.d.ts +1 -0
- package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
- package/dist/types/data-structures/base/linear-base.d.ts +3 -3
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +288 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +336 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +618 -18
- package/dist/types/data-structures/binary-tree/bst.d.ts +676 -1
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +456 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +144 -1
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +3307 -399
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +3285 -360
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2674 -325
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +3072 -287
- package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
- package/dist/types/data-structures/graph/directed-graph.d.ts +240 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +216 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +274 -10
- package/dist/types/data-structures/heap/heap.d.ts +336 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +411 -3
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +363 -3
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +434 -2
- package/dist/types/data-structures/matrix/matrix.d.ts +192 -0
- package/dist/types/data-structures/queue/deque.d.ts +364 -4
- package/dist/types/data-structures/queue/queue.d.ts +288 -0
- package/dist/types/data-structures/stack/stack.d.ts +240 -0
- package/dist/types/data-structures/trie/trie.d.ts +292 -4
- package/dist/types/interfaces/graph.d.ts +1 -1
- package/dist/types/types/common.d.ts +2 -2
- package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
- package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
- package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
- package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
- package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
- package/dist/types/types/utils/validate-type.d.ts +4 -4
- package/dist/umd/graph-typed.js +1291 -205
- package/dist/umd/graph-typed.js.map +1 -1
- package/dist/umd/graph-typed.min.js +3 -3
- package/dist/umd/graph-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/common/error.ts +19 -1
- package/src/common/index.ts +1 -1
- package/src/data-structures/base/index.ts +1 -0
- package/src/data-structures/base/iterable-element-base.ts +3 -2
- package/src/data-structures/base/iterable-entry-base.ts +8 -8
- package/src/data-structures/base/linear-base.ts +3 -3
- package/src/data-structures/binary-tree/avl-tree.ts +299 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +341 -5
- package/src/data-structures/binary-tree/binary-tree.ts +606 -6
- package/src/data-structures/binary-tree/bst.ts +946 -7
- package/src/data-structures/binary-tree/red-black-tree.ts +472 -0
- package/src/data-structures/binary-tree/segment-tree.ts +145 -2
- package/src/data-structures/binary-tree/tree-map.ts +3423 -499
- package/src/data-structures/binary-tree/tree-multi-map.ts +3537 -596
- package/src/data-structures/binary-tree/tree-multi-set.ts +2855 -495
- package/src/data-structures/binary-tree/tree-set.ts +3209 -413
- package/src/data-structures/graph/abstract-graph.ts +6 -6
- package/src/data-structures/graph/directed-graph.ts +240 -0
- package/src/data-structures/graph/undirected-graph.ts +216 -0
- package/src/data-structures/hash/hash-map.ts +281 -19
- package/src/data-structures/heap/heap.ts +340 -4
- package/src/data-structures/heap/max-heap.ts +2 -2
- package/src/data-structures/linked-list/doubly-linked-list.ts +411 -3
- package/src/data-structures/linked-list/singly-linked-list.ts +363 -3
- package/src/data-structures/linked-list/skip-linked-list.ts +439 -7
- package/src/data-structures/matrix/matrix.ts +202 -10
- package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
- package/src/data-structures/queue/deque.ts +365 -5
- package/src/data-structures/queue/queue.ts +288 -0
- package/src/data-structures/stack/stack.ts +240 -0
- package/src/data-structures/trie/trie.ts +295 -7
- package/src/interfaces/graph.ts +1 -1
- package/src/types/common.ts +2 -2
- package/src/types/data-structures/binary-tree/bst.ts +1 -0
- package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
- package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
- package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
- package/src/types/data-structures/heap/heap.ts +1 -0
- package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
- package/src/types/utils/validate-type.ts +4 -4
package/dist/umd/graph-typed.js
CHANGED
|
@@ -37,7 +37,8 @@ var graphTyped = (() => {
|
|
|
37
37
|
Range: () => Range,
|
|
38
38
|
UndirectedEdge: () => UndirectedEdge,
|
|
39
39
|
UndirectedGraph: () => UndirectedGraph,
|
|
40
|
-
UndirectedVertex: () => UndirectedVertex
|
|
40
|
+
UndirectedVertex: () => UndirectedVertex,
|
|
41
|
+
raise: () => raise
|
|
41
42
|
});
|
|
42
43
|
|
|
43
44
|
// src/utils/utils.ts
|
|
@@ -62,6 +63,9 @@ var graphTyped = (() => {
|
|
|
62
63
|
};
|
|
63
64
|
|
|
64
65
|
// src/common/error.ts
|
|
66
|
+
function raise(ErrorClass, message) {
|
|
67
|
+
throw new ErrorClass(message);
|
|
68
|
+
}
|
|
65
69
|
var ERR = {
|
|
66
70
|
// Range / index
|
|
67
71
|
indexOutOfRange: (index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`,
|
|
@@ -83,7 +87,9 @@ var graphTyped = (() => {
|
|
|
83
87
|
matrixSingular: () => "Matrix: Singular matrix, inverse does not exist.",
|
|
84
88
|
matrixNotSquare: () => "Matrix: Must be square for inversion.",
|
|
85
89
|
matrixNotRectangular: () => "Matrix: Must be rectangular for transposition.",
|
|
86
|
-
matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}
|
|
90
|
+
matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`,
|
|
91
|
+
// Order statistic
|
|
92
|
+
orderStatisticNotEnabled: (method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`
|
|
87
93
|
};
|
|
88
94
|
|
|
89
95
|
// src/common/index.ts
|
|
@@ -308,7 +314,7 @@ var graphTyped = (() => {
|
|
|
308
314
|
if (options) {
|
|
309
315
|
const { toElementFn } = options;
|
|
310
316
|
if (typeof toElementFn === "function") this._toElementFn = toElementFn;
|
|
311
|
-
else if (toElementFn)
|
|
317
|
+
else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
|
|
312
318
|
}
|
|
313
319
|
}
|
|
314
320
|
/**
|
|
@@ -464,7 +470,7 @@ var graphTyped = (() => {
|
|
|
464
470
|
acc = initialValue;
|
|
465
471
|
} else {
|
|
466
472
|
const first = iter.next();
|
|
467
|
-
if (first.done)
|
|
473
|
+
if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
|
|
468
474
|
acc = first.value;
|
|
469
475
|
index = 1;
|
|
470
476
|
}
|
|
@@ -506,6 +512,196 @@ var graphTyped = (() => {
|
|
|
506
512
|
}
|
|
507
513
|
};
|
|
508
514
|
|
|
515
|
+
// src/data-structures/base/linear-base.ts
|
|
516
|
+
var LinearBase = class _LinearBase extends IterableElementBase {
|
|
517
|
+
/**
|
|
518
|
+
* Construct a linear container with runtime options.
|
|
519
|
+
* @param options - `{ maxLen?, ... }` bounds/behavior options.
|
|
520
|
+
* @remarks Time O(1), Space O(1)
|
|
521
|
+
*/
|
|
522
|
+
constructor(options) {
|
|
523
|
+
super(options);
|
|
524
|
+
__publicField(this, "_maxLen", -1);
|
|
525
|
+
if (options) {
|
|
526
|
+
const { maxLen } = options;
|
|
527
|
+
if (typeof maxLen === "number" && maxLen > 0 && maxLen % 1 === 0) this._maxLen = maxLen;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Upper bound for length (if positive), or `-1` when unbounded.
|
|
532
|
+
* @returns Maximum allowed length.
|
|
533
|
+
* @remarks Time O(1), Space O(1)
|
|
534
|
+
*/
|
|
535
|
+
get maxLen() {
|
|
536
|
+
return this._maxLen;
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* First index of a value from the left.
|
|
540
|
+
* @param searchElement - Value to match.
|
|
541
|
+
* @param fromIndex - Start position (supports negative index).
|
|
542
|
+
* @returns Index or `-1` if not found.
|
|
543
|
+
* @remarks Time O(n), Space O(1)
|
|
544
|
+
*/
|
|
545
|
+
indexOf(searchElement, fromIndex = 0) {
|
|
546
|
+
if (this.length === 0) return -1;
|
|
547
|
+
if (fromIndex < 0) fromIndex = this.length + fromIndex;
|
|
548
|
+
if (fromIndex < 0) fromIndex = 0;
|
|
549
|
+
for (let i = fromIndex; i < this.length; i++) {
|
|
550
|
+
const element = this.at(i);
|
|
551
|
+
if (element === searchElement) return i;
|
|
552
|
+
}
|
|
553
|
+
return -1;
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Last index of a value from the right.
|
|
557
|
+
* @param searchElement - Value to match.
|
|
558
|
+
* @param fromIndex - Start position (supports negative index).
|
|
559
|
+
* @returns Index or `-1` if not found.
|
|
560
|
+
* @remarks Time O(n), Space O(1)
|
|
561
|
+
*/
|
|
562
|
+
lastIndexOf(searchElement, fromIndex = this.length - 1) {
|
|
563
|
+
if (this.length === 0) return -1;
|
|
564
|
+
if (fromIndex >= this.length) fromIndex = this.length - 1;
|
|
565
|
+
if (fromIndex < 0) fromIndex = this.length + fromIndex;
|
|
566
|
+
for (let i = fromIndex; i >= 0; i--) {
|
|
567
|
+
const element = this.at(i);
|
|
568
|
+
if (element === searchElement) return i;
|
|
569
|
+
}
|
|
570
|
+
return -1;
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Find the first index matching a predicate.
|
|
574
|
+
* @param predicate - `(element, index, self) => boolean`.
|
|
575
|
+
* @param thisArg - Optional `this` for callback.
|
|
576
|
+
* @returns Index or `-1`.
|
|
577
|
+
* @remarks Time O(n), Space O(1)
|
|
578
|
+
*/
|
|
579
|
+
findIndex(predicate, thisArg) {
|
|
580
|
+
for (let i = 0; i < this.length; i++) {
|
|
581
|
+
const item = this.at(i);
|
|
582
|
+
if (item !== void 0 && predicate.call(thisArg, item, i, this)) return i;
|
|
583
|
+
}
|
|
584
|
+
return -1;
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Concatenate elements and/or containers.
|
|
588
|
+
* @param items - Elements or other containers.
|
|
589
|
+
* @returns New container with combined elements (`this` type).
|
|
590
|
+
* @remarks Time O(sum(length)), Space O(sum(length))
|
|
591
|
+
*/
|
|
592
|
+
concat(...items) {
|
|
593
|
+
const newList = this.clone();
|
|
594
|
+
for (const item of items) {
|
|
595
|
+
if (item instanceof _LinearBase) {
|
|
596
|
+
newList.pushMany(item);
|
|
597
|
+
} else {
|
|
598
|
+
newList.push(item);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
return newList;
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* In-place stable order via array sort semantics.
|
|
605
|
+
* @param compareFn - Comparator `(a, b) => number`.
|
|
606
|
+
* @returns This container.
|
|
607
|
+
* @remarks Time O(n log n), Space O(n) (materializes to array temporarily)
|
|
608
|
+
*/
|
|
609
|
+
sort(compareFn) {
|
|
610
|
+
const arr = this.toArray();
|
|
611
|
+
arr.sort(compareFn);
|
|
612
|
+
this.clear();
|
|
613
|
+
for (const item of arr) this.push(item);
|
|
614
|
+
return this;
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* Remove and/or insert elements at a position (array-compatible).
|
|
618
|
+
* @param start - Start index (supports negative index).
|
|
619
|
+
* @param deleteCount - How many to remove.
|
|
620
|
+
* @param items - Elements to insert.
|
|
621
|
+
* @returns Removed elements as a new list (`this` type).
|
|
622
|
+
* @remarks Time O(n + m), Space O(min(n, m)) where `m = items.length`
|
|
623
|
+
*/
|
|
624
|
+
splice(start, deleteCount = 0, ...items) {
|
|
625
|
+
const removedList = this._createInstance();
|
|
626
|
+
start = start < 0 ? this.length + start : start;
|
|
627
|
+
start = Math.max(0, Math.min(start, this.length));
|
|
628
|
+
deleteCount = Math.max(0, Math.min(deleteCount, this.length - start));
|
|
629
|
+
for (let i = 0; i < deleteCount; i++) {
|
|
630
|
+
const removed = this.deleteAt(start);
|
|
631
|
+
if (removed !== void 0) {
|
|
632
|
+
removedList.push(removed);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
for (let i = 0; i < items.length; i++) {
|
|
636
|
+
this.addAt(start + i, items[i]);
|
|
637
|
+
}
|
|
638
|
+
return removedList;
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Join all elements into a string.
|
|
642
|
+
* @param separator - Separator string.
|
|
643
|
+
* @returns Concatenated string.
|
|
644
|
+
* @remarks Time O(n), Space O(n)
|
|
645
|
+
*/
|
|
646
|
+
join(separator = ",") {
|
|
647
|
+
return this.toArray().join(separator);
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Snapshot elements into a reversed array.
|
|
651
|
+
* @returns New reversed array.
|
|
652
|
+
* @remarks Time O(n), Space O(n)
|
|
653
|
+
*/
|
|
654
|
+
toReversedArray() {
|
|
655
|
+
const array = [];
|
|
656
|
+
for (let i = this.length - 1; i >= 0; i--) {
|
|
657
|
+
array.push(this.at(i));
|
|
658
|
+
}
|
|
659
|
+
return array;
|
|
660
|
+
}
|
|
661
|
+
reduceRight(callbackfn, initialValue) {
|
|
662
|
+
let accumulator = initialValue != null ? initialValue : 0;
|
|
663
|
+
for (let i = this.length - 1; i >= 0; i--) {
|
|
664
|
+
accumulator = callbackfn(accumulator, this.at(i), i, this);
|
|
665
|
+
}
|
|
666
|
+
return accumulator;
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Create a shallow copy of a subrange.
|
|
670
|
+
* @param start - Inclusive start (supports negative index).
|
|
671
|
+
* @param end - Exclusive end (supports negative index).
|
|
672
|
+
* @returns New list with the range (`this` type).
|
|
673
|
+
* @remarks Time O(n), Space O(n)
|
|
674
|
+
*/
|
|
675
|
+
slice(start = 0, end = this.length) {
|
|
676
|
+
start = start < 0 ? this.length + start : start;
|
|
677
|
+
end = end < 0 ? this.length + end : end;
|
|
678
|
+
const newList = this._createInstance();
|
|
679
|
+
for (let i = start; i < end; i++) {
|
|
680
|
+
newList.push(this.at(i));
|
|
681
|
+
}
|
|
682
|
+
return newList;
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Fill a range with a value.
|
|
686
|
+
* @param value - Value to set.
|
|
687
|
+
* @param start - Inclusive start.
|
|
688
|
+
* @param end - Exclusive end.
|
|
689
|
+
* @returns This list.
|
|
690
|
+
* @remarks Time O(n), Space O(1)
|
|
691
|
+
*/
|
|
692
|
+
fill(value, start = 0, end = this.length) {
|
|
693
|
+
start = start < 0 ? this.length + start : start;
|
|
694
|
+
end = end < 0 ? this.length + end : end;
|
|
695
|
+
if (start < 0) start = 0;
|
|
696
|
+
if (end > this.length) end = this.length;
|
|
697
|
+
if (start >= end) return this;
|
|
698
|
+
for (let i = start; i < end; i++) {
|
|
699
|
+
this.setAt(i, value);
|
|
700
|
+
}
|
|
701
|
+
return this;
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
|
|
509
705
|
// src/data-structures/heap/heap.ts
|
|
510
706
|
var Heap = class _Heap extends IterableElementBase {
|
|
511
707
|
/**
|
|
@@ -521,7 +717,7 @@ var graphTyped = (() => {
|
|
|
521
717
|
__publicField(this, "_elements", []);
|
|
522
718
|
__publicField(this, "_DEFAULT_COMPARATOR", (a, b) => {
|
|
523
719
|
if (typeof a === "object" || typeof b === "object") {
|
|
524
|
-
|
|
720
|
+
raise(TypeError, ERR.comparatorRequired("Heap"));
|
|
525
721
|
}
|
|
526
722
|
if (a > b) return 1;
|
|
527
723
|
if (a < b) return -1;
|
|
@@ -557,6 +753,30 @@ var graphTyped = (() => {
|
|
|
557
753
|
|
|
558
754
|
|
|
559
755
|
|
|
756
|
+
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
|
|
773
|
+
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
|
|
779
|
+
|
|
560
780
|
* @example
|
|
561
781
|
* // Track heap capacity
|
|
562
782
|
* const heap = new Heap<number>();
|
|
@@ -620,6 +840,30 @@ var graphTyped = (() => {
|
|
|
620
840
|
|
|
621
841
|
|
|
622
842
|
|
|
843
|
+
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
|
|
847
|
+
|
|
848
|
+
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
|
|
852
|
+
|
|
853
|
+
|
|
854
|
+
|
|
855
|
+
|
|
856
|
+
|
|
857
|
+
|
|
858
|
+
|
|
859
|
+
|
|
860
|
+
|
|
861
|
+
|
|
862
|
+
|
|
863
|
+
|
|
864
|
+
|
|
865
|
+
|
|
866
|
+
|
|
623
867
|
* @example
|
|
624
868
|
* // basic Heap creation and add operation
|
|
625
869
|
* // Create a min heap (default)
|
|
@@ -653,6 +897,30 @@ var graphTyped = (() => {
|
|
|
653
897
|
|
|
654
898
|
|
|
655
899
|
|
|
900
|
+
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
|
|
909
|
+
|
|
910
|
+
|
|
911
|
+
|
|
912
|
+
|
|
913
|
+
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
|
|
917
|
+
|
|
918
|
+
|
|
919
|
+
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
|
|
923
|
+
|
|
656
924
|
* @example
|
|
657
925
|
* // Add multiple elements
|
|
658
926
|
* const heap = new Heap<number>([], { comparator: (a, b) => a - b });
|
|
@@ -688,6 +956,30 @@ var graphTyped = (() => {
|
|
|
688
956
|
|
|
689
957
|
|
|
690
958
|
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
|
|
965
|
+
|
|
966
|
+
|
|
967
|
+
|
|
968
|
+
|
|
969
|
+
|
|
970
|
+
|
|
971
|
+
|
|
972
|
+
|
|
973
|
+
|
|
974
|
+
|
|
975
|
+
|
|
976
|
+
|
|
977
|
+
|
|
978
|
+
|
|
979
|
+
|
|
980
|
+
|
|
981
|
+
|
|
982
|
+
|
|
691
983
|
* @example
|
|
692
984
|
* // Heap with custom comparator (MaxHeap behavior)
|
|
693
985
|
* interface Task {
|
|
@@ -739,6 +1031,30 @@ var graphTyped = (() => {
|
|
|
739
1031
|
|
|
740
1032
|
|
|
741
1033
|
|
|
1034
|
+
|
|
1035
|
+
|
|
1036
|
+
|
|
1037
|
+
|
|
1038
|
+
|
|
1039
|
+
|
|
1040
|
+
|
|
1041
|
+
|
|
1042
|
+
|
|
1043
|
+
|
|
1044
|
+
|
|
1045
|
+
|
|
1046
|
+
|
|
1047
|
+
|
|
1048
|
+
|
|
1049
|
+
|
|
1050
|
+
|
|
1051
|
+
|
|
1052
|
+
|
|
1053
|
+
|
|
1054
|
+
|
|
1055
|
+
|
|
1056
|
+
|
|
1057
|
+
|
|
742
1058
|
* @example
|
|
743
1059
|
* // Heap for event processing with priority
|
|
744
1060
|
* interface Event {
|
|
@@ -815,6 +1131,30 @@ var graphTyped = (() => {
|
|
|
815
1131
|
|
|
816
1132
|
|
|
817
1133
|
|
|
1134
|
+
|
|
1135
|
+
|
|
1136
|
+
|
|
1137
|
+
|
|
1138
|
+
|
|
1139
|
+
|
|
1140
|
+
|
|
1141
|
+
|
|
1142
|
+
|
|
1143
|
+
|
|
1144
|
+
|
|
1145
|
+
|
|
1146
|
+
|
|
1147
|
+
|
|
1148
|
+
|
|
1149
|
+
|
|
1150
|
+
|
|
1151
|
+
|
|
1152
|
+
|
|
1153
|
+
|
|
1154
|
+
|
|
1155
|
+
|
|
1156
|
+
|
|
1157
|
+
|
|
818
1158
|
* @example
|
|
819
1159
|
* // Check if heap is empty
|
|
820
1160
|
* const heap = new Heap<number>([], { comparator: (a, b) => a - b });
|
|
@@ -838,6 +1178,30 @@ var graphTyped = (() => {
|
|
|
838
1178
|
|
|
839
1179
|
|
|
840
1180
|
|
|
1181
|
+
|
|
1182
|
+
|
|
1183
|
+
|
|
1184
|
+
|
|
1185
|
+
|
|
1186
|
+
|
|
1187
|
+
|
|
1188
|
+
|
|
1189
|
+
|
|
1190
|
+
|
|
1191
|
+
|
|
1192
|
+
|
|
1193
|
+
|
|
1194
|
+
|
|
1195
|
+
|
|
1196
|
+
|
|
1197
|
+
|
|
1198
|
+
|
|
1199
|
+
|
|
1200
|
+
|
|
1201
|
+
|
|
1202
|
+
|
|
1203
|
+
|
|
1204
|
+
|
|
841
1205
|
* @example
|
|
842
1206
|
* // Remove all elements
|
|
843
1207
|
* const heap = new Heap<number>([1, 2, 3], { comparator: (a, b) => a - b });
|
|
@@ -864,6 +1228,30 @@ var graphTyped = (() => {
|
|
|
864
1228
|
* @returns True if found.
|
|
865
1229
|
|
|
866
1230
|
|
|
1231
|
+
|
|
1232
|
+
|
|
1233
|
+
|
|
1234
|
+
|
|
1235
|
+
|
|
1236
|
+
|
|
1237
|
+
|
|
1238
|
+
|
|
1239
|
+
|
|
1240
|
+
|
|
1241
|
+
|
|
1242
|
+
|
|
1243
|
+
|
|
1244
|
+
|
|
1245
|
+
|
|
1246
|
+
|
|
1247
|
+
|
|
1248
|
+
|
|
1249
|
+
|
|
1250
|
+
|
|
1251
|
+
|
|
1252
|
+
|
|
1253
|
+
|
|
1254
|
+
|
|
867
1255
|
* @example
|
|
868
1256
|
* // Check element existence
|
|
869
1257
|
* const heap = new Heap<number>([3, 1, 2], { comparator: (a, b) => a - b });
|
|
@@ -887,6 +1275,30 @@ var graphTyped = (() => {
|
|
|
887
1275
|
|
|
888
1276
|
|
|
889
1277
|
|
|
1278
|
+
|
|
1279
|
+
|
|
1280
|
+
|
|
1281
|
+
|
|
1282
|
+
|
|
1283
|
+
|
|
1284
|
+
|
|
1285
|
+
|
|
1286
|
+
|
|
1287
|
+
|
|
1288
|
+
|
|
1289
|
+
|
|
1290
|
+
|
|
1291
|
+
|
|
1292
|
+
|
|
1293
|
+
|
|
1294
|
+
|
|
1295
|
+
|
|
1296
|
+
|
|
1297
|
+
|
|
1298
|
+
|
|
1299
|
+
|
|
1300
|
+
|
|
1301
|
+
|
|
890
1302
|
* @example
|
|
891
1303
|
* // Remove specific element
|
|
892
1304
|
* const heap = new Heap<number>([3, 1, 4, 1, 5], { comparator: (a, b) => a - b });
|
|
@@ -956,6 +1368,30 @@ var graphTyped = (() => {
|
|
|
956
1368
|
* @returns Array of visited elements.
|
|
957
1369
|
|
|
958
1370
|
|
|
1371
|
+
|
|
1372
|
+
|
|
1373
|
+
|
|
1374
|
+
|
|
1375
|
+
|
|
1376
|
+
|
|
1377
|
+
|
|
1378
|
+
|
|
1379
|
+
|
|
1380
|
+
|
|
1381
|
+
|
|
1382
|
+
|
|
1383
|
+
|
|
1384
|
+
|
|
1385
|
+
|
|
1386
|
+
|
|
1387
|
+
|
|
1388
|
+
|
|
1389
|
+
|
|
1390
|
+
|
|
1391
|
+
|
|
1392
|
+
|
|
1393
|
+
|
|
1394
|
+
|
|
959
1395
|
* @example
|
|
960
1396
|
* // Depth-first traversal
|
|
961
1397
|
* const heap = new Heap<number>([3, 1, 2], { comparator: (a, b) => a - b });
|
|
@@ -1012,6 +1448,30 @@ var graphTyped = (() => {
|
|
|
1012
1448
|
|
|
1013
1449
|
|
|
1014
1450
|
|
|
1451
|
+
|
|
1452
|
+
|
|
1453
|
+
|
|
1454
|
+
|
|
1455
|
+
|
|
1456
|
+
|
|
1457
|
+
|
|
1458
|
+
|
|
1459
|
+
|
|
1460
|
+
|
|
1461
|
+
|
|
1462
|
+
|
|
1463
|
+
|
|
1464
|
+
|
|
1465
|
+
|
|
1466
|
+
|
|
1467
|
+
|
|
1468
|
+
|
|
1469
|
+
|
|
1470
|
+
|
|
1471
|
+
|
|
1472
|
+
|
|
1473
|
+
|
|
1474
|
+
|
|
1015
1475
|
* @example
|
|
1016
1476
|
* // Sort elements using heap
|
|
1017
1477
|
* const heap = new Heap<number>([5, 1, 3, 2, 4]);
|
|
@@ -1041,6 +1501,30 @@ var graphTyped = (() => {
|
|
|
1041
1501
|
|
|
1042
1502
|
|
|
1043
1503
|
|
|
1504
|
+
|
|
1505
|
+
|
|
1506
|
+
|
|
1507
|
+
|
|
1508
|
+
|
|
1509
|
+
|
|
1510
|
+
|
|
1511
|
+
|
|
1512
|
+
|
|
1513
|
+
|
|
1514
|
+
|
|
1515
|
+
|
|
1516
|
+
|
|
1517
|
+
|
|
1518
|
+
|
|
1519
|
+
|
|
1520
|
+
|
|
1521
|
+
|
|
1522
|
+
|
|
1523
|
+
|
|
1524
|
+
|
|
1525
|
+
|
|
1526
|
+
|
|
1527
|
+
|
|
1044
1528
|
* @example
|
|
1045
1529
|
* // Create independent copy
|
|
1046
1530
|
* const heap = new Heap<number>([3, 1, 4], { comparator: (a, b) => a - b });
|
|
@@ -1069,6 +1553,30 @@ var graphTyped = (() => {
|
|
|
1069
1553
|
|
|
1070
1554
|
|
|
1071
1555
|
|
|
1556
|
+
|
|
1557
|
+
|
|
1558
|
+
|
|
1559
|
+
|
|
1560
|
+
|
|
1561
|
+
|
|
1562
|
+
|
|
1563
|
+
|
|
1564
|
+
|
|
1565
|
+
|
|
1566
|
+
|
|
1567
|
+
|
|
1568
|
+
|
|
1569
|
+
|
|
1570
|
+
|
|
1571
|
+
|
|
1572
|
+
|
|
1573
|
+
|
|
1574
|
+
|
|
1575
|
+
|
|
1576
|
+
|
|
1577
|
+
|
|
1578
|
+
|
|
1579
|
+
|
|
1072
1580
|
* @example
|
|
1073
1581
|
* // Filter elements
|
|
1074
1582
|
* const heap = new Heap<number>([1, 2, 3, 4, 5], { comparator: (a, b) => a - b });
|
|
@@ -1104,6 +1612,30 @@ var graphTyped = (() => {
|
|
|
1104
1612
|
|
|
1105
1613
|
|
|
1106
1614
|
|
|
1615
|
+
|
|
1616
|
+
|
|
1617
|
+
|
|
1618
|
+
|
|
1619
|
+
|
|
1620
|
+
|
|
1621
|
+
|
|
1622
|
+
|
|
1623
|
+
|
|
1624
|
+
|
|
1625
|
+
|
|
1626
|
+
|
|
1627
|
+
|
|
1628
|
+
|
|
1629
|
+
|
|
1630
|
+
|
|
1631
|
+
|
|
1632
|
+
|
|
1633
|
+
|
|
1634
|
+
|
|
1635
|
+
|
|
1636
|
+
|
|
1637
|
+
|
|
1638
|
+
|
|
1107
1639
|
* @example
|
|
1108
1640
|
* // Transform elements
|
|
1109
1641
|
* const heap = new Heap<number>([1, 2, 3], { comparator: (a, b) => a - b });
|
|
@@ -1112,7 +1644,7 @@ var graphTyped = (() => {
|
|
|
1112
1644
|
*/
|
|
1113
1645
|
map(callback, options, thisArg) {
|
|
1114
1646
|
const { comparator, toElementFn, ...rest } = options != null ? options : {};
|
|
1115
|
-
if (!comparator)
|
|
1647
|
+
if (!comparator) raise(TypeError, ERR.comparatorRequired("Heap.map"));
|
|
1116
1648
|
const out = this._createLike([], { ...rest, comparator, toElementFn });
|
|
1117
1649
|
let i = 0;
|
|
1118
1650
|
for (const x of this) {
|
|
@@ -1201,205 +1733,15 @@ var graphTyped = (() => {
|
|
|
1201
1733
|
return new Ctor(elements, options);
|
|
1202
1734
|
}
|
|
1203
1735
|
/**
|
|
1204
|
-
* (Protected) Spawn an empty like-kind heap instance.
|
|
1205
|
-
* @remarks Time O(1), Space O(1)
|
|
1206
|
-
* @template EM
|
|
1207
|
-
* @template RM
|
|
1208
|
-
* @param [options] - Options forwarded to the constructor.
|
|
1209
|
-
* @returns An empty like-kind heap instance.
|
|
1210
|
-
*/
|
|
1211
|
-
_spawnLike(options) {
|
|
1212
|
-
return this._createLike([], options);
|
|
1213
|
-
}
|
|
1214
|
-
};
|
|
1215
|
-
|
|
1216
|
-
// src/data-structures/base/linear-base.ts
|
|
1217
|
-
var LinearBase = class _LinearBase extends IterableElementBase {
|
|
1218
|
-
/**
|
|
1219
|
-
* Construct a linear container with runtime options.
|
|
1220
|
-
* @param options - `{ maxLen?, ... }` bounds/behavior options.
|
|
1221
|
-
* @remarks Time O(1), Space O(1)
|
|
1222
|
-
*/
|
|
1223
|
-
constructor(options) {
|
|
1224
|
-
super(options);
|
|
1225
|
-
__publicField(this, "_maxLen", -1);
|
|
1226
|
-
if (options) {
|
|
1227
|
-
const { maxLen } = options;
|
|
1228
|
-
if (typeof maxLen === "number" && maxLen > 0 && maxLen % 1 === 0) this._maxLen = maxLen;
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
/**
|
|
1232
|
-
* Upper bound for length (if positive), or `-1` when unbounded.
|
|
1233
|
-
* @returns Maximum allowed length.
|
|
1234
|
-
* @remarks Time O(1), Space O(1)
|
|
1235
|
-
*/
|
|
1236
|
-
get maxLen() {
|
|
1237
|
-
return this._maxLen;
|
|
1238
|
-
}
|
|
1239
|
-
/**
|
|
1240
|
-
* First index of a value from the left.
|
|
1241
|
-
* @param searchElement - Value to match.
|
|
1242
|
-
* @param fromIndex - Start position (supports negative index).
|
|
1243
|
-
* @returns Index or `-1` if not found.
|
|
1244
|
-
* @remarks Time O(n), Space O(1)
|
|
1245
|
-
*/
|
|
1246
|
-
indexOf(searchElement, fromIndex = 0) {
|
|
1247
|
-
if (this.length === 0) return -1;
|
|
1248
|
-
if (fromIndex < 0) fromIndex = this.length + fromIndex;
|
|
1249
|
-
if (fromIndex < 0) fromIndex = 0;
|
|
1250
|
-
for (let i = fromIndex; i < this.length; i++) {
|
|
1251
|
-
const element = this.at(i);
|
|
1252
|
-
if (element === searchElement) return i;
|
|
1253
|
-
}
|
|
1254
|
-
return -1;
|
|
1255
|
-
}
|
|
1256
|
-
/**
|
|
1257
|
-
* Last index of a value from the right.
|
|
1258
|
-
* @param searchElement - Value to match.
|
|
1259
|
-
* @param fromIndex - Start position (supports negative index).
|
|
1260
|
-
* @returns Index or `-1` if not found.
|
|
1261
|
-
* @remarks Time O(n), Space O(1)
|
|
1262
|
-
*/
|
|
1263
|
-
lastIndexOf(searchElement, fromIndex = this.length - 1) {
|
|
1264
|
-
if (this.length === 0) return -1;
|
|
1265
|
-
if (fromIndex >= this.length) fromIndex = this.length - 1;
|
|
1266
|
-
if (fromIndex < 0) fromIndex = this.length + fromIndex;
|
|
1267
|
-
for (let i = fromIndex; i >= 0; i--) {
|
|
1268
|
-
const element = this.at(i);
|
|
1269
|
-
if (element === searchElement) return i;
|
|
1270
|
-
}
|
|
1271
|
-
return -1;
|
|
1272
|
-
}
|
|
1273
|
-
/**
|
|
1274
|
-
* Find the first index matching a predicate.
|
|
1275
|
-
* @param predicate - `(element, index, self) => boolean`.
|
|
1276
|
-
* @param thisArg - Optional `this` for callback.
|
|
1277
|
-
* @returns Index or `-1`.
|
|
1278
|
-
* @remarks Time O(n), Space O(1)
|
|
1279
|
-
*/
|
|
1280
|
-
findIndex(predicate, thisArg) {
|
|
1281
|
-
for (let i = 0; i < this.length; i++) {
|
|
1282
|
-
const item = this.at(i);
|
|
1283
|
-
if (item !== void 0 && predicate.call(thisArg, item, i, this)) return i;
|
|
1284
|
-
}
|
|
1285
|
-
return -1;
|
|
1286
|
-
}
|
|
1287
|
-
/**
|
|
1288
|
-
* Concatenate elements and/or containers.
|
|
1289
|
-
* @param items - Elements or other containers.
|
|
1290
|
-
* @returns New container with combined elements (`this` type).
|
|
1291
|
-
* @remarks Time O(sum(length)), Space O(sum(length))
|
|
1292
|
-
*/
|
|
1293
|
-
concat(...items) {
|
|
1294
|
-
const newList = this.clone();
|
|
1295
|
-
for (const item of items) {
|
|
1296
|
-
if (item instanceof _LinearBase) {
|
|
1297
|
-
newList.pushMany(item);
|
|
1298
|
-
} else {
|
|
1299
|
-
newList.push(item);
|
|
1300
|
-
}
|
|
1301
|
-
}
|
|
1302
|
-
return newList;
|
|
1303
|
-
}
|
|
1304
|
-
/**
|
|
1305
|
-
* In-place stable order via array sort semantics.
|
|
1306
|
-
* @param compareFn - Comparator `(a, b) => number`.
|
|
1307
|
-
* @returns This container.
|
|
1308
|
-
* @remarks Time O(n log n), Space O(n) (materializes to array temporarily)
|
|
1309
|
-
*/
|
|
1310
|
-
sort(compareFn) {
|
|
1311
|
-
const arr = this.toArray();
|
|
1312
|
-
arr.sort(compareFn);
|
|
1313
|
-
this.clear();
|
|
1314
|
-
for (const item of arr) this.push(item);
|
|
1315
|
-
return this;
|
|
1316
|
-
}
|
|
1317
|
-
/**
|
|
1318
|
-
* Remove and/or insert elements at a position (array-compatible).
|
|
1319
|
-
* @param start - Start index (supports negative index).
|
|
1320
|
-
* @param deleteCount - How many to remove.
|
|
1321
|
-
* @param items - Elements to insert.
|
|
1322
|
-
* @returns Removed elements as a new list (`this` type).
|
|
1323
|
-
* @remarks Time O(n + m), Space O(min(n, m)) where `m = items.length`
|
|
1324
|
-
*/
|
|
1325
|
-
splice(start, deleteCount = 0, ...items) {
|
|
1326
|
-
const removedList = this._createInstance();
|
|
1327
|
-
start = start < 0 ? this.length + start : start;
|
|
1328
|
-
start = Math.max(0, Math.min(start, this.length));
|
|
1329
|
-
deleteCount = Math.max(0, Math.min(deleteCount, this.length - start));
|
|
1330
|
-
for (let i = 0; i < deleteCount; i++) {
|
|
1331
|
-
const removed = this.deleteAt(start);
|
|
1332
|
-
if (removed !== void 0) {
|
|
1333
|
-
removedList.push(removed);
|
|
1334
|
-
}
|
|
1335
|
-
}
|
|
1336
|
-
for (let i = 0; i < items.length; i++) {
|
|
1337
|
-
this.addAt(start + i, items[i]);
|
|
1338
|
-
}
|
|
1339
|
-
return removedList;
|
|
1340
|
-
}
|
|
1341
|
-
/**
|
|
1342
|
-
* Join all elements into a string.
|
|
1343
|
-
* @param separator - Separator string.
|
|
1344
|
-
* @returns Concatenated string.
|
|
1345
|
-
* @remarks Time O(n), Space O(n)
|
|
1346
|
-
*/
|
|
1347
|
-
join(separator = ",") {
|
|
1348
|
-
return this.toArray().join(separator);
|
|
1349
|
-
}
|
|
1350
|
-
/**
|
|
1351
|
-
* Snapshot elements into a reversed array.
|
|
1352
|
-
* @returns New reversed array.
|
|
1353
|
-
* @remarks Time O(n), Space O(n)
|
|
1354
|
-
*/
|
|
1355
|
-
toReversedArray() {
|
|
1356
|
-
const array = [];
|
|
1357
|
-
for (let i = this.length - 1; i >= 0; i--) {
|
|
1358
|
-
array.push(this.at(i));
|
|
1359
|
-
}
|
|
1360
|
-
return array;
|
|
1361
|
-
}
|
|
1362
|
-
reduceRight(callbackfn, initialValue) {
|
|
1363
|
-
let accumulator = initialValue != null ? initialValue : 0;
|
|
1364
|
-
for (let i = this.length - 1; i >= 0; i--) {
|
|
1365
|
-
accumulator = callbackfn(accumulator, this.at(i), i, this);
|
|
1366
|
-
}
|
|
1367
|
-
return accumulator;
|
|
1368
|
-
}
|
|
1369
|
-
/**
|
|
1370
|
-
* Create a shallow copy of a subrange.
|
|
1371
|
-
* @param start - Inclusive start (supports negative index).
|
|
1372
|
-
* @param end - Exclusive end (supports negative index).
|
|
1373
|
-
* @returns New list with the range (`this` type).
|
|
1374
|
-
* @remarks Time O(n), Space O(n)
|
|
1375
|
-
*/
|
|
1376
|
-
slice(start = 0, end = this.length) {
|
|
1377
|
-
start = start < 0 ? this.length + start : start;
|
|
1378
|
-
end = end < 0 ? this.length + end : end;
|
|
1379
|
-
const newList = this._createInstance();
|
|
1380
|
-
for (let i = start; i < end; i++) {
|
|
1381
|
-
newList.push(this.at(i));
|
|
1382
|
-
}
|
|
1383
|
-
return newList;
|
|
1384
|
-
}
|
|
1385
|
-
/**
|
|
1386
|
-
* Fill a range with a value.
|
|
1387
|
-
* @param value - Value to set.
|
|
1388
|
-
* @param start - Inclusive start.
|
|
1389
|
-
* @param end - Exclusive end.
|
|
1390
|
-
* @returns This list.
|
|
1391
|
-
* @remarks Time O(n), Space O(1)
|
|
1736
|
+
* (Protected) Spawn an empty like-kind heap instance.
|
|
1737
|
+
* @remarks Time O(1), Space O(1)
|
|
1738
|
+
* @template EM
|
|
1739
|
+
* @template RM
|
|
1740
|
+
* @param [options] - Options forwarded to the constructor.
|
|
1741
|
+
* @returns An empty like-kind heap instance.
|
|
1392
1742
|
*/
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
end = end < 0 ? this.length + end : end;
|
|
1396
|
-
if (start < 0) start = 0;
|
|
1397
|
-
if (end > this.length) end = this.length;
|
|
1398
|
-
if (start >= end) return this;
|
|
1399
|
-
for (let i = start; i < end; i++) {
|
|
1400
|
-
this.setAt(i, value);
|
|
1401
|
-
}
|
|
1402
|
-
return this;
|
|
1743
|
+
_spawnLike(options) {
|
|
1744
|
+
return this._createLike([], options);
|
|
1403
1745
|
}
|
|
1404
1746
|
};
|
|
1405
1747
|
|
|
@@ -1471,6 +1813,30 @@ var graphTyped = (() => {
|
|
|
1471
1813
|
|
|
1472
1814
|
|
|
1473
1815
|
|
|
1816
|
+
|
|
1817
|
+
|
|
1818
|
+
|
|
1819
|
+
|
|
1820
|
+
|
|
1821
|
+
|
|
1822
|
+
|
|
1823
|
+
|
|
1824
|
+
|
|
1825
|
+
|
|
1826
|
+
|
|
1827
|
+
|
|
1828
|
+
|
|
1829
|
+
|
|
1830
|
+
|
|
1831
|
+
|
|
1832
|
+
|
|
1833
|
+
|
|
1834
|
+
|
|
1835
|
+
|
|
1836
|
+
|
|
1837
|
+
|
|
1838
|
+
|
|
1839
|
+
|
|
1474
1840
|
* @example
|
|
1475
1841
|
* // Track queue length
|
|
1476
1842
|
* const q = new Queue<number>();
|
|
@@ -1497,6 +1863,30 @@ var graphTyped = (() => {
|
|
|
1497
1863
|
|
|
1498
1864
|
|
|
1499
1865
|
|
|
1866
|
+
|
|
1867
|
+
|
|
1868
|
+
|
|
1869
|
+
|
|
1870
|
+
|
|
1871
|
+
|
|
1872
|
+
|
|
1873
|
+
|
|
1874
|
+
|
|
1875
|
+
|
|
1876
|
+
|
|
1877
|
+
|
|
1878
|
+
|
|
1879
|
+
|
|
1880
|
+
|
|
1881
|
+
|
|
1882
|
+
|
|
1883
|
+
|
|
1884
|
+
|
|
1885
|
+
|
|
1886
|
+
|
|
1887
|
+
|
|
1888
|
+
|
|
1889
|
+
|
|
1500
1890
|
* @example
|
|
1501
1891
|
* // View the front element
|
|
1502
1892
|
* const q = new Queue<string>(['first', 'second', 'third']);
|
|
@@ -1539,6 +1929,30 @@ var graphTyped = (() => {
|
|
|
1539
1929
|
|
|
1540
1930
|
|
|
1541
1931
|
|
|
1932
|
+
|
|
1933
|
+
|
|
1934
|
+
|
|
1935
|
+
|
|
1936
|
+
|
|
1937
|
+
|
|
1938
|
+
|
|
1939
|
+
|
|
1940
|
+
|
|
1941
|
+
|
|
1942
|
+
|
|
1943
|
+
|
|
1944
|
+
|
|
1945
|
+
|
|
1946
|
+
|
|
1947
|
+
|
|
1948
|
+
|
|
1949
|
+
|
|
1950
|
+
|
|
1951
|
+
|
|
1952
|
+
|
|
1953
|
+
|
|
1954
|
+
|
|
1955
|
+
|
|
1542
1956
|
* @example
|
|
1543
1957
|
* // Queue for...of iteration and isEmpty check
|
|
1544
1958
|
* const queue = new Queue<string>(['A', 'B', 'C', 'D']);
|
|
@@ -1577,6 +1991,30 @@ var graphTyped = (() => {
|
|
|
1577
1991
|
|
|
1578
1992
|
|
|
1579
1993
|
|
|
1994
|
+
|
|
1995
|
+
|
|
1996
|
+
|
|
1997
|
+
|
|
1998
|
+
|
|
1999
|
+
|
|
2000
|
+
|
|
2001
|
+
|
|
2002
|
+
|
|
2003
|
+
|
|
2004
|
+
|
|
2005
|
+
|
|
2006
|
+
|
|
2007
|
+
|
|
2008
|
+
|
|
2009
|
+
|
|
2010
|
+
|
|
2011
|
+
|
|
2012
|
+
|
|
2013
|
+
|
|
2014
|
+
|
|
2015
|
+
|
|
2016
|
+
|
|
2017
|
+
|
|
1580
2018
|
* @example
|
|
1581
2019
|
* // basic Queue creation and push operation
|
|
1582
2020
|
* // Create a simple Queue with initial values
|
|
@@ -1622,6 +2060,30 @@ var graphTyped = (() => {
|
|
|
1622
2060
|
|
|
1623
2061
|
|
|
1624
2062
|
|
|
2063
|
+
|
|
2064
|
+
|
|
2065
|
+
|
|
2066
|
+
|
|
2067
|
+
|
|
2068
|
+
|
|
2069
|
+
|
|
2070
|
+
|
|
2071
|
+
|
|
2072
|
+
|
|
2073
|
+
|
|
2074
|
+
|
|
2075
|
+
|
|
2076
|
+
|
|
2077
|
+
|
|
2078
|
+
|
|
2079
|
+
|
|
2080
|
+
|
|
2081
|
+
|
|
2082
|
+
|
|
2083
|
+
|
|
2084
|
+
|
|
2085
|
+
|
|
2086
|
+
|
|
1625
2087
|
* @example
|
|
1626
2088
|
* // Queue shift and peek operations
|
|
1627
2089
|
* const queue = new Queue<number>([10, 20, 30, 40]);
|
|
@@ -1657,6 +2119,30 @@ var graphTyped = (() => {
|
|
|
1657
2119
|
|
|
1658
2120
|
|
|
1659
2121
|
|
|
2122
|
+
|
|
2123
|
+
|
|
2124
|
+
|
|
2125
|
+
|
|
2126
|
+
|
|
2127
|
+
|
|
2128
|
+
|
|
2129
|
+
|
|
2130
|
+
|
|
2131
|
+
|
|
2132
|
+
|
|
2133
|
+
|
|
2134
|
+
|
|
2135
|
+
|
|
2136
|
+
|
|
2137
|
+
|
|
2138
|
+
|
|
2139
|
+
|
|
2140
|
+
|
|
2141
|
+
|
|
2142
|
+
|
|
2143
|
+
|
|
2144
|
+
|
|
2145
|
+
|
|
1660
2146
|
* @example
|
|
1661
2147
|
* // Remove specific element
|
|
1662
2148
|
* const q = new Queue<number>([1, 2, 3, 2]);
|
|
@@ -1685,6 +2171,30 @@ var graphTyped = (() => {
|
|
|
1685
2171
|
|
|
1686
2172
|
|
|
1687
2173
|
|
|
2174
|
+
|
|
2175
|
+
|
|
2176
|
+
|
|
2177
|
+
|
|
2178
|
+
|
|
2179
|
+
|
|
2180
|
+
|
|
2181
|
+
|
|
2182
|
+
|
|
2183
|
+
|
|
2184
|
+
|
|
2185
|
+
|
|
2186
|
+
|
|
2187
|
+
|
|
2188
|
+
|
|
2189
|
+
|
|
2190
|
+
|
|
2191
|
+
|
|
2192
|
+
|
|
2193
|
+
|
|
2194
|
+
|
|
2195
|
+
|
|
2196
|
+
|
|
2197
|
+
|
|
1688
2198
|
* @example
|
|
1689
2199
|
* // Access element by index
|
|
1690
2200
|
* const q = new Queue<string>(['a', 'b', 'c']);
|
|
@@ -1754,6 +2264,30 @@ var graphTyped = (() => {
|
|
|
1754
2264
|
|
|
1755
2265
|
|
|
1756
2266
|
|
|
2267
|
+
|
|
2268
|
+
|
|
2269
|
+
|
|
2270
|
+
|
|
2271
|
+
|
|
2272
|
+
|
|
2273
|
+
|
|
2274
|
+
|
|
2275
|
+
|
|
2276
|
+
|
|
2277
|
+
|
|
2278
|
+
|
|
2279
|
+
|
|
2280
|
+
|
|
2281
|
+
|
|
2282
|
+
|
|
2283
|
+
|
|
2284
|
+
|
|
2285
|
+
|
|
2286
|
+
|
|
2287
|
+
|
|
2288
|
+
|
|
2289
|
+
|
|
2290
|
+
|
|
1757
2291
|
* @example
|
|
1758
2292
|
* // Remove all elements
|
|
1759
2293
|
* const q = new Queue<number>([1, 2, 3]);
|
|
@@ -1776,6 +2310,30 @@ var graphTyped = (() => {
|
|
|
1776
2310
|
|
|
1777
2311
|
|
|
1778
2312
|
|
|
2313
|
+
|
|
2314
|
+
|
|
2315
|
+
|
|
2316
|
+
|
|
2317
|
+
|
|
2318
|
+
|
|
2319
|
+
|
|
2320
|
+
|
|
2321
|
+
|
|
2322
|
+
|
|
2323
|
+
|
|
2324
|
+
|
|
2325
|
+
|
|
2326
|
+
|
|
2327
|
+
|
|
2328
|
+
|
|
2329
|
+
|
|
2330
|
+
|
|
2331
|
+
|
|
2332
|
+
|
|
2333
|
+
|
|
2334
|
+
|
|
2335
|
+
|
|
2336
|
+
|
|
1779
2337
|
* @example
|
|
1780
2338
|
* // Reclaim unused memory
|
|
1781
2339
|
* const q = new Queue<number>([1, 2, 3, 4, 5]);
|
|
@@ -1821,6 +2379,30 @@ var graphTyped = (() => {
|
|
|
1821
2379
|
|
|
1822
2380
|
|
|
1823
2381
|
|
|
2382
|
+
|
|
2383
|
+
|
|
2384
|
+
|
|
2385
|
+
|
|
2386
|
+
|
|
2387
|
+
|
|
2388
|
+
|
|
2389
|
+
|
|
2390
|
+
|
|
2391
|
+
|
|
2392
|
+
|
|
2393
|
+
|
|
2394
|
+
|
|
2395
|
+
|
|
2396
|
+
|
|
2397
|
+
|
|
2398
|
+
|
|
2399
|
+
|
|
2400
|
+
|
|
2401
|
+
|
|
2402
|
+
|
|
2403
|
+
|
|
2404
|
+
|
|
2405
|
+
|
|
1824
2406
|
* @example
|
|
1825
2407
|
* // Create independent copy
|
|
1826
2408
|
* const q = new Queue<number>([1, 2, 3]);
|
|
@@ -1850,6 +2432,30 @@ var graphTyped = (() => {
|
|
|
1850
2432
|
|
|
1851
2433
|
|
|
1852
2434
|
|
|
2435
|
+
|
|
2436
|
+
|
|
2437
|
+
|
|
2438
|
+
|
|
2439
|
+
|
|
2440
|
+
|
|
2441
|
+
|
|
2442
|
+
|
|
2443
|
+
|
|
2444
|
+
|
|
2445
|
+
|
|
2446
|
+
|
|
2447
|
+
|
|
2448
|
+
|
|
2449
|
+
|
|
2450
|
+
|
|
2451
|
+
|
|
2452
|
+
|
|
2453
|
+
|
|
2454
|
+
|
|
2455
|
+
|
|
2456
|
+
|
|
2457
|
+
|
|
2458
|
+
|
|
1853
2459
|
* @example
|
|
1854
2460
|
* // Filter elements
|
|
1855
2461
|
* const q = new Queue<number>([1, 2, 3, 4, 5]);
|
|
@@ -1883,6 +2489,30 @@ var graphTyped = (() => {
|
|
|
1883
2489
|
|
|
1884
2490
|
|
|
1885
2491
|
|
|
2492
|
+
|
|
2493
|
+
|
|
2494
|
+
|
|
2495
|
+
|
|
2496
|
+
|
|
2497
|
+
|
|
2498
|
+
|
|
2499
|
+
|
|
2500
|
+
|
|
2501
|
+
|
|
2502
|
+
|
|
2503
|
+
|
|
2504
|
+
|
|
2505
|
+
|
|
2506
|
+
|
|
2507
|
+
|
|
2508
|
+
|
|
2509
|
+
|
|
2510
|
+
|
|
2511
|
+
|
|
2512
|
+
|
|
2513
|
+
|
|
2514
|
+
|
|
2515
|
+
|
|
1886
2516
|
* @example
|
|
1887
2517
|
* // Transform elements
|
|
1888
2518
|
* const q = new Queue<number>([1, 2, 3]);
|
|
@@ -2111,7 +2741,7 @@ var graphTyped = (() => {
|
|
|
2111
2741
|
const newEdge = this.createEdge(srcOrEdge, dest, weight, value);
|
|
2112
2742
|
return this._addEdge(newEdge);
|
|
2113
2743
|
} else {
|
|
2114
|
-
|
|
2744
|
+
raise(TypeError, ERR.invalidArgument("dest must be a Vertex or vertex key when srcOrEdge is an Edge.", "Graph"));
|
|
2115
2745
|
}
|
|
2116
2746
|
}
|
|
2117
2747
|
}
|
|
@@ -2989,6 +3619,30 @@ var graphTyped = (() => {
|
|
|
2989
3619
|
|
|
2990
3620
|
|
|
2991
3621
|
|
|
3622
|
+
|
|
3623
|
+
|
|
3624
|
+
|
|
3625
|
+
|
|
3626
|
+
|
|
3627
|
+
|
|
3628
|
+
|
|
3629
|
+
|
|
3630
|
+
|
|
3631
|
+
|
|
3632
|
+
|
|
3633
|
+
|
|
3634
|
+
|
|
3635
|
+
|
|
3636
|
+
|
|
3637
|
+
|
|
3638
|
+
|
|
3639
|
+
|
|
3640
|
+
|
|
3641
|
+
|
|
3642
|
+
|
|
3643
|
+
|
|
3644
|
+
|
|
3645
|
+
|
|
2992
3646
|
* @example
|
|
2993
3647
|
* // Get edge between vertices
|
|
2994
3648
|
* const g = new DirectedGraph();
|
|
@@ -3053,6 +3707,30 @@ var graphTyped = (() => {
|
|
|
3053
3707
|
|
|
3054
3708
|
|
|
3055
3709
|
|
|
3710
|
+
|
|
3711
|
+
|
|
3712
|
+
|
|
3713
|
+
|
|
3714
|
+
|
|
3715
|
+
|
|
3716
|
+
|
|
3717
|
+
|
|
3718
|
+
|
|
3719
|
+
|
|
3720
|
+
|
|
3721
|
+
|
|
3722
|
+
|
|
3723
|
+
|
|
3724
|
+
|
|
3725
|
+
|
|
3726
|
+
|
|
3727
|
+
|
|
3728
|
+
|
|
3729
|
+
|
|
3730
|
+
|
|
3731
|
+
|
|
3732
|
+
|
|
3733
|
+
|
|
3056
3734
|
* @example
|
|
3057
3735
|
* // DirectedGraph deleteEdge and vertex operations
|
|
3058
3736
|
* const graph = new DirectedGraph<string>();
|
|
@@ -3115,6 +3793,30 @@ var graphTyped = (() => {
|
|
|
3115
3793
|
|
|
3116
3794
|
|
|
3117
3795
|
|
|
3796
|
+
|
|
3797
|
+
|
|
3798
|
+
|
|
3799
|
+
|
|
3800
|
+
|
|
3801
|
+
|
|
3802
|
+
|
|
3803
|
+
|
|
3804
|
+
|
|
3805
|
+
|
|
3806
|
+
|
|
3807
|
+
|
|
3808
|
+
|
|
3809
|
+
|
|
3810
|
+
|
|
3811
|
+
|
|
3812
|
+
|
|
3813
|
+
|
|
3814
|
+
|
|
3815
|
+
|
|
3816
|
+
|
|
3817
|
+
|
|
3818
|
+
|
|
3819
|
+
|
|
3118
3820
|
* @example
|
|
3119
3821
|
* // Remove a vertex
|
|
3120
3822
|
* const g = new DirectedGraph();
|
|
@@ -3168,6 +3870,30 @@ var graphTyped = (() => {
|
|
|
3168
3870
|
|
|
3169
3871
|
|
|
3170
3872
|
|
|
3873
|
+
|
|
3874
|
+
|
|
3875
|
+
|
|
3876
|
+
|
|
3877
|
+
|
|
3878
|
+
|
|
3879
|
+
|
|
3880
|
+
|
|
3881
|
+
|
|
3882
|
+
|
|
3883
|
+
|
|
3884
|
+
|
|
3885
|
+
|
|
3886
|
+
|
|
3887
|
+
|
|
3888
|
+
|
|
3889
|
+
|
|
3890
|
+
|
|
3891
|
+
|
|
3892
|
+
|
|
3893
|
+
|
|
3894
|
+
|
|
3895
|
+
|
|
3896
|
+
|
|
3171
3897
|
* @example
|
|
3172
3898
|
* // Get incoming edges
|
|
3173
3899
|
* const g = new DirectedGraph();
|
|
@@ -3198,6 +3924,30 @@ var graphTyped = (() => {
|
|
|
3198
3924
|
|
|
3199
3925
|
|
|
3200
3926
|
|
|
3927
|
+
|
|
3928
|
+
|
|
3929
|
+
|
|
3930
|
+
|
|
3931
|
+
|
|
3932
|
+
|
|
3933
|
+
|
|
3934
|
+
|
|
3935
|
+
|
|
3936
|
+
|
|
3937
|
+
|
|
3938
|
+
|
|
3939
|
+
|
|
3940
|
+
|
|
3941
|
+
|
|
3942
|
+
|
|
3943
|
+
|
|
3944
|
+
|
|
3945
|
+
|
|
3946
|
+
|
|
3947
|
+
|
|
3948
|
+
|
|
3949
|
+
|
|
3950
|
+
|
|
3201
3951
|
* @example
|
|
3202
3952
|
* // Get outgoing edges
|
|
3203
3953
|
* const g = new DirectedGraph();
|
|
@@ -3281,6 +4031,30 @@ var graphTyped = (() => {
|
|
|
3281
4031
|
|
|
3282
4032
|
|
|
3283
4033
|
|
|
4034
|
+
|
|
4035
|
+
|
|
4036
|
+
|
|
4037
|
+
|
|
4038
|
+
|
|
4039
|
+
|
|
4040
|
+
|
|
4041
|
+
|
|
4042
|
+
|
|
4043
|
+
|
|
4044
|
+
|
|
4045
|
+
|
|
4046
|
+
|
|
4047
|
+
|
|
4048
|
+
|
|
4049
|
+
|
|
4050
|
+
|
|
4051
|
+
|
|
4052
|
+
|
|
4053
|
+
|
|
4054
|
+
|
|
4055
|
+
|
|
4056
|
+
|
|
4057
|
+
|
|
3284
4058
|
* @example
|
|
3285
4059
|
* // DirectedGraph topologicalSort for task scheduling
|
|
3286
4060
|
* const graph = new DirectedGraph<string>();
|
|
@@ -3345,6 +4119,30 @@ var graphTyped = (() => {
|
|
|
3345
4119
|
|
|
3346
4120
|
|
|
3347
4121
|
|
|
4122
|
+
|
|
4123
|
+
|
|
4124
|
+
|
|
4125
|
+
|
|
4126
|
+
|
|
4127
|
+
|
|
4128
|
+
|
|
4129
|
+
|
|
4130
|
+
|
|
4131
|
+
|
|
4132
|
+
|
|
4133
|
+
|
|
4134
|
+
|
|
4135
|
+
|
|
4136
|
+
|
|
4137
|
+
|
|
4138
|
+
|
|
4139
|
+
|
|
4140
|
+
|
|
4141
|
+
|
|
4142
|
+
|
|
4143
|
+
|
|
4144
|
+
|
|
4145
|
+
|
|
3348
4146
|
* @example
|
|
3349
4147
|
* // Get all edges
|
|
3350
4148
|
* const g = new DirectedGraph();
|
|
@@ -3371,6 +4169,30 @@ var graphTyped = (() => {
|
|
|
3371
4169
|
|
|
3372
4170
|
|
|
3373
4171
|
|
|
4172
|
+
|
|
4173
|
+
|
|
4174
|
+
|
|
4175
|
+
|
|
4176
|
+
|
|
4177
|
+
|
|
4178
|
+
|
|
4179
|
+
|
|
4180
|
+
|
|
4181
|
+
|
|
4182
|
+
|
|
4183
|
+
|
|
4184
|
+
|
|
4185
|
+
|
|
4186
|
+
|
|
4187
|
+
|
|
4188
|
+
|
|
4189
|
+
|
|
4190
|
+
|
|
4191
|
+
|
|
4192
|
+
|
|
4193
|
+
|
|
4194
|
+
|
|
4195
|
+
|
|
3374
4196
|
* @example
|
|
3375
4197
|
* // Get outgoing neighbors
|
|
3376
4198
|
* const g = new DirectedGraph();
|
|
@@ -3450,6 +4272,30 @@ var graphTyped = (() => {
|
|
|
3450
4272
|
|
|
3451
4273
|
|
|
3452
4274
|
|
|
4275
|
+
|
|
4276
|
+
|
|
4277
|
+
|
|
4278
|
+
|
|
4279
|
+
|
|
4280
|
+
|
|
4281
|
+
|
|
4282
|
+
|
|
4283
|
+
|
|
4284
|
+
|
|
4285
|
+
|
|
4286
|
+
|
|
4287
|
+
|
|
4288
|
+
|
|
4289
|
+
|
|
4290
|
+
|
|
4291
|
+
|
|
4292
|
+
|
|
4293
|
+
|
|
4294
|
+
|
|
4295
|
+
|
|
4296
|
+
|
|
4297
|
+
|
|
4298
|
+
|
|
3453
4299
|
* @example
|
|
3454
4300
|
* // Find strongly connected components
|
|
3455
4301
|
* const g = new DirectedGraph();
|
|
@@ -3532,6 +4378,30 @@ var graphTyped = (() => {
|
|
|
3532
4378
|
|
|
3533
4379
|
|
|
3534
4380
|
|
|
4381
|
+
|
|
4382
|
+
|
|
4383
|
+
|
|
4384
|
+
|
|
4385
|
+
|
|
4386
|
+
|
|
4387
|
+
|
|
4388
|
+
|
|
4389
|
+
|
|
4390
|
+
|
|
4391
|
+
|
|
4392
|
+
|
|
4393
|
+
|
|
4394
|
+
|
|
4395
|
+
|
|
4396
|
+
|
|
4397
|
+
|
|
4398
|
+
|
|
4399
|
+
|
|
4400
|
+
|
|
4401
|
+
|
|
4402
|
+
|
|
4403
|
+
|
|
4404
|
+
|
|
3535
4405
|
* @example
|
|
3536
4406
|
* // Get strongly connected components
|
|
3537
4407
|
* const g = new DirectedGraph();
|
|
@@ -3672,6 +4542,30 @@ var graphTyped = (() => {
|
|
|
3672
4542
|
|
|
3673
4543
|
|
|
3674
4544
|
|
|
4545
|
+
|
|
4546
|
+
|
|
4547
|
+
|
|
4548
|
+
|
|
4549
|
+
|
|
4550
|
+
|
|
4551
|
+
|
|
4552
|
+
|
|
4553
|
+
|
|
4554
|
+
|
|
4555
|
+
|
|
4556
|
+
|
|
4557
|
+
|
|
4558
|
+
|
|
4559
|
+
|
|
4560
|
+
|
|
4561
|
+
|
|
4562
|
+
|
|
4563
|
+
|
|
4564
|
+
|
|
4565
|
+
|
|
4566
|
+
|
|
4567
|
+
|
|
4568
|
+
|
|
3675
4569
|
* @example
|
|
3676
4570
|
* // Get edge between vertices
|
|
3677
4571
|
* const g = new UndirectedGraph();
|
|
@@ -3733,6 +4627,30 @@ var graphTyped = (() => {
|
|
|
3733
4627
|
|
|
3734
4628
|
|
|
3735
4629
|
|
|
4630
|
+
|
|
4631
|
+
|
|
4632
|
+
|
|
4633
|
+
|
|
4634
|
+
|
|
4635
|
+
|
|
4636
|
+
|
|
4637
|
+
|
|
4638
|
+
|
|
4639
|
+
|
|
4640
|
+
|
|
4641
|
+
|
|
4642
|
+
|
|
4643
|
+
|
|
4644
|
+
|
|
4645
|
+
|
|
4646
|
+
|
|
4647
|
+
|
|
4648
|
+
|
|
4649
|
+
|
|
4650
|
+
|
|
4651
|
+
|
|
4652
|
+
|
|
4653
|
+
|
|
3736
4654
|
* @example
|
|
3737
4655
|
* // UndirectedGraph deleteEdge and vertex operations
|
|
3738
4656
|
* const graph = new UndirectedGraph<string>();
|
|
@@ -3793,6 +4711,30 @@ var graphTyped = (() => {
|
|
|
3793
4711
|
|
|
3794
4712
|
|
|
3795
4713
|
|
|
4714
|
+
|
|
4715
|
+
|
|
4716
|
+
|
|
4717
|
+
|
|
4718
|
+
|
|
4719
|
+
|
|
4720
|
+
|
|
4721
|
+
|
|
4722
|
+
|
|
4723
|
+
|
|
4724
|
+
|
|
4725
|
+
|
|
4726
|
+
|
|
4727
|
+
|
|
4728
|
+
|
|
4729
|
+
|
|
4730
|
+
|
|
4731
|
+
|
|
4732
|
+
|
|
4733
|
+
|
|
4734
|
+
|
|
4735
|
+
|
|
4736
|
+
|
|
4737
|
+
|
|
3796
4738
|
* @example
|
|
3797
4739
|
* // Remove vertex and edges
|
|
3798
4740
|
* const g = new UndirectedGraph();
|
|
@@ -3868,6 +4810,30 @@ var graphTyped = (() => {
|
|
|
3868
4810
|
|
|
3869
4811
|
|
|
3870
4812
|
|
|
4813
|
+
|
|
4814
|
+
|
|
4815
|
+
|
|
4816
|
+
|
|
4817
|
+
|
|
4818
|
+
|
|
4819
|
+
|
|
4820
|
+
|
|
4821
|
+
|
|
4822
|
+
|
|
4823
|
+
|
|
4824
|
+
|
|
4825
|
+
|
|
4826
|
+
|
|
4827
|
+
|
|
4828
|
+
|
|
4829
|
+
|
|
4830
|
+
|
|
4831
|
+
|
|
4832
|
+
|
|
4833
|
+
|
|
4834
|
+
|
|
4835
|
+
|
|
4836
|
+
|
|
3871
4837
|
* @example
|
|
3872
4838
|
* // Get all edges
|
|
3873
4839
|
* const g = new UndirectedGraph();
|
|
@@ -3898,6 +4864,30 @@ var graphTyped = (() => {
|
|
|
3898
4864
|
|
|
3899
4865
|
|
|
3900
4866
|
|
|
4867
|
+
|
|
4868
|
+
|
|
4869
|
+
|
|
4870
|
+
|
|
4871
|
+
|
|
4872
|
+
|
|
4873
|
+
|
|
4874
|
+
|
|
4875
|
+
|
|
4876
|
+
|
|
4877
|
+
|
|
4878
|
+
|
|
4879
|
+
|
|
4880
|
+
|
|
4881
|
+
|
|
4882
|
+
|
|
4883
|
+
|
|
4884
|
+
|
|
4885
|
+
|
|
4886
|
+
|
|
4887
|
+
|
|
4888
|
+
|
|
4889
|
+
|
|
4890
|
+
|
|
3901
4891
|
* @example
|
|
3902
4892
|
* // UndirectedGraph connectivity and neighbors
|
|
3903
4893
|
* const graph = new UndirectedGraph<string>();
|
|
@@ -3998,6 +4988,30 @@ var graphTyped = (() => {
|
|
|
3998
4988
|
|
|
3999
4989
|
|
|
4000
4990
|
|
|
4991
|
+
|
|
4992
|
+
|
|
4993
|
+
|
|
4994
|
+
|
|
4995
|
+
|
|
4996
|
+
|
|
4997
|
+
|
|
4998
|
+
|
|
4999
|
+
|
|
5000
|
+
|
|
5001
|
+
|
|
5002
|
+
|
|
5003
|
+
|
|
5004
|
+
|
|
5005
|
+
|
|
5006
|
+
|
|
5007
|
+
|
|
5008
|
+
|
|
5009
|
+
|
|
5010
|
+
|
|
5011
|
+
|
|
5012
|
+
|
|
5013
|
+
|
|
5014
|
+
|
|
4001
5015
|
* @example
|
|
4002
5016
|
* // Find articulation points and bridges
|
|
4003
5017
|
* const g = new UndirectedGraph();
|
|
@@ -4120,6 +5134,30 @@ var graphTyped = (() => {
|
|
|
4120
5134
|
|
|
4121
5135
|
|
|
4122
5136
|
|
|
5137
|
+
|
|
5138
|
+
|
|
5139
|
+
|
|
5140
|
+
|
|
5141
|
+
|
|
5142
|
+
|
|
5143
|
+
|
|
5144
|
+
|
|
5145
|
+
|
|
5146
|
+
|
|
5147
|
+
|
|
5148
|
+
|
|
5149
|
+
|
|
5150
|
+
|
|
5151
|
+
|
|
5152
|
+
|
|
5153
|
+
|
|
5154
|
+
|
|
5155
|
+
|
|
5156
|
+
|
|
5157
|
+
|
|
5158
|
+
|
|
5159
|
+
|
|
5160
|
+
|
|
4123
5161
|
* @example
|
|
4124
5162
|
* // Detect cycle
|
|
4125
5163
|
* const g = new UndirectedGraph();
|
|
@@ -4164,6 +5202,30 @@ var graphTyped = (() => {
|
|
|
4164
5202
|
|
|
4165
5203
|
|
|
4166
5204
|
|
|
5205
|
+
|
|
5206
|
+
|
|
5207
|
+
|
|
5208
|
+
|
|
5209
|
+
|
|
5210
|
+
|
|
5211
|
+
|
|
5212
|
+
|
|
5213
|
+
|
|
5214
|
+
|
|
5215
|
+
|
|
5216
|
+
|
|
5217
|
+
|
|
5218
|
+
|
|
5219
|
+
|
|
5220
|
+
|
|
5221
|
+
|
|
5222
|
+
|
|
5223
|
+
|
|
5224
|
+
|
|
5225
|
+
|
|
5226
|
+
|
|
5227
|
+
|
|
5228
|
+
|
|
4167
5229
|
* @example
|
|
4168
5230
|
* // Find bridge edges
|
|
4169
5231
|
* const g = new UndirectedGraph();
|
|
@@ -4190,6 +5252,30 @@ var graphTyped = (() => {
|
|
|
4190
5252
|
|
|
4191
5253
|
|
|
4192
5254
|
|
|
5255
|
+
|
|
5256
|
+
|
|
5257
|
+
|
|
5258
|
+
|
|
5259
|
+
|
|
5260
|
+
|
|
5261
|
+
|
|
5262
|
+
|
|
5263
|
+
|
|
5264
|
+
|
|
5265
|
+
|
|
5266
|
+
|
|
5267
|
+
|
|
5268
|
+
|
|
5269
|
+
|
|
5270
|
+
|
|
5271
|
+
|
|
5272
|
+
|
|
5273
|
+
|
|
5274
|
+
|
|
5275
|
+
|
|
5276
|
+
|
|
5277
|
+
|
|
5278
|
+
|
|
4193
5279
|
* @example
|
|
4194
5280
|
* // Find articulation points
|
|
4195
5281
|
* const g = new UndirectedGraph();
|