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
|
@@ -27,6 +27,10 @@ var arrayRemove = /* @__PURE__ */ __name(function(array, predicate) {
|
|
|
27
27
|
}, "arrayRemove");
|
|
28
28
|
|
|
29
29
|
// src/common/error.ts
|
|
30
|
+
function raise(ErrorClass, message) {
|
|
31
|
+
throw new ErrorClass(message);
|
|
32
|
+
}
|
|
33
|
+
__name(raise, "raise");
|
|
30
34
|
var ERR = {
|
|
31
35
|
// Range / index
|
|
32
36
|
indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
|
|
@@ -48,7 +52,9 @@ var ERR = {
|
|
|
48
52
|
matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
|
|
49
53
|
matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
|
|
50
54
|
matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
|
|
51
|
-
matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
|
|
55
|
+
matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch"),
|
|
56
|
+
// Order statistic
|
|
57
|
+
orderStatisticNotEnabled: /* @__PURE__ */ __name((method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`, "orderStatisticNotEnabled")
|
|
52
58
|
};
|
|
53
59
|
|
|
54
60
|
// src/common/index.ts
|
|
@@ -277,7 +283,7 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
277
283
|
if (options) {
|
|
278
284
|
const { toElementFn } = options;
|
|
279
285
|
if (typeof toElementFn === "function") this._toElementFn = toElementFn;
|
|
280
|
-
else if (toElementFn)
|
|
286
|
+
else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
|
|
281
287
|
}
|
|
282
288
|
}
|
|
283
289
|
/**
|
|
@@ -433,7 +439,7 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
433
439
|
acc = initialValue;
|
|
434
440
|
} else {
|
|
435
441
|
const first = iter.next();
|
|
436
|
-
if (first.done)
|
|
442
|
+
if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
|
|
437
443
|
acc = first.value;
|
|
438
444
|
index = 1;
|
|
439
445
|
}
|
|
@@ -477,6 +483,198 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
477
483
|
__name(_IterableElementBase, "IterableElementBase");
|
|
478
484
|
var IterableElementBase = _IterableElementBase;
|
|
479
485
|
|
|
486
|
+
// src/data-structures/base/linear-base.ts
|
|
487
|
+
var _LinearBase = class _LinearBase extends IterableElementBase {
|
|
488
|
+
/**
|
|
489
|
+
* Construct a linear container with runtime options.
|
|
490
|
+
* @param options - `{ maxLen?, ... }` bounds/behavior options.
|
|
491
|
+
* @remarks Time O(1), Space O(1)
|
|
492
|
+
*/
|
|
493
|
+
constructor(options) {
|
|
494
|
+
super(options);
|
|
495
|
+
__publicField(this, "_maxLen", -1);
|
|
496
|
+
if (options) {
|
|
497
|
+
const { maxLen } = options;
|
|
498
|
+
if (typeof maxLen === "number" && maxLen > 0 && maxLen % 1 === 0) this._maxLen = maxLen;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Upper bound for length (if positive), or `-1` when unbounded.
|
|
503
|
+
* @returns Maximum allowed length.
|
|
504
|
+
* @remarks Time O(1), Space O(1)
|
|
505
|
+
*/
|
|
506
|
+
get maxLen() {
|
|
507
|
+
return this._maxLen;
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* First index of a value from the left.
|
|
511
|
+
* @param searchElement - Value to match.
|
|
512
|
+
* @param fromIndex - Start position (supports negative index).
|
|
513
|
+
* @returns Index or `-1` if not found.
|
|
514
|
+
* @remarks Time O(n), Space O(1)
|
|
515
|
+
*/
|
|
516
|
+
indexOf(searchElement, fromIndex = 0) {
|
|
517
|
+
if (this.length === 0) return -1;
|
|
518
|
+
if (fromIndex < 0) fromIndex = this.length + fromIndex;
|
|
519
|
+
if (fromIndex < 0) fromIndex = 0;
|
|
520
|
+
for (let i = fromIndex; i < this.length; i++) {
|
|
521
|
+
const element = this.at(i);
|
|
522
|
+
if (element === searchElement) return i;
|
|
523
|
+
}
|
|
524
|
+
return -1;
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Last index of a value from the right.
|
|
528
|
+
* @param searchElement - Value to match.
|
|
529
|
+
* @param fromIndex - Start position (supports negative index).
|
|
530
|
+
* @returns Index or `-1` if not found.
|
|
531
|
+
* @remarks Time O(n), Space O(1)
|
|
532
|
+
*/
|
|
533
|
+
lastIndexOf(searchElement, fromIndex = this.length - 1) {
|
|
534
|
+
if (this.length === 0) return -1;
|
|
535
|
+
if (fromIndex >= this.length) fromIndex = this.length - 1;
|
|
536
|
+
if (fromIndex < 0) fromIndex = this.length + fromIndex;
|
|
537
|
+
for (let i = fromIndex; i >= 0; i--) {
|
|
538
|
+
const element = this.at(i);
|
|
539
|
+
if (element === searchElement) return i;
|
|
540
|
+
}
|
|
541
|
+
return -1;
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Find the first index matching a predicate.
|
|
545
|
+
* @param predicate - `(element, index, self) => boolean`.
|
|
546
|
+
* @param thisArg - Optional `this` for callback.
|
|
547
|
+
* @returns Index or `-1`.
|
|
548
|
+
* @remarks Time O(n), Space O(1)
|
|
549
|
+
*/
|
|
550
|
+
findIndex(predicate, thisArg) {
|
|
551
|
+
for (let i = 0; i < this.length; i++) {
|
|
552
|
+
const item = this.at(i);
|
|
553
|
+
if (item !== void 0 && predicate.call(thisArg, item, i, this)) return i;
|
|
554
|
+
}
|
|
555
|
+
return -1;
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Concatenate elements and/or containers.
|
|
559
|
+
* @param items - Elements or other containers.
|
|
560
|
+
* @returns New container with combined elements (`this` type).
|
|
561
|
+
* @remarks Time O(sum(length)), Space O(sum(length))
|
|
562
|
+
*/
|
|
563
|
+
concat(...items) {
|
|
564
|
+
const newList = this.clone();
|
|
565
|
+
for (const item of items) {
|
|
566
|
+
if (item instanceof _LinearBase) {
|
|
567
|
+
newList.pushMany(item);
|
|
568
|
+
} else {
|
|
569
|
+
newList.push(item);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
return newList;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* In-place stable order via array sort semantics.
|
|
576
|
+
* @param compareFn - Comparator `(a, b) => number`.
|
|
577
|
+
* @returns This container.
|
|
578
|
+
* @remarks Time O(n log n), Space O(n) (materializes to array temporarily)
|
|
579
|
+
*/
|
|
580
|
+
sort(compareFn) {
|
|
581
|
+
const arr = this.toArray();
|
|
582
|
+
arr.sort(compareFn);
|
|
583
|
+
this.clear();
|
|
584
|
+
for (const item of arr) this.push(item);
|
|
585
|
+
return this;
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* Remove and/or insert elements at a position (array-compatible).
|
|
589
|
+
* @param start - Start index (supports negative index).
|
|
590
|
+
* @param deleteCount - How many to remove.
|
|
591
|
+
* @param items - Elements to insert.
|
|
592
|
+
* @returns Removed elements as a new list (`this` type).
|
|
593
|
+
* @remarks Time O(n + m), Space O(min(n, m)) where `m = items.length`
|
|
594
|
+
*/
|
|
595
|
+
splice(start, deleteCount = 0, ...items) {
|
|
596
|
+
const removedList = this._createInstance();
|
|
597
|
+
start = start < 0 ? this.length + start : start;
|
|
598
|
+
start = Math.max(0, Math.min(start, this.length));
|
|
599
|
+
deleteCount = Math.max(0, Math.min(deleteCount, this.length - start));
|
|
600
|
+
for (let i = 0; i < deleteCount; i++) {
|
|
601
|
+
const removed = this.deleteAt(start);
|
|
602
|
+
if (removed !== void 0) {
|
|
603
|
+
removedList.push(removed);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
for (let i = 0; i < items.length; i++) {
|
|
607
|
+
this.addAt(start + i, items[i]);
|
|
608
|
+
}
|
|
609
|
+
return removedList;
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Join all elements into a string.
|
|
613
|
+
* @param separator - Separator string.
|
|
614
|
+
* @returns Concatenated string.
|
|
615
|
+
* @remarks Time O(n), Space O(n)
|
|
616
|
+
*/
|
|
617
|
+
join(separator = ",") {
|
|
618
|
+
return this.toArray().join(separator);
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Snapshot elements into a reversed array.
|
|
622
|
+
* @returns New reversed array.
|
|
623
|
+
* @remarks Time O(n), Space O(n)
|
|
624
|
+
*/
|
|
625
|
+
toReversedArray() {
|
|
626
|
+
const array = [];
|
|
627
|
+
for (let i = this.length - 1; i >= 0; i--) {
|
|
628
|
+
array.push(this.at(i));
|
|
629
|
+
}
|
|
630
|
+
return array;
|
|
631
|
+
}
|
|
632
|
+
reduceRight(callbackfn, initialValue) {
|
|
633
|
+
let accumulator = initialValue != null ? initialValue : 0;
|
|
634
|
+
for (let i = this.length - 1; i >= 0; i--) {
|
|
635
|
+
accumulator = callbackfn(accumulator, this.at(i), i, this);
|
|
636
|
+
}
|
|
637
|
+
return accumulator;
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Create a shallow copy of a subrange.
|
|
641
|
+
* @param start - Inclusive start (supports negative index).
|
|
642
|
+
* @param end - Exclusive end (supports negative index).
|
|
643
|
+
* @returns New list with the range (`this` type).
|
|
644
|
+
* @remarks Time O(n), Space O(n)
|
|
645
|
+
*/
|
|
646
|
+
slice(start = 0, end = this.length) {
|
|
647
|
+
start = start < 0 ? this.length + start : start;
|
|
648
|
+
end = end < 0 ? this.length + end : end;
|
|
649
|
+
const newList = this._createInstance();
|
|
650
|
+
for (let i = start; i < end; i++) {
|
|
651
|
+
newList.push(this.at(i));
|
|
652
|
+
}
|
|
653
|
+
return newList;
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Fill a range with a value.
|
|
657
|
+
* @param value - Value to set.
|
|
658
|
+
* @param start - Inclusive start.
|
|
659
|
+
* @param end - Exclusive end.
|
|
660
|
+
* @returns This list.
|
|
661
|
+
* @remarks Time O(n), Space O(1)
|
|
662
|
+
*/
|
|
663
|
+
fill(value, start = 0, end = this.length) {
|
|
664
|
+
start = start < 0 ? this.length + start : start;
|
|
665
|
+
end = end < 0 ? this.length + end : end;
|
|
666
|
+
if (start < 0) start = 0;
|
|
667
|
+
if (end > this.length) end = this.length;
|
|
668
|
+
if (start >= end) return this;
|
|
669
|
+
for (let i = start; i < end; i++) {
|
|
670
|
+
this.setAt(i, value);
|
|
671
|
+
}
|
|
672
|
+
return this;
|
|
673
|
+
}
|
|
674
|
+
};
|
|
675
|
+
__name(_LinearBase, "LinearBase");
|
|
676
|
+
var LinearBase = _LinearBase;
|
|
677
|
+
|
|
480
678
|
// src/data-structures/heap/heap.ts
|
|
481
679
|
var _Heap = class _Heap extends IterableElementBase {
|
|
482
680
|
/**
|
|
@@ -492,7 +690,7 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
492
690
|
__publicField(this, "_elements", []);
|
|
493
691
|
__publicField(this, "_DEFAULT_COMPARATOR", /* @__PURE__ */ __name((a, b) => {
|
|
494
692
|
if (typeof a === "object" || typeof b === "object") {
|
|
495
|
-
|
|
693
|
+
raise(TypeError, ERR.comparatorRequired("Heap"));
|
|
496
694
|
}
|
|
497
695
|
if (a > b) return 1;
|
|
498
696
|
if (a < b) return -1;
|
|
@@ -528,6 +726,30 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
528
726
|
|
|
529
727
|
|
|
530
728
|
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
|
|
750
|
+
|
|
751
|
+
|
|
752
|
+
|
|
531
753
|
* @example
|
|
532
754
|
* // Track heap capacity
|
|
533
755
|
* const heap = new Heap<number>();
|
|
@@ -591,6 +813,30 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
591
813
|
|
|
592
814
|
|
|
593
815
|
|
|
816
|
+
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
|
|
820
|
+
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
|
|
594
840
|
* @example
|
|
595
841
|
* // basic Heap creation and add operation
|
|
596
842
|
* // Create a min heap (default)
|
|
@@ -624,6 +870,30 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
624
870
|
|
|
625
871
|
|
|
626
872
|
|
|
873
|
+
|
|
874
|
+
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
|
|
878
|
+
|
|
879
|
+
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
|
|
627
897
|
* @example
|
|
628
898
|
* // Add multiple elements
|
|
629
899
|
* const heap = new Heap<number>([], { comparator: (a, b) => a - b });
|
|
@@ -659,6 +929,30 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
659
929
|
|
|
660
930
|
|
|
661
931
|
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
|
|
935
|
+
|
|
936
|
+
|
|
937
|
+
|
|
938
|
+
|
|
939
|
+
|
|
940
|
+
|
|
941
|
+
|
|
942
|
+
|
|
943
|
+
|
|
944
|
+
|
|
945
|
+
|
|
946
|
+
|
|
947
|
+
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
|
|
952
|
+
|
|
953
|
+
|
|
954
|
+
|
|
955
|
+
|
|
662
956
|
* @example
|
|
663
957
|
* // Heap with custom comparator (MaxHeap behavior)
|
|
664
958
|
* interface Task {
|
|
@@ -710,6 +1004,30 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
710
1004
|
|
|
711
1005
|
|
|
712
1006
|
|
|
1007
|
+
|
|
1008
|
+
|
|
1009
|
+
|
|
1010
|
+
|
|
1011
|
+
|
|
1012
|
+
|
|
1013
|
+
|
|
1014
|
+
|
|
1015
|
+
|
|
1016
|
+
|
|
1017
|
+
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
|
|
1021
|
+
|
|
1022
|
+
|
|
1023
|
+
|
|
1024
|
+
|
|
1025
|
+
|
|
1026
|
+
|
|
1027
|
+
|
|
1028
|
+
|
|
1029
|
+
|
|
1030
|
+
|
|
713
1031
|
* @example
|
|
714
1032
|
* // Heap for event processing with priority
|
|
715
1033
|
* interface Event {
|
|
@@ -786,6 +1104,30 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
786
1104
|
|
|
787
1105
|
|
|
788
1106
|
|
|
1107
|
+
|
|
1108
|
+
|
|
1109
|
+
|
|
1110
|
+
|
|
1111
|
+
|
|
1112
|
+
|
|
1113
|
+
|
|
1114
|
+
|
|
1115
|
+
|
|
1116
|
+
|
|
1117
|
+
|
|
1118
|
+
|
|
1119
|
+
|
|
1120
|
+
|
|
1121
|
+
|
|
1122
|
+
|
|
1123
|
+
|
|
1124
|
+
|
|
1125
|
+
|
|
1126
|
+
|
|
1127
|
+
|
|
1128
|
+
|
|
1129
|
+
|
|
1130
|
+
|
|
789
1131
|
* @example
|
|
790
1132
|
* // Check if heap is empty
|
|
791
1133
|
* const heap = new Heap<number>([], { comparator: (a, b) => a - b });
|
|
@@ -809,6 +1151,30 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
809
1151
|
|
|
810
1152
|
|
|
811
1153
|
|
|
1154
|
+
|
|
1155
|
+
|
|
1156
|
+
|
|
1157
|
+
|
|
1158
|
+
|
|
1159
|
+
|
|
1160
|
+
|
|
1161
|
+
|
|
1162
|
+
|
|
1163
|
+
|
|
1164
|
+
|
|
1165
|
+
|
|
1166
|
+
|
|
1167
|
+
|
|
1168
|
+
|
|
1169
|
+
|
|
1170
|
+
|
|
1171
|
+
|
|
1172
|
+
|
|
1173
|
+
|
|
1174
|
+
|
|
1175
|
+
|
|
1176
|
+
|
|
1177
|
+
|
|
812
1178
|
* @example
|
|
813
1179
|
* // Remove all elements
|
|
814
1180
|
* const heap = new Heap<number>([1, 2, 3], { comparator: (a, b) => a - b });
|
|
@@ -835,6 +1201,30 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
835
1201
|
* @returns True if found.
|
|
836
1202
|
|
|
837
1203
|
|
|
1204
|
+
|
|
1205
|
+
|
|
1206
|
+
|
|
1207
|
+
|
|
1208
|
+
|
|
1209
|
+
|
|
1210
|
+
|
|
1211
|
+
|
|
1212
|
+
|
|
1213
|
+
|
|
1214
|
+
|
|
1215
|
+
|
|
1216
|
+
|
|
1217
|
+
|
|
1218
|
+
|
|
1219
|
+
|
|
1220
|
+
|
|
1221
|
+
|
|
1222
|
+
|
|
1223
|
+
|
|
1224
|
+
|
|
1225
|
+
|
|
1226
|
+
|
|
1227
|
+
|
|
838
1228
|
* @example
|
|
839
1229
|
* // Check element existence
|
|
840
1230
|
* const heap = new Heap<number>([3, 1, 2], { comparator: (a, b) => a - b });
|
|
@@ -858,6 +1248,30 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
858
1248
|
|
|
859
1249
|
|
|
860
1250
|
|
|
1251
|
+
|
|
1252
|
+
|
|
1253
|
+
|
|
1254
|
+
|
|
1255
|
+
|
|
1256
|
+
|
|
1257
|
+
|
|
1258
|
+
|
|
1259
|
+
|
|
1260
|
+
|
|
1261
|
+
|
|
1262
|
+
|
|
1263
|
+
|
|
1264
|
+
|
|
1265
|
+
|
|
1266
|
+
|
|
1267
|
+
|
|
1268
|
+
|
|
1269
|
+
|
|
1270
|
+
|
|
1271
|
+
|
|
1272
|
+
|
|
1273
|
+
|
|
1274
|
+
|
|
861
1275
|
* @example
|
|
862
1276
|
* // Remove specific element
|
|
863
1277
|
* const heap = new Heap<number>([3, 1, 4, 1, 5], { comparator: (a, b) => a - b });
|
|
@@ -927,6 +1341,30 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
927
1341
|
* @returns Array of visited elements.
|
|
928
1342
|
|
|
929
1343
|
|
|
1344
|
+
|
|
1345
|
+
|
|
1346
|
+
|
|
1347
|
+
|
|
1348
|
+
|
|
1349
|
+
|
|
1350
|
+
|
|
1351
|
+
|
|
1352
|
+
|
|
1353
|
+
|
|
1354
|
+
|
|
1355
|
+
|
|
1356
|
+
|
|
1357
|
+
|
|
1358
|
+
|
|
1359
|
+
|
|
1360
|
+
|
|
1361
|
+
|
|
1362
|
+
|
|
1363
|
+
|
|
1364
|
+
|
|
1365
|
+
|
|
1366
|
+
|
|
1367
|
+
|
|
930
1368
|
* @example
|
|
931
1369
|
* // Depth-first traversal
|
|
932
1370
|
* const heap = new Heap<number>([3, 1, 2], { comparator: (a, b) => a - b });
|
|
@@ -983,6 +1421,30 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
983
1421
|
|
|
984
1422
|
|
|
985
1423
|
|
|
1424
|
+
|
|
1425
|
+
|
|
1426
|
+
|
|
1427
|
+
|
|
1428
|
+
|
|
1429
|
+
|
|
1430
|
+
|
|
1431
|
+
|
|
1432
|
+
|
|
1433
|
+
|
|
1434
|
+
|
|
1435
|
+
|
|
1436
|
+
|
|
1437
|
+
|
|
1438
|
+
|
|
1439
|
+
|
|
1440
|
+
|
|
1441
|
+
|
|
1442
|
+
|
|
1443
|
+
|
|
1444
|
+
|
|
1445
|
+
|
|
1446
|
+
|
|
1447
|
+
|
|
986
1448
|
* @example
|
|
987
1449
|
* // Sort elements using heap
|
|
988
1450
|
* const heap = new Heap<number>([5, 1, 3, 2, 4]);
|
|
@@ -1012,6 +1474,30 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1012
1474
|
|
|
1013
1475
|
|
|
1014
1476
|
|
|
1477
|
+
|
|
1478
|
+
|
|
1479
|
+
|
|
1480
|
+
|
|
1481
|
+
|
|
1482
|
+
|
|
1483
|
+
|
|
1484
|
+
|
|
1485
|
+
|
|
1486
|
+
|
|
1487
|
+
|
|
1488
|
+
|
|
1489
|
+
|
|
1490
|
+
|
|
1491
|
+
|
|
1492
|
+
|
|
1493
|
+
|
|
1494
|
+
|
|
1495
|
+
|
|
1496
|
+
|
|
1497
|
+
|
|
1498
|
+
|
|
1499
|
+
|
|
1500
|
+
|
|
1015
1501
|
* @example
|
|
1016
1502
|
* // Create independent copy
|
|
1017
1503
|
* const heap = new Heap<number>([3, 1, 4], { comparator: (a, b) => a - b });
|
|
@@ -1040,6 +1526,30 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1040
1526
|
|
|
1041
1527
|
|
|
1042
1528
|
|
|
1529
|
+
|
|
1530
|
+
|
|
1531
|
+
|
|
1532
|
+
|
|
1533
|
+
|
|
1534
|
+
|
|
1535
|
+
|
|
1536
|
+
|
|
1537
|
+
|
|
1538
|
+
|
|
1539
|
+
|
|
1540
|
+
|
|
1541
|
+
|
|
1542
|
+
|
|
1543
|
+
|
|
1544
|
+
|
|
1545
|
+
|
|
1546
|
+
|
|
1547
|
+
|
|
1548
|
+
|
|
1549
|
+
|
|
1550
|
+
|
|
1551
|
+
|
|
1552
|
+
|
|
1043
1553
|
* @example
|
|
1044
1554
|
* // Filter elements
|
|
1045
1555
|
* const heap = new Heap<number>([1, 2, 3, 4, 5], { comparator: (a, b) => a - b });
|
|
@@ -1075,6 +1585,30 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1075
1585
|
|
|
1076
1586
|
|
|
1077
1587
|
|
|
1588
|
+
|
|
1589
|
+
|
|
1590
|
+
|
|
1591
|
+
|
|
1592
|
+
|
|
1593
|
+
|
|
1594
|
+
|
|
1595
|
+
|
|
1596
|
+
|
|
1597
|
+
|
|
1598
|
+
|
|
1599
|
+
|
|
1600
|
+
|
|
1601
|
+
|
|
1602
|
+
|
|
1603
|
+
|
|
1604
|
+
|
|
1605
|
+
|
|
1606
|
+
|
|
1607
|
+
|
|
1608
|
+
|
|
1609
|
+
|
|
1610
|
+
|
|
1611
|
+
|
|
1078
1612
|
* @example
|
|
1079
1613
|
* // Transform elements
|
|
1080
1614
|
* const heap = new Heap<number>([1, 2, 3], { comparator: (a, b) => a - b });
|
|
@@ -1083,7 +1617,7 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1083
1617
|
*/
|
|
1084
1618
|
map(callback, options, thisArg) {
|
|
1085
1619
|
const { comparator, toElementFn, ...rest } = options != null ? options : {};
|
|
1086
|
-
if (!comparator)
|
|
1620
|
+
if (!comparator) raise(TypeError, ERR.comparatorRequired("Heap.map"));
|
|
1087
1621
|
const out = this._createLike([], { ...rest, comparator, toElementFn });
|
|
1088
1622
|
let i = 0;
|
|
1089
1623
|
for (const x of this) {
|
|
@@ -1170,213 +1704,21 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1170
1704
|
_createLike(elements = [], options) {
|
|
1171
1705
|
const Ctor = this.constructor;
|
|
1172
1706
|
return new Ctor(elements, options);
|
|
1173
|
-
}
|
|
1174
|
-
/**
|
|
1175
|
-
* (Protected) Spawn an empty like-kind heap instance.
|
|
1176
|
-
* @remarks Time O(1), Space O(1)
|
|
1177
|
-
* @template EM
|
|
1178
|
-
* @template RM
|
|
1179
|
-
* @param [options] - Options forwarded to the constructor.
|
|
1180
|
-
* @returns An empty like-kind heap instance.
|
|
1181
|
-
*/
|
|
1182
|
-
_spawnLike(options) {
|
|
1183
|
-
return this._createLike([], options);
|
|
1184
|
-
}
|
|
1185
|
-
};
|
|
1186
|
-
__name(_Heap, "Heap");
|
|
1187
|
-
var Heap = _Heap;
|
|
1188
|
-
|
|
1189
|
-
// src/data-structures/base/linear-base.ts
|
|
1190
|
-
var _LinearBase = class _LinearBase extends IterableElementBase {
|
|
1191
|
-
/**
|
|
1192
|
-
* Construct a linear container with runtime options.
|
|
1193
|
-
* @param options - `{ maxLen?, ... }` bounds/behavior options.
|
|
1194
|
-
* @remarks Time O(1), Space O(1)
|
|
1195
|
-
*/
|
|
1196
|
-
constructor(options) {
|
|
1197
|
-
super(options);
|
|
1198
|
-
__publicField(this, "_maxLen", -1);
|
|
1199
|
-
if (options) {
|
|
1200
|
-
const { maxLen } = options;
|
|
1201
|
-
if (typeof maxLen === "number" && maxLen > 0 && maxLen % 1 === 0) this._maxLen = maxLen;
|
|
1202
|
-
}
|
|
1203
|
-
}
|
|
1204
|
-
/**
|
|
1205
|
-
* Upper bound for length (if positive), or `-1` when unbounded.
|
|
1206
|
-
* @returns Maximum allowed length.
|
|
1207
|
-
* @remarks Time O(1), Space O(1)
|
|
1208
|
-
*/
|
|
1209
|
-
get maxLen() {
|
|
1210
|
-
return this._maxLen;
|
|
1211
|
-
}
|
|
1212
|
-
/**
|
|
1213
|
-
* First index of a value from the left.
|
|
1214
|
-
* @param searchElement - Value to match.
|
|
1215
|
-
* @param fromIndex - Start position (supports negative index).
|
|
1216
|
-
* @returns Index or `-1` if not found.
|
|
1217
|
-
* @remarks Time O(n), Space O(1)
|
|
1218
|
-
*/
|
|
1219
|
-
indexOf(searchElement, fromIndex = 0) {
|
|
1220
|
-
if (this.length === 0) return -1;
|
|
1221
|
-
if (fromIndex < 0) fromIndex = this.length + fromIndex;
|
|
1222
|
-
if (fromIndex < 0) fromIndex = 0;
|
|
1223
|
-
for (let i = fromIndex; i < this.length; i++) {
|
|
1224
|
-
const element = this.at(i);
|
|
1225
|
-
if (element === searchElement) return i;
|
|
1226
|
-
}
|
|
1227
|
-
return -1;
|
|
1228
|
-
}
|
|
1229
|
-
/**
|
|
1230
|
-
* Last index of a value from the right.
|
|
1231
|
-
* @param searchElement - Value to match.
|
|
1232
|
-
* @param fromIndex - Start position (supports negative index).
|
|
1233
|
-
* @returns Index or `-1` if not found.
|
|
1234
|
-
* @remarks Time O(n), Space O(1)
|
|
1235
|
-
*/
|
|
1236
|
-
lastIndexOf(searchElement, fromIndex = this.length - 1) {
|
|
1237
|
-
if (this.length === 0) return -1;
|
|
1238
|
-
if (fromIndex >= this.length) fromIndex = this.length - 1;
|
|
1239
|
-
if (fromIndex < 0) fromIndex = this.length + fromIndex;
|
|
1240
|
-
for (let i = fromIndex; i >= 0; i--) {
|
|
1241
|
-
const element = this.at(i);
|
|
1242
|
-
if (element === searchElement) return i;
|
|
1243
|
-
}
|
|
1244
|
-
return -1;
|
|
1245
|
-
}
|
|
1246
|
-
/**
|
|
1247
|
-
* Find the first index matching a predicate.
|
|
1248
|
-
* @param predicate - `(element, index, self) => boolean`.
|
|
1249
|
-
* @param thisArg - Optional `this` for callback.
|
|
1250
|
-
* @returns Index or `-1`.
|
|
1251
|
-
* @remarks Time O(n), Space O(1)
|
|
1252
|
-
*/
|
|
1253
|
-
findIndex(predicate, thisArg) {
|
|
1254
|
-
for (let i = 0; i < this.length; i++) {
|
|
1255
|
-
const item = this.at(i);
|
|
1256
|
-
if (item !== void 0 && predicate.call(thisArg, item, i, this)) return i;
|
|
1257
|
-
}
|
|
1258
|
-
return -1;
|
|
1259
|
-
}
|
|
1260
|
-
/**
|
|
1261
|
-
* Concatenate elements and/or containers.
|
|
1262
|
-
* @param items - Elements or other containers.
|
|
1263
|
-
* @returns New container with combined elements (`this` type).
|
|
1264
|
-
* @remarks Time O(sum(length)), Space O(sum(length))
|
|
1265
|
-
*/
|
|
1266
|
-
concat(...items) {
|
|
1267
|
-
const newList = this.clone();
|
|
1268
|
-
for (const item of items) {
|
|
1269
|
-
if (item instanceof _LinearBase) {
|
|
1270
|
-
newList.pushMany(item);
|
|
1271
|
-
} else {
|
|
1272
|
-
newList.push(item);
|
|
1273
|
-
}
|
|
1274
|
-
}
|
|
1275
|
-
return newList;
|
|
1276
|
-
}
|
|
1277
|
-
/**
|
|
1278
|
-
* In-place stable order via array sort semantics.
|
|
1279
|
-
* @param compareFn - Comparator `(a, b) => number`.
|
|
1280
|
-
* @returns This container.
|
|
1281
|
-
* @remarks Time O(n log n), Space O(n) (materializes to array temporarily)
|
|
1282
|
-
*/
|
|
1283
|
-
sort(compareFn) {
|
|
1284
|
-
const arr = this.toArray();
|
|
1285
|
-
arr.sort(compareFn);
|
|
1286
|
-
this.clear();
|
|
1287
|
-
for (const item of arr) this.push(item);
|
|
1288
|
-
return this;
|
|
1289
|
-
}
|
|
1290
|
-
/**
|
|
1291
|
-
* Remove and/or insert elements at a position (array-compatible).
|
|
1292
|
-
* @param start - Start index (supports negative index).
|
|
1293
|
-
* @param deleteCount - How many to remove.
|
|
1294
|
-
* @param items - Elements to insert.
|
|
1295
|
-
* @returns Removed elements as a new list (`this` type).
|
|
1296
|
-
* @remarks Time O(n + m), Space O(min(n, m)) where `m = items.length`
|
|
1297
|
-
*/
|
|
1298
|
-
splice(start, deleteCount = 0, ...items) {
|
|
1299
|
-
const removedList = this._createInstance();
|
|
1300
|
-
start = start < 0 ? this.length + start : start;
|
|
1301
|
-
start = Math.max(0, Math.min(start, this.length));
|
|
1302
|
-
deleteCount = Math.max(0, Math.min(deleteCount, this.length - start));
|
|
1303
|
-
for (let i = 0; i < deleteCount; i++) {
|
|
1304
|
-
const removed = this.deleteAt(start);
|
|
1305
|
-
if (removed !== void 0) {
|
|
1306
|
-
removedList.push(removed);
|
|
1307
|
-
}
|
|
1308
|
-
}
|
|
1309
|
-
for (let i = 0; i < items.length; i++) {
|
|
1310
|
-
this.addAt(start + i, items[i]);
|
|
1311
|
-
}
|
|
1312
|
-
return removedList;
|
|
1313
|
-
}
|
|
1314
|
-
/**
|
|
1315
|
-
* Join all elements into a string.
|
|
1316
|
-
* @param separator - Separator string.
|
|
1317
|
-
* @returns Concatenated string.
|
|
1318
|
-
* @remarks Time O(n), Space O(n)
|
|
1319
|
-
*/
|
|
1320
|
-
join(separator = ",") {
|
|
1321
|
-
return this.toArray().join(separator);
|
|
1322
|
-
}
|
|
1323
|
-
/**
|
|
1324
|
-
* Snapshot elements into a reversed array.
|
|
1325
|
-
* @returns New reversed array.
|
|
1326
|
-
* @remarks Time O(n), Space O(n)
|
|
1327
|
-
*/
|
|
1328
|
-
toReversedArray() {
|
|
1329
|
-
const array = [];
|
|
1330
|
-
for (let i = this.length - 1; i >= 0; i--) {
|
|
1331
|
-
array.push(this.at(i));
|
|
1332
|
-
}
|
|
1333
|
-
return array;
|
|
1334
|
-
}
|
|
1335
|
-
reduceRight(callbackfn, initialValue) {
|
|
1336
|
-
let accumulator = initialValue != null ? initialValue : 0;
|
|
1337
|
-
for (let i = this.length - 1; i >= 0; i--) {
|
|
1338
|
-
accumulator = callbackfn(accumulator, this.at(i), i, this);
|
|
1339
|
-
}
|
|
1340
|
-
return accumulator;
|
|
1341
|
-
}
|
|
1342
|
-
/**
|
|
1343
|
-
* Create a shallow copy of a subrange.
|
|
1344
|
-
* @param start - Inclusive start (supports negative index).
|
|
1345
|
-
* @param end - Exclusive end (supports negative index).
|
|
1346
|
-
* @returns New list with the range (`this` type).
|
|
1347
|
-
* @remarks Time O(n), Space O(n)
|
|
1348
|
-
*/
|
|
1349
|
-
slice(start = 0, end = this.length) {
|
|
1350
|
-
start = start < 0 ? this.length + start : start;
|
|
1351
|
-
end = end < 0 ? this.length + end : end;
|
|
1352
|
-
const newList = this._createInstance();
|
|
1353
|
-
for (let i = start; i < end; i++) {
|
|
1354
|
-
newList.push(this.at(i));
|
|
1355
|
-
}
|
|
1356
|
-
return newList;
|
|
1357
|
-
}
|
|
1358
|
-
/**
|
|
1359
|
-
* Fill a range with a value.
|
|
1360
|
-
* @param value - Value to set.
|
|
1361
|
-
* @param start - Inclusive start.
|
|
1362
|
-
* @param end - Exclusive end.
|
|
1363
|
-
* @returns This list.
|
|
1364
|
-
* @remarks Time O(n), Space O(1)
|
|
1707
|
+
}
|
|
1708
|
+
/**
|
|
1709
|
+
* (Protected) Spawn an empty like-kind heap instance.
|
|
1710
|
+
* @remarks Time O(1), Space O(1)
|
|
1711
|
+
* @template EM
|
|
1712
|
+
* @template RM
|
|
1713
|
+
* @param [options] - Options forwarded to the constructor.
|
|
1714
|
+
* @returns An empty like-kind heap instance.
|
|
1365
1715
|
*/
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
end = end < 0 ? this.length + end : end;
|
|
1369
|
-
if (start < 0) start = 0;
|
|
1370
|
-
if (end > this.length) end = this.length;
|
|
1371
|
-
if (start >= end) return this;
|
|
1372
|
-
for (let i = start; i < end; i++) {
|
|
1373
|
-
this.setAt(i, value);
|
|
1374
|
-
}
|
|
1375
|
-
return this;
|
|
1716
|
+
_spawnLike(options) {
|
|
1717
|
+
return this._createLike([], options);
|
|
1376
1718
|
}
|
|
1377
1719
|
};
|
|
1378
|
-
__name(
|
|
1379
|
-
var
|
|
1720
|
+
__name(_Heap, "Heap");
|
|
1721
|
+
var Heap = _Heap;
|
|
1380
1722
|
|
|
1381
1723
|
// src/data-structures/queue/queue.ts
|
|
1382
1724
|
var _Queue = class _Queue extends LinearBase {
|
|
@@ -1446,6 +1788,30 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1446
1788
|
|
|
1447
1789
|
|
|
1448
1790
|
|
|
1791
|
+
|
|
1792
|
+
|
|
1793
|
+
|
|
1794
|
+
|
|
1795
|
+
|
|
1796
|
+
|
|
1797
|
+
|
|
1798
|
+
|
|
1799
|
+
|
|
1800
|
+
|
|
1801
|
+
|
|
1802
|
+
|
|
1803
|
+
|
|
1804
|
+
|
|
1805
|
+
|
|
1806
|
+
|
|
1807
|
+
|
|
1808
|
+
|
|
1809
|
+
|
|
1810
|
+
|
|
1811
|
+
|
|
1812
|
+
|
|
1813
|
+
|
|
1814
|
+
|
|
1449
1815
|
* @example
|
|
1450
1816
|
* // Track queue length
|
|
1451
1817
|
* const q = new Queue<number>();
|
|
@@ -1472,6 +1838,30 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1472
1838
|
|
|
1473
1839
|
|
|
1474
1840
|
|
|
1841
|
+
|
|
1842
|
+
|
|
1843
|
+
|
|
1844
|
+
|
|
1845
|
+
|
|
1846
|
+
|
|
1847
|
+
|
|
1848
|
+
|
|
1849
|
+
|
|
1850
|
+
|
|
1851
|
+
|
|
1852
|
+
|
|
1853
|
+
|
|
1854
|
+
|
|
1855
|
+
|
|
1856
|
+
|
|
1857
|
+
|
|
1858
|
+
|
|
1859
|
+
|
|
1860
|
+
|
|
1861
|
+
|
|
1862
|
+
|
|
1863
|
+
|
|
1864
|
+
|
|
1475
1865
|
* @example
|
|
1476
1866
|
* // View the front element
|
|
1477
1867
|
* const q = new Queue<string>(['first', 'second', 'third']);
|
|
@@ -1514,6 +1904,30 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1514
1904
|
|
|
1515
1905
|
|
|
1516
1906
|
|
|
1907
|
+
|
|
1908
|
+
|
|
1909
|
+
|
|
1910
|
+
|
|
1911
|
+
|
|
1912
|
+
|
|
1913
|
+
|
|
1914
|
+
|
|
1915
|
+
|
|
1916
|
+
|
|
1917
|
+
|
|
1918
|
+
|
|
1919
|
+
|
|
1920
|
+
|
|
1921
|
+
|
|
1922
|
+
|
|
1923
|
+
|
|
1924
|
+
|
|
1925
|
+
|
|
1926
|
+
|
|
1927
|
+
|
|
1928
|
+
|
|
1929
|
+
|
|
1930
|
+
|
|
1517
1931
|
* @example
|
|
1518
1932
|
* // Queue for...of iteration and isEmpty check
|
|
1519
1933
|
* const queue = new Queue<string>(['A', 'B', 'C', 'D']);
|
|
@@ -1552,6 +1966,30 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1552
1966
|
|
|
1553
1967
|
|
|
1554
1968
|
|
|
1969
|
+
|
|
1970
|
+
|
|
1971
|
+
|
|
1972
|
+
|
|
1973
|
+
|
|
1974
|
+
|
|
1975
|
+
|
|
1976
|
+
|
|
1977
|
+
|
|
1978
|
+
|
|
1979
|
+
|
|
1980
|
+
|
|
1981
|
+
|
|
1982
|
+
|
|
1983
|
+
|
|
1984
|
+
|
|
1985
|
+
|
|
1986
|
+
|
|
1987
|
+
|
|
1988
|
+
|
|
1989
|
+
|
|
1990
|
+
|
|
1991
|
+
|
|
1992
|
+
|
|
1555
1993
|
* @example
|
|
1556
1994
|
* // basic Queue creation and push operation
|
|
1557
1995
|
* // Create a simple Queue with initial values
|
|
@@ -1597,6 +2035,30 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1597
2035
|
|
|
1598
2036
|
|
|
1599
2037
|
|
|
2038
|
+
|
|
2039
|
+
|
|
2040
|
+
|
|
2041
|
+
|
|
2042
|
+
|
|
2043
|
+
|
|
2044
|
+
|
|
2045
|
+
|
|
2046
|
+
|
|
2047
|
+
|
|
2048
|
+
|
|
2049
|
+
|
|
2050
|
+
|
|
2051
|
+
|
|
2052
|
+
|
|
2053
|
+
|
|
2054
|
+
|
|
2055
|
+
|
|
2056
|
+
|
|
2057
|
+
|
|
2058
|
+
|
|
2059
|
+
|
|
2060
|
+
|
|
2061
|
+
|
|
1600
2062
|
* @example
|
|
1601
2063
|
* // Queue shift and peek operations
|
|
1602
2064
|
* const queue = new Queue<number>([10, 20, 30, 40]);
|
|
@@ -1632,6 +2094,30 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1632
2094
|
|
|
1633
2095
|
|
|
1634
2096
|
|
|
2097
|
+
|
|
2098
|
+
|
|
2099
|
+
|
|
2100
|
+
|
|
2101
|
+
|
|
2102
|
+
|
|
2103
|
+
|
|
2104
|
+
|
|
2105
|
+
|
|
2106
|
+
|
|
2107
|
+
|
|
2108
|
+
|
|
2109
|
+
|
|
2110
|
+
|
|
2111
|
+
|
|
2112
|
+
|
|
2113
|
+
|
|
2114
|
+
|
|
2115
|
+
|
|
2116
|
+
|
|
2117
|
+
|
|
2118
|
+
|
|
2119
|
+
|
|
2120
|
+
|
|
1635
2121
|
* @example
|
|
1636
2122
|
* // Remove specific element
|
|
1637
2123
|
* const q = new Queue<number>([1, 2, 3, 2]);
|
|
@@ -1660,6 +2146,30 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1660
2146
|
|
|
1661
2147
|
|
|
1662
2148
|
|
|
2149
|
+
|
|
2150
|
+
|
|
2151
|
+
|
|
2152
|
+
|
|
2153
|
+
|
|
2154
|
+
|
|
2155
|
+
|
|
2156
|
+
|
|
2157
|
+
|
|
2158
|
+
|
|
2159
|
+
|
|
2160
|
+
|
|
2161
|
+
|
|
2162
|
+
|
|
2163
|
+
|
|
2164
|
+
|
|
2165
|
+
|
|
2166
|
+
|
|
2167
|
+
|
|
2168
|
+
|
|
2169
|
+
|
|
2170
|
+
|
|
2171
|
+
|
|
2172
|
+
|
|
1663
2173
|
* @example
|
|
1664
2174
|
* // Access element by index
|
|
1665
2175
|
* const q = new Queue<string>(['a', 'b', 'c']);
|
|
@@ -1729,6 +2239,30 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1729
2239
|
|
|
1730
2240
|
|
|
1731
2241
|
|
|
2242
|
+
|
|
2243
|
+
|
|
2244
|
+
|
|
2245
|
+
|
|
2246
|
+
|
|
2247
|
+
|
|
2248
|
+
|
|
2249
|
+
|
|
2250
|
+
|
|
2251
|
+
|
|
2252
|
+
|
|
2253
|
+
|
|
2254
|
+
|
|
2255
|
+
|
|
2256
|
+
|
|
2257
|
+
|
|
2258
|
+
|
|
2259
|
+
|
|
2260
|
+
|
|
2261
|
+
|
|
2262
|
+
|
|
2263
|
+
|
|
2264
|
+
|
|
2265
|
+
|
|
1732
2266
|
* @example
|
|
1733
2267
|
* // Remove all elements
|
|
1734
2268
|
* const q = new Queue<number>([1, 2, 3]);
|
|
@@ -1751,6 +2285,30 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1751
2285
|
|
|
1752
2286
|
|
|
1753
2287
|
|
|
2288
|
+
|
|
2289
|
+
|
|
2290
|
+
|
|
2291
|
+
|
|
2292
|
+
|
|
2293
|
+
|
|
2294
|
+
|
|
2295
|
+
|
|
2296
|
+
|
|
2297
|
+
|
|
2298
|
+
|
|
2299
|
+
|
|
2300
|
+
|
|
2301
|
+
|
|
2302
|
+
|
|
2303
|
+
|
|
2304
|
+
|
|
2305
|
+
|
|
2306
|
+
|
|
2307
|
+
|
|
2308
|
+
|
|
2309
|
+
|
|
2310
|
+
|
|
2311
|
+
|
|
1754
2312
|
* @example
|
|
1755
2313
|
* // Reclaim unused memory
|
|
1756
2314
|
* const q = new Queue<number>([1, 2, 3, 4, 5]);
|
|
@@ -1796,6 +2354,30 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1796
2354
|
|
|
1797
2355
|
|
|
1798
2356
|
|
|
2357
|
+
|
|
2358
|
+
|
|
2359
|
+
|
|
2360
|
+
|
|
2361
|
+
|
|
2362
|
+
|
|
2363
|
+
|
|
2364
|
+
|
|
2365
|
+
|
|
2366
|
+
|
|
2367
|
+
|
|
2368
|
+
|
|
2369
|
+
|
|
2370
|
+
|
|
2371
|
+
|
|
2372
|
+
|
|
2373
|
+
|
|
2374
|
+
|
|
2375
|
+
|
|
2376
|
+
|
|
2377
|
+
|
|
2378
|
+
|
|
2379
|
+
|
|
2380
|
+
|
|
1799
2381
|
* @example
|
|
1800
2382
|
* // Create independent copy
|
|
1801
2383
|
* const q = new Queue<number>([1, 2, 3]);
|
|
@@ -1825,6 +2407,30 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1825
2407
|
|
|
1826
2408
|
|
|
1827
2409
|
|
|
2410
|
+
|
|
2411
|
+
|
|
2412
|
+
|
|
2413
|
+
|
|
2414
|
+
|
|
2415
|
+
|
|
2416
|
+
|
|
2417
|
+
|
|
2418
|
+
|
|
2419
|
+
|
|
2420
|
+
|
|
2421
|
+
|
|
2422
|
+
|
|
2423
|
+
|
|
2424
|
+
|
|
2425
|
+
|
|
2426
|
+
|
|
2427
|
+
|
|
2428
|
+
|
|
2429
|
+
|
|
2430
|
+
|
|
2431
|
+
|
|
2432
|
+
|
|
2433
|
+
|
|
1828
2434
|
* @example
|
|
1829
2435
|
* // Filter elements
|
|
1830
2436
|
* const q = new Queue<number>([1, 2, 3, 4, 5]);
|
|
@@ -1858,6 +2464,30 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1858
2464
|
|
|
1859
2465
|
|
|
1860
2466
|
|
|
2467
|
+
|
|
2468
|
+
|
|
2469
|
+
|
|
2470
|
+
|
|
2471
|
+
|
|
2472
|
+
|
|
2473
|
+
|
|
2474
|
+
|
|
2475
|
+
|
|
2476
|
+
|
|
2477
|
+
|
|
2478
|
+
|
|
2479
|
+
|
|
2480
|
+
|
|
2481
|
+
|
|
2482
|
+
|
|
2483
|
+
|
|
2484
|
+
|
|
2485
|
+
|
|
2486
|
+
|
|
2487
|
+
|
|
2488
|
+
|
|
2489
|
+
|
|
2490
|
+
|
|
1861
2491
|
* @example
|
|
1862
2492
|
* // Transform elements
|
|
1863
2493
|
* const q = new Queue<number>([1, 2, 3]);
|
|
@@ -2092,7 +2722,7 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
|
|
|
2092
2722
|
const newEdge = this.createEdge(srcOrEdge, dest, weight, value);
|
|
2093
2723
|
return this._addEdge(newEdge);
|
|
2094
2724
|
} else {
|
|
2095
|
-
|
|
2725
|
+
raise(TypeError, ERR.invalidArgument("dest must be a Vertex or vertex key when srcOrEdge is an Edge.", "Graph"));
|
|
2096
2726
|
}
|
|
2097
2727
|
}
|
|
2098
2728
|
}
|
|
@@ -2976,6 +3606,30 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
2976
3606
|
|
|
2977
3607
|
|
|
2978
3608
|
|
|
3609
|
+
|
|
3610
|
+
|
|
3611
|
+
|
|
3612
|
+
|
|
3613
|
+
|
|
3614
|
+
|
|
3615
|
+
|
|
3616
|
+
|
|
3617
|
+
|
|
3618
|
+
|
|
3619
|
+
|
|
3620
|
+
|
|
3621
|
+
|
|
3622
|
+
|
|
3623
|
+
|
|
3624
|
+
|
|
3625
|
+
|
|
3626
|
+
|
|
3627
|
+
|
|
3628
|
+
|
|
3629
|
+
|
|
3630
|
+
|
|
3631
|
+
|
|
3632
|
+
|
|
2979
3633
|
* @example
|
|
2980
3634
|
* // Get edge between vertices
|
|
2981
3635
|
* const g = new DirectedGraph();
|
|
@@ -3040,6 +3694,30 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3040
3694
|
|
|
3041
3695
|
|
|
3042
3696
|
|
|
3697
|
+
|
|
3698
|
+
|
|
3699
|
+
|
|
3700
|
+
|
|
3701
|
+
|
|
3702
|
+
|
|
3703
|
+
|
|
3704
|
+
|
|
3705
|
+
|
|
3706
|
+
|
|
3707
|
+
|
|
3708
|
+
|
|
3709
|
+
|
|
3710
|
+
|
|
3711
|
+
|
|
3712
|
+
|
|
3713
|
+
|
|
3714
|
+
|
|
3715
|
+
|
|
3716
|
+
|
|
3717
|
+
|
|
3718
|
+
|
|
3719
|
+
|
|
3720
|
+
|
|
3043
3721
|
* @example
|
|
3044
3722
|
* // DirectedGraph deleteEdge and vertex operations
|
|
3045
3723
|
* const graph = new DirectedGraph<string>();
|
|
@@ -3102,6 +3780,30 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3102
3780
|
|
|
3103
3781
|
|
|
3104
3782
|
|
|
3783
|
+
|
|
3784
|
+
|
|
3785
|
+
|
|
3786
|
+
|
|
3787
|
+
|
|
3788
|
+
|
|
3789
|
+
|
|
3790
|
+
|
|
3791
|
+
|
|
3792
|
+
|
|
3793
|
+
|
|
3794
|
+
|
|
3795
|
+
|
|
3796
|
+
|
|
3797
|
+
|
|
3798
|
+
|
|
3799
|
+
|
|
3800
|
+
|
|
3801
|
+
|
|
3802
|
+
|
|
3803
|
+
|
|
3804
|
+
|
|
3805
|
+
|
|
3806
|
+
|
|
3105
3807
|
* @example
|
|
3106
3808
|
* // Remove a vertex
|
|
3107
3809
|
* const g = new DirectedGraph();
|
|
@@ -3155,6 +3857,30 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3155
3857
|
|
|
3156
3858
|
|
|
3157
3859
|
|
|
3860
|
+
|
|
3861
|
+
|
|
3862
|
+
|
|
3863
|
+
|
|
3864
|
+
|
|
3865
|
+
|
|
3866
|
+
|
|
3867
|
+
|
|
3868
|
+
|
|
3869
|
+
|
|
3870
|
+
|
|
3871
|
+
|
|
3872
|
+
|
|
3873
|
+
|
|
3874
|
+
|
|
3875
|
+
|
|
3876
|
+
|
|
3877
|
+
|
|
3878
|
+
|
|
3879
|
+
|
|
3880
|
+
|
|
3881
|
+
|
|
3882
|
+
|
|
3883
|
+
|
|
3158
3884
|
* @example
|
|
3159
3885
|
* // Get incoming edges
|
|
3160
3886
|
* const g = new DirectedGraph();
|
|
@@ -3185,6 +3911,30 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3185
3911
|
|
|
3186
3912
|
|
|
3187
3913
|
|
|
3914
|
+
|
|
3915
|
+
|
|
3916
|
+
|
|
3917
|
+
|
|
3918
|
+
|
|
3919
|
+
|
|
3920
|
+
|
|
3921
|
+
|
|
3922
|
+
|
|
3923
|
+
|
|
3924
|
+
|
|
3925
|
+
|
|
3926
|
+
|
|
3927
|
+
|
|
3928
|
+
|
|
3929
|
+
|
|
3930
|
+
|
|
3931
|
+
|
|
3932
|
+
|
|
3933
|
+
|
|
3934
|
+
|
|
3935
|
+
|
|
3936
|
+
|
|
3937
|
+
|
|
3188
3938
|
* @example
|
|
3189
3939
|
* // Get outgoing edges
|
|
3190
3940
|
* const g = new DirectedGraph();
|
|
@@ -3268,6 +4018,30 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3268
4018
|
|
|
3269
4019
|
|
|
3270
4020
|
|
|
4021
|
+
|
|
4022
|
+
|
|
4023
|
+
|
|
4024
|
+
|
|
4025
|
+
|
|
4026
|
+
|
|
4027
|
+
|
|
4028
|
+
|
|
4029
|
+
|
|
4030
|
+
|
|
4031
|
+
|
|
4032
|
+
|
|
4033
|
+
|
|
4034
|
+
|
|
4035
|
+
|
|
4036
|
+
|
|
4037
|
+
|
|
4038
|
+
|
|
4039
|
+
|
|
4040
|
+
|
|
4041
|
+
|
|
4042
|
+
|
|
4043
|
+
|
|
4044
|
+
|
|
3271
4045
|
* @example
|
|
3272
4046
|
* // DirectedGraph topologicalSort for task scheduling
|
|
3273
4047
|
* const graph = new DirectedGraph<string>();
|
|
@@ -3332,6 +4106,30 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3332
4106
|
|
|
3333
4107
|
|
|
3334
4108
|
|
|
4109
|
+
|
|
4110
|
+
|
|
4111
|
+
|
|
4112
|
+
|
|
4113
|
+
|
|
4114
|
+
|
|
4115
|
+
|
|
4116
|
+
|
|
4117
|
+
|
|
4118
|
+
|
|
4119
|
+
|
|
4120
|
+
|
|
4121
|
+
|
|
4122
|
+
|
|
4123
|
+
|
|
4124
|
+
|
|
4125
|
+
|
|
4126
|
+
|
|
4127
|
+
|
|
4128
|
+
|
|
4129
|
+
|
|
4130
|
+
|
|
4131
|
+
|
|
4132
|
+
|
|
3335
4133
|
* @example
|
|
3336
4134
|
* // Get all edges
|
|
3337
4135
|
* const g = new DirectedGraph();
|
|
@@ -3358,6 +4156,30 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3358
4156
|
|
|
3359
4157
|
|
|
3360
4158
|
|
|
4159
|
+
|
|
4160
|
+
|
|
4161
|
+
|
|
4162
|
+
|
|
4163
|
+
|
|
4164
|
+
|
|
4165
|
+
|
|
4166
|
+
|
|
4167
|
+
|
|
4168
|
+
|
|
4169
|
+
|
|
4170
|
+
|
|
4171
|
+
|
|
4172
|
+
|
|
4173
|
+
|
|
4174
|
+
|
|
4175
|
+
|
|
4176
|
+
|
|
4177
|
+
|
|
4178
|
+
|
|
4179
|
+
|
|
4180
|
+
|
|
4181
|
+
|
|
4182
|
+
|
|
3361
4183
|
* @example
|
|
3362
4184
|
* // Get outgoing neighbors
|
|
3363
4185
|
* const g = new DirectedGraph();
|
|
@@ -3437,6 +4259,30 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3437
4259
|
|
|
3438
4260
|
|
|
3439
4261
|
|
|
4262
|
+
|
|
4263
|
+
|
|
4264
|
+
|
|
4265
|
+
|
|
4266
|
+
|
|
4267
|
+
|
|
4268
|
+
|
|
4269
|
+
|
|
4270
|
+
|
|
4271
|
+
|
|
4272
|
+
|
|
4273
|
+
|
|
4274
|
+
|
|
4275
|
+
|
|
4276
|
+
|
|
4277
|
+
|
|
4278
|
+
|
|
4279
|
+
|
|
4280
|
+
|
|
4281
|
+
|
|
4282
|
+
|
|
4283
|
+
|
|
4284
|
+
|
|
4285
|
+
|
|
3440
4286
|
* @example
|
|
3441
4287
|
* // Find strongly connected components
|
|
3442
4288
|
* const g = new DirectedGraph();
|
|
@@ -3519,6 +4365,30 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3519
4365
|
|
|
3520
4366
|
|
|
3521
4367
|
|
|
4368
|
+
|
|
4369
|
+
|
|
4370
|
+
|
|
4371
|
+
|
|
4372
|
+
|
|
4373
|
+
|
|
4374
|
+
|
|
4375
|
+
|
|
4376
|
+
|
|
4377
|
+
|
|
4378
|
+
|
|
4379
|
+
|
|
4380
|
+
|
|
4381
|
+
|
|
4382
|
+
|
|
4383
|
+
|
|
4384
|
+
|
|
4385
|
+
|
|
4386
|
+
|
|
4387
|
+
|
|
4388
|
+
|
|
4389
|
+
|
|
4390
|
+
|
|
4391
|
+
|
|
3522
4392
|
* @example
|
|
3523
4393
|
* // Get strongly connected components
|
|
3524
4394
|
* const g = new DirectedGraph();
|
|
@@ -3665,6 +4535,30 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
3665
4535
|
|
|
3666
4536
|
|
|
3667
4537
|
|
|
4538
|
+
|
|
4539
|
+
|
|
4540
|
+
|
|
4541
|
+
|
|
4542
|
+
|
|
4543
|
+
|
|
4544
|
+
|
|
4545
|
+
|
|
4546
|
+
|
|
4547
|
+
|
|
4548
|
+
|
|
4549
|
+
|
|
4550
|
+
|
|
4551
|
+
|
|
4552
|
+
|
|
4553
|
+
|
|
4554
|
+
|
|
4555
|
+
|
|
4556
|
+
|
|
4557
|
+
|
|
4558
|
+
|
|
4559
|
+
|
|
4560
|
+
|
|
4561
|
+
|
|
3668
4562
|
* @example
|
|
3669
4563
|
* // Get edge between vertices
|
|
3670
4564
|
* const g = new UndirectedGraph();
|
|
@@ -3726,6 +4620,30 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
3726
4620
|
|
|
3727
4621
|
|
|
3728
4622
|
|
|
4623
|
+
|
|
4624
|
+
|
|
4625
|
+
|
|
4626
|
+
|
|
4627
|
+
|
|
4628
|
+
|
|
4629
|
+
|
|
4630
|
+
|
|
4631
|
+
|
|
4632
|
+
|
|
4633
|
+
|
|
4634
|
+
|
|
4635
|
+
|
|
4636
|
+
|
|
4637
|
+
|
|
4638
|
+
|
|
4639
|
+
|
|
4640
|
+
|
|
4641
|
+
|
|
4642
|
+
|
|
4643
|
+
|
|
4644
|
+
|
|
4645
|
+
|
|
4646
|
+
|
|
3729
4647
|
* @example
|
|
3730
4648
|
* // UndirectedGraph deleteEdge and vertex operations
|
|
3731
4649
|
* const graph = new UndirectedGraph<string>();
|
|
@@ -3786,6 +4704,30 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
3786
4704
|
|
|
3787
4705
|
|
|
3788
4706
|
|
|
4707
|
+
|
|
4708
|
+
|
|
4709
|
+
|
|
4710
|
+
|
|
4711
|
+
|
|
4712
|
+
|
|
4713
|
+
|
|
4714
|
+
|
|
4715
|
+
|
|
4716
|
+
|
|
4717
|
+
|
|
4718
|
+
|
|
4719
|
+
|
|
4720
|
+
|
|
4721
|
+
|
|
4722
|
+
|
|
4723
|
+
|
|
4724
|
+
|
|
4725
|
+
|
|
4726
|
+
|
|
4727
|
+
|
|
4728
|
+
|
|
4729
|
+
|
|
4730
|
+
|
|
3789
4731
|
* @example
|
|
3790
4732
|
* // Remove vertex and edges
|
|
3791
4733
|
* const g = new UndirectedGraph();
|
|
@@ -3861,6 +4803,30 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
3861
4803
|
|
|
3862
4804
|
|
|
3863
4805
|
|
|
4806
|
+
|
|
4807
|
+
|
|
4808
|
+
|
|
4809
|
+
|
|
4810
|
+
|
|
4811
|
+
|
|
4812
|
+
|
|
4813
|
+
|
|
4814
|
+
|
|
4815
|
+
|
|
4816
|
+
|
|
4817
|
+
|
|
4818
|
+
|
|
4819
|
+
|
|
4820
|
+
|
|
4821
|
+
|
|
4822
|
+
|
|
4823
|
+
|
|
4824
|
+
|
|
4825
|
+
|
|
4826
|
+
|
|
4827
|
+
|
|
4828
|
+
|
|
4829
|
+
|
|
3864
4830
|
* @example
|
|
3865
4831
|
* // Get all edges
|
|
3866
4832
|
* const g = new UndirectedGraph();
|
|
@@ -3891,6 +4857,30 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
3891
4857
|
|
|
3892
4858
|
|
|
3893
4859
|
|
|
4860
|
+
|
|
4861
|
+
|
|
4862
|
+
|
|
4863
|
+
|
|
4864
|
+
|
|
4865
|
+
|
|
4866
|
+
|
|
4867
|
+
|
|
4868
|
+
|
|
4869
|
+
|
|
4870
|
+
|
|
4871
|
+
|
|
4872
|
+
|
|
4873
|
+
|
|
4874
|
+
|
|
4875
|
+
|
|
4876
|
+
|
|
4877
|
+
|
|
4878
|
+
|
|
4879
|
+
|
|
4880
|
+
|
|
4881
|
+
|
|
4882
|
+
|
|
4883
|
+
|
|
3894
4884
|
* @example
|
|
3895
4885
|
* // UndirectedGraph connectivity and neighbors
|
|
3896
4886
|
* const graph = new UndirectedGraph<string>();
|
|
@@ -3991,6 +4981,30 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
3991
4981
|
|
|
3992
4982
|
|
|
3993
4983
|
|
|
4984
|
+
|
|
4985
|
+
|
|
4986
|
+
|
|
4987
|
+
|
|
4988
|
+
|
|
4989
|
+
|
|
4990
|
+
|
|
4991
|
+
|
|
4992
|
+
|
|
4993
|
+
|
|
4994
|
+
|
|
4995
|
+
|
|
4996
|
+
|
|
4997
|
+
|
|
4998
|
+
|
|
4999
|
+
|
|
5000
|
+
|
|
5001
|
+
|
|
5002
|
+
|
|
5003
|
+
|
|
5004
|
+
|
|
5005
|
+
|
|
5006
|
+
|
|
5007
|
+
|
|
3994
5008
|
* @example
|
|
3995
5009
|
* // Find articulation points and bridges
|
|
3996
5010
|
* const g = new UndirectedGraph();
|
|
@@ -4113,6 +5127,30 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
4113
5127
|
|
|
4114
5128
|
|
|
4115
5129
|
|
|
5130
|
+
|
|
5131
|
+
|
|
5132
|
+
|
|
5133
|
+
|
|
5134
|
+
|
|
5135
|
+
|
|
5136
|
+
|
|
5137
|
+
|
|
5138
|
+
|
|
5139
|
+
|
|
5140
|
+
|
|
5141
|
+
|
|
5142
|
+
|
|
5143
|
+
|
|
5144
|
+
|
|
5145
|
+
|
|
5146
|
+
|
|
5147
|
+
|
|
5148
|
+
|
|
5149
|
+
|
|
5150
|
+
|
|
5151
|
+
|
|
5152
|
+
|
|
5153
|
+
|
|
4116
5154
|
* @example
|
|
4117
5155
|
* // Detect cycle
|
|
4118
5156
|
* const g = new UndirectedGraph();
|
|
@@ -4157,6 +5195,30 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
4157
5195
|
|
|
4158
5196
|
|
|
4159
5197
|
|
|
5198
|
+
|
|
5199
|
+
|
|
5200
|
+
|
|
5201
|
+
|
|
5202
|
+
|
|
5203
|
+
|
|
5204
|
+
|
|
5205
|
+
|
|
5206
|
+
|
|
5207
|
+
|
|
5208
|
+
|
|
5209
|
+
|
|
5210
|
+
|
|
5211
|
+
|
|
5212
|
+
|
|
5213
|
+
|
|
5214
|
+
|
|
5215
|
+
|
|
5216
|
+
|
|
5217
|
+
|
|
5218
|
+
|
|
5219
|
+
|
|
5220
|
+
|
|
5221
|
+
|
|
4160
5222
|
* @example
|
|
4161
5223
|
* // Find bridge edges
|
|
4162
5224
|
* const g = new UndirectedGraph();
|
|
@@ -4183,6 +5245,30 @@ var _UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
4183
5245
|
|
|
4184
5246
|
|
|
4185
5247
|
|
|
5248
|
+
|
|
5249
|
+
|
|
5250
|
+
|
|
5251
|
+
|
|
5252
|
+
|
|
5253
|
+
|
|
5254
|
+
|
|
5255
|
+
|
|
5256
|
+
|
|
5257
|
+
|
|
5258
|
+
|
|
5259
|
+
|
|
5260
|
+
|
|
5261
|
+
|
|
5262
|
+
|
|
5263
|
+
|
|
5264
|
+
|
|
5265
|
+
|
|
5266
|
+
|
|
5267
|
+
|
|
5268
|
+
|
|
5269
|
+
|
|
5270
|
+
|
|
5271
|
+
|
|
4186
5272
|
* @example
|
|
4187
5273
|
* // Find articulation points
|
|
4188
5274
|
* const g = new UndirectedGraph();
|
|
@@ -4356,5 +5442,6 @@ exports.Range = Range;
|
|
|
4356
5442
|
exports.UndirectedEdge = UndirectedEdge;
|
|
4357
5443
|
exports.UndirectedGraph = UndirectedGraph;
|
|
4358
5444
|
exports.UndirectedVertex = UndirectedVertex;
|
|
5445
|
+
exports.raise = raise;
|
|
4359
5446
|
//# sourceMappingURL=index.cjs.map
|
|
4360
5447
|
//# sourceMappingURL=index.cjs.map
|