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