graph-typed 2.5.0 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +1213 -268
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +1202 -257
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +1213 -268
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +1202 -257
- package/dist/esm-legacy/index.mjs.map +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 +252 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +294 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +527 -2
- package/dist/types/data-structures/binary-tree/bst.d.ts +505 -1
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +399 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +126 -1
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +2881 -382
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +2867 -347
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2328 -312
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +2671 -277
- package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
- package/dist/types/data-structures/graph/directed-graph.d.ts +210 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +189 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +241 -10
- package/dist/types/data-structures/heap/heap.d.ts +294 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +360 -3
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +318 -3
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +380 -2
- package/dist/types/data-structures/matrix/matrix.d.ts +168 -0
- package/dist/types/data-structures/queue/deque.d.ts +319 -4
- package/dist/types/data-structures/queue/queue.d.ts +252 -0
- package/dist/types/data-structures/stack/stack.d.ts +210 -0
- package/dist/types/data-structures/trie/trie.d.ts +256 -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/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 +1204 -259
- 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/data-structures/base/index.ts +1 -0
- 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 +252 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +295 -1
- package/src/data-structures/binary-tree/binary-tree.ts +527 -2
- package/src/data-structures/binary-tree/bst.ts +505 -1
- package/src/data-structures/binary-tree/red-black-tree.ts +399 -0
- package/src/data-structures/binary-tree/segment-tree.ts +127 -2
- package/src/data-structures/binary-tree/tree-map.ts +2958 -459
- package/src/data-structures/binary-tree/tree-multi-map.ts +3069 -549
- package/src/data-structures/binary-tree/tree-multi-set.ts +2476 -460
- package/src/data-structures/binary-tree/tree-set.ts +2816 -422
- package/src/data-structures/graph/abstract-graph.ts +4 -4
- package/src/data-structures/graph/directed-graph.ts +210 -0
- package/src/data-structures/graph/undirected-graph.ts +189 -0
- package/src/data-structures/hash/hash-map.ts +246 -15
- package/src/data-structures/heap/heap.ts +294 -0
- package/src/data-structures/linked-list/doubly-linked-list.ts +360 -3
- package/src/data-structures/linked-list/singly-linked-list.ts +318 -3
- package/src/data-structures/linked-list/skip-linked-list.ts +380 -2
- package/src/data-structures/matrix/matrix.ts +169 -1
- package/src/data-structures/queue/deque.ts +320 -5
- package/src/data-structures/queue/queue.ts +252 -0
- package/src/data-structures/stack/stack.ts +210 -0
- package/src/data-structures/trie/trie.ts +257 -5
- package/src/interfaces/graph.ts +1 -1
- package/src/types/common.ts +2 -2
- package/src/types/data-structures/heap/heap.ts +1 -0
- package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
- package/src/types/utils/validate-type.ts +4 -4
package/dist/umd/graph-typed.js
CHANGED
|
@@ -506,6 +506,196 @@ var graphTyped = (() => {
|
|
|
506
506
|
}
|
|
507
507
|
};
|
|
508
508
|
|
|
509
|
+
// src/data-structures/base/linear-base.ts
|
|
510
|
+
var LinearBase = class _LinearBase extends IterableElementBase {
|
|
511
|
+
/**
|
|
512
|
+
* Construct a linear container with runtime options.
|
|
513
|
+
* @param options - `{ maxLen?, ... }` bounds/behavior options.
|
|
514
|
+
* @remarks Time O(1), Space O(1)
|
|
515
|
+
*/
|
|
516
|
+
constructor(options) {
|
|
517
|
+
super(options);
|
|
518
|
+
__publicField(this, "_maxLen", -1);
|
|
519
|
+
if (options) {
|
|
520
|
+
const { maxLen } = options;
|
|
521
|
+
if (typeof maxLen === "number" && maxLen > 0 && maxLen % 1 === 0) this._maxLen = maxLen;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Upper bound for length (if positive), or `-1` when unbounded.
|
|
526
|
+
* @returns Maximum allowed length.
|
|
527
|
+
* @remarks Time O(1), Space O(1)
|
|
528
|
+
*/
|
|
529
|
+
get maxLen() {
|
|
530
|
+
return this._maxLen;
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* First index of a value from the left.
|
|
534
|
+
* @param searchElement - Value to match.
|
|
535
|
+
* @param fromIndex - Start position (supports negative index).
|
|
536
|
+
* @returns Index or `-1` if not found.
|
|
537
|
+
* @remarks Time O(n), Space O(1)
|
|
538
|
+
*/
|
|
539
|
+
indexOf(searchElement, fromIndex = 0) {
|
|
540
|
+
if (this.length === 0) return -1;
|
|
541
|
+
if (fromIndex < 0) fromIndex = this.length + fromIndex;
|
|
542
|
+
if (fromIndex < 0) fromIndex = 0;
|
|
543
|
+
for (let i = fromIndex; i < this.length; i++) {
|
|
544
|
+
const element = this.at(i);
|
|
545
|
+
if (element === searchElement) return i;
|
|
546
|
+
}
|
|
547
|
+
return -1;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Last index of a value from the right.
|
|
551
|
+
* @param searchElement - Value to match.
|
|
552
|
+
* @param fromIndex - Start position (supports negative index).
|
|
553
|
+
* @returns Index or `-1` if not found.
|
|
554
|
+
* @remarks Time O(n), Space O(1)
|
|
555
|
+
*/
|
|
556
|
+
lastIndexOf(searchElement, fromIndex = this.length - 1) {
|
|
557
|
+
if (this.length === 0) return -1;
|
|
558
|
+
if (fromIndex >= this.length) fromIndex = this.length - 1;
|
|
559
|
+
if (fromIndex < 0) fromIndex = this.length + fromIndex;
|
|
560
|
+
for (let i = fromIndex; i >= 0; i--) {
|
|
561
|
+
const element = this.at(i);
|
|
562
|
+
if (element === searchElement) return i;
|
|
563
|
+
}
|
|
564
|
+
return -1;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Find the first index matching a predicate.
|
|
568
|
+
* @param predicate - `(element, index, self) => boolean`.
|
|
569
|
+
* @param thisArg - Optional `this` for callback.
|
|
570
|
+
* @returns Index or `-1`.
|
|
571
|
+
* @remarks Time O(n), Space O(1)
|
|
572
|
+
*/
|
|
573
|
+
findIndex(predicate, thisArg) {
|
|
574
|
+
for (let i = 0; i < this.length; i++) {
|
|
575
|
+
const item = this.at(i);
|
|
576
|
+
if (item !== void 0 && predicate.call(thisArg, item, i, this)) return i;
|
|
577
|
+
}
|
|
578
|
+
return -1;
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Concatenate elements and/or containers.
|
|
582
|
+
* @param items - Elements or other containers.
|
|
583
|
+
* @returns New container with combined elements (`this` type).
|
|
584
|
+
* @remarks Time O(sum(length)), Space O(sum(length))
|
|
585
|
+
*/
|
|
586
|
+
concat(...items) {
|
|
587
|
+
const newList = this.clone();
|
|
588
|
+
for (const item of items) {
|
|
589
|
+
if (item instanceof _LinearBase) {
|
|
590
|
+
newList.pushMany(item);
|
|
591
|
+
} else {
|
|
592
|
+
newList.push(item);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
return newList;
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* In-place stable order via array sort semantics.
|
|
599
|
+
* @param compareFn - Comparator `(a, b) => number`.
|
|
600
|
+
* @returns This container.
|
|
601
|
+
* @remarks Time O(n log n), Space O(n) (materializes to array temporarily)
|
|
602
|
+
*/
|
|
603
|
+
sort(compareFn) {
|
|
604
|
+
const arr = this.toArray();
|
|
605
|
+
arr.sort(compareFn);
|
|
606
|
+
this.clear();
|
|
607
|
+
for (const item of arr) this.push(item);
|
|
608
|
+
return this;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Remove and/or insert elements at a position (array-compatible).
|
|
612
|
+
* @param start - Start index (supports negative index).
|
|
613
|
+
* @param deleteCount - How many to remove.
|
|
614
|
+
* @param items - Elements to insert.
|
|
615
|
+
* @returns Removed elements as a new list (`this` type).
|
|
616
|
+
* @remarks Time O(n + m), Space O(min(n, m)) where `m = items.length`
|
|
617
|
+
*/
|
|
618
|
+
splice(start, deleteCount = 0, ...items) {
|
|
619
|
+
const removedList = this._createInstance();
|
|
620
|
+
start = start < 0 ? this.length + start : start;
|
|
621
|
+
start = Math.max(0, Math.min(start, this.length));
|
|
622
|
+
deleteCount = Math.max(0, Math.min(deleteCount, this.length - start));
|
|
623
|
+
for (let i = 0; i < deleteCount; i++) {
|
|
624
|
+
const removed = this.deleteAt(start);
|
|
625
|
+
if (removed !== void 0) {
|
|
626
|
+
removedList.push(removed);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
for (let i = 0; i < items.length; i++) {
|
|
630
|
+
this.addAt(start + i, items[i]);
|
|
631
|
+
}
|
|
632
|
+
return removedList;
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* Join all elements into a string.
|
|
636
|
+
* @param separator - Separator string.
|
|
637
|
+
* @returns Concatenated string.
|
|
638
|
+
* @remarks Time O(n), Space O(n)
|
|
639
|
+
*/
|
|
640
|
+
join(separator = ",") {
|
|
641
|
+
return this.toArray().join(separator);
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* Snapshot elements into a reversed array.
|
|
645
|
+
* @returns New reversed array.
|
|
646
|
+
* @remarks Time O(n), Space O(n)
|
|
647
|
+
*/
|
|
648
|
+
toReversedArray() {
|
|
649
|
+
const array = [];
|
|
650
|
+
for (let i = this.length - 1; i >= 0; i--) {
|
|
651
|
+
array.push(this.at(i));
|
|
652
|
+
}
|
|
653
|
+
return array;
|
|
654
|
+
}
|
|
655
|
+
reduceRight(callbackfn, initialValue) {
|
|
656
|
+
let accumulator = initialValue != null ? initialValue : 0;
|
|
657
|
+
for (let i = this.length - 1; i >= 0; i--) {
|
|
658
|
+
accumulator = callbackfn(accumulator, this.at(i), i, this);
|
|
659
|
+
}
|
|
660
|
+
return accumulator;
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Create a shallow copy of a subrange.
|
|
664
|
+
* @param start - Inclusive start (supports negative index).
|
|
665
|
+
* @param end - Exclusive end (supports negative index).
|
|
666
|
+
* @returns New list with the range (`this` type).
|
|
667
|
+
* @remarks Time O(n), Space O(n)
|
|
668
|
+
*/
|
|
669
|
+
slice(start = 0, end = this.length) {
|
|
670
|
+
start = start < 0 ? this.length + start : start;
|
|
671
|
+
end = end < 0 ? this.length + end : end;
|
|
672
|
+
const newList = this._createInstance();
|
|
673
|
+
for (let i = start; i < end; i++) {
|
|
674
|
+
newList.push(this.at(i));
|
|
675
|
+
}
|
|
676
|
+
return newList;
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Fill a range with a value.
|
|
680
|
+
* @param value - Value to set.
|
|
681
|
+
* @param start - Inclusive start.
|
|
682
|
+
* @param end - Exclusive end.
|
|
683
|
+
* @returns This list.
|
|
684
|
+
* @remarks Time O(n), Space O(1)
|
|
685
|
+
*/
|
|
686
|
+
fill(value, start = 0, end = this.length) {
|
|
687
|
+
start = start < 0 ? this.length + start : start;
|
|
688
|
+
end = end < 0 ? this.length + end : end;
|
|
689
|
+
if (start < 0) start = 0;
|
|
690
|
+
if (end > this.length) end = this.length;
|
|
691
|
+
if (start >= end) return this;
|
|
692
|
+
for (let i = start; i < end; i++) {
|
|
693
|
+
this.setAt(i, value);
|
|
694
|
+
}
|
|
695
|
+
return this;
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
|
|
509
699
|
// src/data-structures/heap/heap.ts
|
|
510
700
|
var Heap = class _Heap extends IterableElementBase {
|
|
511
701
|
/**
|
|
@@ -557,6 +747,27 @@ var graphTyped = (() => {
|
|
|
557
747
|
|
|
558
748
|
|
|
559
749
|
|
|
750
|
+
|
|
751
|
+
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
|
|
560
771
|
* @example
|
|
561
772
|
* // Track heap capacity
|
|
562
773
|
* const heap = new Heap<number>();
|
|
@@ -620,6 +831,27 @@ var graphTyped = (() => {
|
|
|
620
831
|
|
|
621
832
|
|
|
622
833
|
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
|
|
847
|
+
|
|
848
|
+
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
|
|
852
|
+
|
|
853
|
+
|
|
854
|
+
|
|
623
855
|
* @example
|
|
624
856
|
* // basic Heap creation and add operation
|
|
625
857
|
* // Create a min heap (default)
|
|
@@ -653,6 +885,27 @@ var graphTyped = (() => {
|
|
|
653
885
|
|
|
654
886
|
|
|
655
887
|
|
|
888
|
+
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
|
|
656
909
|
* @example
|
|
657
910
|
* // Add multiple elements
|
|
658
911
|
* const heap = new Heap<number>([], { comparator: (a, b) => a - b });
|
|
@@ -688,9 +941,30 @@ var graphTyped = (() => {
|
|
|
688
941
|
|
|
689
942
|
|
|
690
943
|
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
944
|
+
|
|
945
|
+
|
|
946
|
+
|
|
947
|
+
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
|
|
952
|
+
|
|
953
|
+
|
|
954
|
+
|
|
955
|
+
|
|
956
|
+
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
|
|
965
|
+
* @example
|
|
966
|
+
* // Heap with custom comparator (MaxHeap behavior)
|
|
967
|
+
* interface Task {
|
|
694
968
|
* id: number;
|
|
695
969
|
* priority: number;
|
|
696
970
|
* name: string;
|
|
@@ -739,6 +1013,27 @@ var graphTyped = (() => {
|
|
|
739
1013
|
|
|
740
1014
|
|
|
741
1015
|
|
|
1016
|
+
|
|
1017
|
+
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
|
|
1021
|
+
|
|
1022
|
+
|
|
1023
|
+
|
|
1024
|
+
|
|
1025
|
+
|
|
1026
|
+
|
|
1027
|
+
|
|
1028
|
+
|
|
1029
|
+
|
|
1030
|
+
|
|
1031
|
+
|
|
1032
|
+
|
|
1033
|
+
|
|
1034
|
+
|
|
1035
|
+
|
|
1036
|
+
|
|
742
1037
|
* @example
|
|
743
1038
|
* // Heap for event processing with priority
|
|
744
1039
|
* interface Event {
|
|
@@ -815,6 +1110,27 @@ var graphTyped = (() => {
|
|
|
815
1110
|
|
|
816
1111
|
|
|
817
1112
|
|
|
1113
|
+
|
|
1114
|
+
|
|
1115
|
+
|
|
1116
|
+
|
|
1117
|
+
|
|
1118
|
+
|
|
1119
|
+
|
|
1120
|
+
|
|
1121
|
+
|
|
1122
|
+
|
|
1123
|
+
|
|
1124
|
+
|
|
1125
|
+
|
|
1126
|
+
|
|
1127
|
+
|
|
1128
|
+
|
|
1129
|
+
|
|
1130
|
+
|
|
1131
|
+
|
|
1132
|
+
|
|
1133
|
+
|
|
818
1134
|
* @example
|
|
819
1135
|
* // Check if heap is empty
|
|
820
1136
|
* const heap = new Heap<number>([], { comparator: (a, b) => a - b });
|
|
@@ -838,6 +1154,27 @@ var graphTyped = (() => {
|
|
|
838
1154
|
|
|
839
1155
|
|
|
840
1156
|
|
|
1157
|
+
|
|
1158
|
+
|
|
1159
|
+
|
|
1160
|
+
|
|
1161
|
+
|
|
1162
|
+
|
|
1163
|
+
|
|
1164
|
+
|
|
1165
|
+
|
|
1166
|
+
|
|
1167
|
+
|
|
1168
|
+
|
|
1169
|
+
|
|
1170
|
+
|
|
1171
|
+
|
|
1172
|
+
|
|
1173
|
+
|
|
1174
|
+
|
|
1175
|
+
|
|
1176
|
+
|
|
1177
|
+
|
|
841
1178
|
* @example
|
|
842
1179
|
* // Remove all elements
|
|
843
1180
|
* const heap = new Heap<number>([1, 2, 3], { comparator: (a, b) => a - b });
|
|
@@ -864,6 +1201,27 @@ var graphTyped = (() => {
|
|
|
864
1201
|
* @returns True if found.
|
|
865
1202
|
|
|
866
1203
|
|
|
1204
|
+
|
|
1205
|
+
|
|
1206
|
+
|
|
1207
|
+
|
|
1208
|
+
|
|
1209
|
+
|
|
1210
|
+
|
|
1211
|
+
|
|
1212
|
+
|
|
1213
|
+
|
|
1214
|
+
|
|
1215
|
+
|
|
1216
|
+
|
|
1217
|
+
|
|
1218
|
+
|
|
1219
|
+
|
|
1220
|
+
|
|
1221
|
+
|
|
1222
|
+
|
|
1223
|
+
|
|
1224
|
+
|
|
867
1225
|
* @example
|
|
868
1226
|
* // Check element existence
|
|
869
1227
|
* const heap = new Heap<number>([3, 1, 2], { comparator: (a, b) => a - b });
|
|
@@ -887,6 +1245,27 @@ var graphTyped = (() => {
|
|
|
887
1245
|
|
|
888
1246
|
|
|
889
1247
|
|
|
1248
|
+
|
|
1249
|
+
|
|
1250
|
+
|
|
1251
|
+
|
|
1252
|
+
|
|
1253
|
+
|
|
1254
|
+
|
|
1255
|
+
|
|
1256
|
+
|
|
1257
|
+
|
|
1258
|
+
|
|
1259
|
+
|
|
1260
|
+
|
|
1261
|
+
|
|
1262
|
+
|
|
1263
|
+
|
|
1264
|
+
|
|
1265
|
+
|
|
1266
|
+
|
|
1267
|
+
|
|
1268
|
+
|
|
890
1269
|
* @example
|
|
891
1270
|
* // Remove specific element
|
|
892
1271
|
* const heap = new Heap<number>([3, 1, 4, 1, 5], { comparator: (a, b) => a - b });
|
|
@@ -956,6 +1335,27 @@ var graphTyped = (() => {
|
|
|
956
1335
|
* @returns Array of visited elements.
|
|
957
1336
|
|
|
958
1337
|
|
|
1338
|
+
|
|
1339
|
+
|
|
1340
|
+
|
|
1341
|
+
|
|
1342
|
+
|
|
1343
|
+
|
|
1344
|
+
|
|
1345
|
+
|
|
1346
|
+
|
|
1347
|
+
|
|
1348
|
+
|
|
1349
|
+
|
|
1350
|
+
|
|
1351
|
+
|
|
1352
|
+
|
|
1353
|
+
|
|
1354
|
+
|
|
1355
|
+
|
|
1356
|
+
|
|
1357
|
+
|
|
1358
|
+
|
|
959
1359
|
* @example
|
|
960
1360
|
* // Depth-first traversal
|
|
961
1361
|
* const heap = new Heap<number>([3, 1, 2], { comparator: (a, b) => a - b });
|
|
@@ -1012,6 +1412,27 @@ var graphTyped = (() => {
|
|
|
1012
1412
|
|
|
1013
1413
|
|
|
1014
1414
|
|
|
1415
|
+
|
|
1416
|
+
|
|
1417
|
+
|
|
1418
|
+
|
|
1419
|
+
|
|
1420
|
+
|
|
1421
|
+
|
|
1422
|
+
|
|
1423
|
+
|
|
1424
|
+
|
|
1425
|
+
|
|
1426
|
+
|
|
1427
|
+
|
|
1428
|
+
|
|
1429
|
+
|
|
1430
|
+
|
|
1431
|
+
|
|
1432
|
+
|
|
1433
|
+
|
|
1434
|
+
|
|
1435
|
+
|
|
1015
1436
|
* @example
|
|
1016
1437
|
* // Sort elements using heap
|
|
1017
1438
|
* const heap = new Heap<number>([5, 1, 3, 2, 4]);
|
|
@@ -1041,6 +1462,27 @@ var graphTyped = (() => {
|
|
|
1041
1462
|
|
|
1042
1463
|
|
|
1043
1464
|
|
|
1465
|
+
|
|
1466
|
+
|
|
1467
|
+
|
|
1468
|
+
|
|
1469
|
+
|
|
1470
|
+
|
|
1471
|
+
|
|
1472
|
+
|
|
1473
|
+
|
|
1474
|
+
|
|
1475
|
+
|
|
1476
|
+
|
|
1477
|
+
|
|
1478
|
+
|
|
1479
|
+
|
|
1480
|
+
|
|
1481
|
+
|
|
1482
|
+
|
|
1483
|
+
|
|
1484
|
+
|
|
1485
|
+
|
|
1044
1486
|
* @example
|
|
1045
1487
|
* // Create independent copy
|
|
1046
1488
|
* const heap = new Heap<number>([3, 1, 4], { comparator: (a, b) => a - b });
|
|
@@ -1069,6 +1511,27 @@ var graphTyped = (() => {
|
|
|
1069
1511
|
|
|
1070
1512
|
|
|
1071
1513
|
|
|
1514
|
+
|
|
1515
|
+
|
|
1516
|
+
|
|
1517
|
+
|
|
1518
|
+
|
|
1519
|
+
|
|
1520
|
+
|
|
1521
|
+
|
|
1522
|
+
|
|
1523
|
+
|
|
1524
|
+
|
|
1525
|
+
|
|
1526
|
+
|
|
1527
|
+
|
|
1528
|
+
|
|
1529
|
+
|
|
1530
|
+
|
|
1531
|
+
|
|
1532
|
+
|
|
1533
|
+
|
|
1534
|
+
|
|
1072
1535
|
* @example
|
|
1073
1536
|
* // Filter elements
|
|
1074
1537
|
* const heap = new Heap<number>([1, 2, 3, 4, 5], { comparator: (a, b) => a - b });
|
|
@@ -1104,6 +1567,27 @@ var graphTyped = (() => {
|
|
|
1104
1567
|
|
|
1105
1568
|
|
|
1106
1569
|
|
|
1570
|
+
|
|
1571
|
+
|
|
1572
|
+
|
|
1573
|
+
|
|
1574
|
+
|
|
1575
|
+
|
|
1576
|
+
|
|
1577
|
+
|
|
1578
|
+
|
|
1579
|
+
|
|
1580
|
+
|
|
1581
|
+
|
|
1582
|
+
|
|
1583
|
+
|
|
1584
|
+
|
|
1585
|
+
|
|
1586
|
+
|
|
1587
|
+
|
|
1588
|
+
|
|
1589
|
+
|
|
1590
|
+
|
|
1107
1591
|
* @example
|
|
1108
1592
|
* // Transform elements
|
|
1109
1593
|
* const heap = new Heap<number>([1, 2, 3], { comparator: (a, b) => a - b });
|
|
@@ -1130,276 +1614,86 @@ var graphTyped = (() => {
|
|
|
1130
1614
|
*/
|
|
1131
1615
|
mapSame(callback, thisArg) {
|
|
1132
1616
|
const out = this._createInstance();
|
|
1133
|
-
let i = 0;
|
|
1134
|
-
for (const x of this) {
|
|
1135
|
-
const v = thisArg === void 0 ? callback(x, i++, this) : callback.call(thisArg, x, i++, this);
|
|
1136
|
-
out.add(v);
|
|
1137
|
-
}
|
|
1138
|
-
return out;
|
|
1139
|
-
}
|
|
1140
|
-
/**
|
|
1141
|
-
* Get the comparator used to order elements.
|
|
1142
|
-
* @remarks Time O(1), Space O(1)
|
|
1143
|
-
* @returns Comparator function.
|
|
1144
|
-
*/
|
|
1145
|
-
get comparator() {
|
|
1146
|
-
return this._comparator;
|
|
1147
|
-
}
|
|
1148
|
-
*_getIterator() {
|
|
1149
|
-
for (const element of this.elements) yield element;
|
|
1150
|
-
}
|
|
1151
|
-
_bubbleUp(index) {
|
|
1152
|
-
const element = this.elements[index];
|
|
1153
|
-
while (index > 0) {
|
|
1154
|
-
const parent = index - 1 >> 1;
|
|
1155
|
-
const parentItem = this.elements[parent];
|
|
1156
|
-
if (this.comparator(parentItem, element) <= 0) break;
|
|
1157
|
-
this.elements[index] = parentItem;
|
|
1158
|
-
index = parent;
|
|
1159
|
-
}
|
|
1160
|
-
this.elements[index] = element;
|
|
1161
|
-
return true;
|
|
1162
|
-
}
|
|
1163
|
-
_sinkDown(index, halfLength) {
|
|
1164
|
-
const element = this.elements[index];
|
|
1165
|
-
while (index < halfLength) {
|
|
1166
|
-
let left = index << 1 | 1;
|
|
1167
|
-
const right = left + 1;
|
|
1168
|
-
let minItem = this.elements[left];
|
|
1169
|
-
if (right < this.elements.length && this.comparator(minItem, this.elements[right]) > 0) {
|
|
1170
|
-
left = right;
|
|
1171
|
-
minItem = this.elements[right];
|
|
1172
|
-
}
|
|
1173
|
-
if (this.comparator(minItem, element) >= 0) break;
|
|
1174
|
-
this.elements[index] = minItem;
|
|
1175
|
-
index = left;
|
|
1176
|
-
}
|
|
1177
|
-
this.elements[index] = element;
|
|
1178
|
-
return true;
|
|
1179
|
-
}
|
|
1180
|
-
/**
|
|
1181
|
-
* (Protected) Create an empty instance of the same concrete class.
|
|
1182
|
-
* @remarks Time O(1), Space O(1)
|
|
1183
|
-
* @param [options] - Options to override comparator or toElementFn.
|
|
1184
|
-
* @returns A like-kind empty heap instance.
|
|
1185
|
-
*/
|
|
1186
|
-
_createInstance(options) {
|
|
1187
|
-
const Ctor = this.constructor;
|
|
1188
|
-
return new Ctor([], { comparator: this.comparator, toElementFn: this.toElementFn, ...options != null ? options : {} });
|
|
1189
|
-
}
|
|
1190
|
-
/**
|
|
1191
|
-
* (Protected) Create a like-kind instance seeded by elements.
|
|
1192
|
-
* @remarks Time O(N log N), Space O(N)
|
|
1193
|
-
* @template EM
|
|
1194
|
-
* @template RM
|
|
1195
|
-
* @param [elements] - Iterable of elements or raw values to seed.
|
|
1196
|
-
* @param [options] - Options forwarded to the constructor.
|
|
1197
|
-
* @returns A like-kind heap instance.
|
|
1198
|
-
*/
|
|
1199
|
-
_createLike(elements = [], options) {
|
|
1200
|
-
const Ctor = this.constructor;
|
|
1201
|
-
return new Ctor(elements, options);
|
|
1202
|
-
}
|
|
1203
|
-
/**
|
|
1204
|
-
* (Protected) Spawn an empty like-kind heap instance.
|
|
1205
|
-
* @remarks Time O(1), Space O(1)
|
|
1206
|
-
* @template EM
|
|
1207
|
-
* @template RM
|
|
1208
|
-
* @param [options] - Options forwarded to the constructor.
|
|
1209
|
-
* @returns An empty like-kind heap instance.
|
|
1210
|
-
*/
|
|
1211
|
-
_spawnLike(options) {
|
|
1212
|
-
return this._createLike([], options);
|
|
1213
|
-
}
|
|
1214
|
-
};
|
|
1215
|
-
|
|
1216
|
-
// src/data-structures/base/linear-base.ts
|
|
1217
|
-
var LinearBase = class _LinearBase extends IterableElementBase {
|
|
1218
|
-
/**
|
|
1219
|
-
* Construct a linear container with runtime options.
|
|
1220
|
-
* @param options - `{ maxLen?, ... }` bounds/behavior options.
|
|
1221
|
-
* @remarks Time O(1), Space O(1)
|
|
1222
|
-
*/
|
|
1223
|
-
constructor(options) {
|
|
1224
|
-
super(options);
|
|
1225
|
-
__publicField(this, "_maxLen", -1);
|
|
1226
|
-
if (options) {
|
|
1227
|
-
const { maxLen } = options;
|
|
1228
|
-
if (typeof maxLen === "number" && maxLen > 0 && maxLen % 1 === 0) this._maxLen = maxLen;
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
/**
|
|
1232
|
-
* Upper bound for length (if positive), or `-1` when unbounded.
|
|
1233
|
-
* @returns Maximum allowed length.
|
|
1234
|
-
* @remarks Time O(1), Space O(1)
|
|
1235
|
-
*/
|
|
1236
|
-
get maxLen() {
|
|
1237
|
-
return this._maxLen;
|
|
1238
|
-
}
|
|
1239
|
-
/**
|
|
1240
|
-
* First index of a value from the left.
|
|
1241
|
-
* @param searchElement - Value to match.
|
|
1242
|
-
* @param fromIndex - Start position (supports negative index).
|
|
1243
|
-
* @returns Index or `-1` if not found.
|
|
1244
|
-
* @remarks Time O(n), Space O(1)
|
|
1245
|
-
*/
|
|
1246
|
-
indexOf(searchElement, fromIndex = 0) {
|
|
1247
|
-
if (this.length === 0) return -1;
|
|
1248
|
-
if (fromIndex < 0) fromIndex = this.length + fromIndex;
|
|
1249
|
-
if (fromIndex < 0) fromIndex = 0;
|
|
1250
|
-
for (let i = fromIndex; i < this.length; i++) {
|
|
1251
|
-
const element = this.at(i);
|
|
1252
|
-
if (element === searchElement) return i;
|
|
1253
|
-
}
|
|
1254
|
-
return -1;
|
|
1255
|
-
}
|
|
1256
|
-
/**
|
|
1257
|
-
* Last index of a value from the right.
|
|
1258
|
-
* @param searchElement - Value to match.
|
|
1259
|
-
* @param fromIndex - Start position (supports negative index).
|
|
1260
|
-
* @returns Index or `-1` if not found.
|
|
1261
|
-
* @remarks Time O(n), Space O(1)
|
|
1262
|
-
*/
|
|
1263
|
-
lastIndexOf(searchElement, fromIndex = this.length - 1) {
|
|
1264
|
-
if (this.length === 0) return -1;
|
|
1265
|
-
if (fromIndex >= this.length) fromIndex = this.length - 1;
|
|
1266
|
-
if (fromIndex < 0) fromIndex = this.length + fromIndex;
|
|
1267
|
-
for (let i = fromIndex; i >= 0; i--) {
|
|
1268
|
-
const element = this.at(i);
|
|
1269
|
-
if (element === searchElement) return i;
|
|
1270
|
-
}
|
|
1271
|
-
return -1;
|
|
1272
|
-
}
|
|
1273
|
-
/**
|
|
1274
|
-
* Find the first index matching a predicate.
|
|
1275
|
-
* @param predicate - `(element, index, self) => boolean`.
|
|
1276
|
-
* @param thisArg - Optional `this` for callback.
|
|
1277
|
-
* @returns Index or `-1`.
|
|
1278
|
-
* @remarks Time O(n), Space O(1)
|
|
1279
|
-
*/
|
|
1280
|
-
findIndex(predicate, thisArg) {
|
|
1281
|
-
for (let i = 0; i < this.length; i++) {
|
|
1282
|
-
const item = this.at(i);
|
|
1283
|
-
if (item !== void 0 && predicate.call(thisArg, item, i, this)) return i;
|
|
1284
|
-
}
|
|
1285
|
-
return -1;
|
|
1286
|
-
}
|
|
1287
|
-
/**
|
|
1288
|
-
* Concatenate elements and/or containers.
|
|
1289
|
-
* @param items - Elements or other containers.
|
|
1290
|
-
* @returns New container with combined elements (`this` type).
|
|
1291
|
-
* @remarks Time O(sum(length)), Space O(sum(length))
|
|
1292
|
-
*/
|
|
1293
|
-
concat(...items) {
|
|
1294
|
-
const newList = this.clone();
|
|
1295
|
-
for (const item of items) {
|
|
1296
|
-
if (item instanceof _LinearBase) {
|
|
1297
|
-
newList.pushMany(item);
|
|
1298
|
-
} else {
|
|
1299
|
-
newList.push(item);
|
|
1300
|
-
}
|
|
1301
|
-
}
|
|
1302
|
-
return newList;
|
|
1303
|
-
}
|
|
1304
|
-
/**
|
|
1305
|
-
* In-place stable order via array sort semantics.
|
|
1306
|
-
* @param compareFn - Comparator `(a, b) => number`.
|
|
1307
|
-
* @returns This container.
|
|
1308
|
-
* @remarks Time O(n log n), Space O(n) (materializes to array temporarily)
|
|
1309
|
-
*/
|
|
1310
|
-
sort(compareFn) {
|
|
1311
|
-
const arr = this.toArray();
|
|
1312
|
-
arr.sort(compareFn);
|
|
1313
|
-
this.clear();
|
|
1314
|
-
for (const item of arr) this.push(item);
|
|
1315
|
-
return this;
|
|
1316
|
-
}
|
|
1317
|
-
/**
|
|
1318
|
-
* Remove and/or insert elements at a position (array-compatible).
|
|
1319
|
-
* @param start - Start index (supports negative index).
|
|
1320
|
-
* @param deleteCount - How many to remove.
|
|
1321
|
-
* @param items - Elements to insert.
|
|
1322
|
-
* @returns Removed elements as a new list (`this` type).
|
|
1323
|
-
* @remarks Time O(n + m), Space O(min(n, m)) where `m = items.length`
|
|
1324
|
-
*/
|
|
1325
|
-
splice(start, deleteCount = 0, ...items) {
|
|
1326
|
-
const removedList = this._createInstance();
|
|
1327
|
-
start = start < 0 ? this.length + start : start;
|
|
1328
|
-
start = Math.max(0, Math.min(start, this.length));
|
|
1329
|
-
deleteCount = Math.max(0, Math.min(deleteCount, this.length - start));
|
|
1330
|
-
for (let i = 0; i < deleteCount; i++) {
|
|
1331
|
-
const removed = this.deleteAt(start);
|
|
1332
|
-
if (removed !== void 0) {
|
|
1333
|
-
removedList.push(removed);
|
|
1334
|
-
}
|
|
1335
|
-
}
|
|
1336
|
-
for (let i = 0; i < items.length; i++) {
|
|
1337
|
-
this.addAt(start + i, items[i]);
|
|
1617
|
+
let i = 0;
|
|
1618
|
+
for (const x of this) {
|
|
1619
|
+
const v = thisArg === void 0 ? callback(x, i++, this) : callback.call(thisArg, x, i++, this);
|
|
1620
|
+
out.add(v);
|
|
1338
1621
|
}
|
|
1339
|
-
return
|
|
1622
|
+
return out;
|
|
1340
1623
|
}
|
|
1341
1624
|
/**
|
|
1342
|
-
*
|
|
1343
|
-
* @
|
|
1344
|
-
* @returns
|
|
1345
|
-
* @remarks Time O(n), Space O(n)
|
|
1625
|
+
* Get the comparator used to order elements.
|
|
1626
|
+
* @remarks Time O(1), Space O(1)
|
|
1627
|
+
* @returns Comparator function.
|
|
1346
1628
|
*/
|
|
1347
|
-
|
|
1348
|
-
return this.
|
|
1629
|
+
get comparator() {
|
|
1630
|
+
return this._comparator;
|
|
1349
1631
|
}
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1632
|
+
*_getIterator() {
|
|
1633
|
+
for (const element of this.elements) yield element;
|
|
1634
|
+
}
|
|
1635
|
+
_bubbleUp(index) {
|
|
1636
|
+
const element = this.elements[index];
|
|
1637
|
+
while (index > 0) {
|
|
1638
|
+
const parent = index - 1 >> 1;
|
|
1639
|
+
const parentItem = this.elements[parent];
|
|
1640
|
+
if (this.comparator(parentItem, element) <= 0) break;
|
|
1641
|
+
this.elements[index] = parentItem;
|
|
1642
|
+
index = parent;
|
|
1359
1643
|
}
|
|
1360
|
-
|
|
1644
|
+
this.elements[index] = element;
|
|
1645
|
+
return true;
|
|
1361
1646
|
}
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1647
|
+
_sinkDown(index, halfLength) {
|
|
1648
|
+
const element = this.elements[index];
|
|
1649
|
+
while (index < halfLength) {
|
|
1650
|
+
let left = index << 1 | 1;
|
|
1651
|
+
const right = left + 1;
|
|
1652
|
+
let minItem = this.elements[left];
|
|
1653
|
+
if (right < this.elements.length && this.comparator(minItem, this.elements[right]) > 0) {
|
|
1654
|
+
left = right;
|
|
1655
|
+
minItem = this.elements[right];
|
|
1656
|
+
}
|
|
1657
|
+
if (this.comparator(minItem, element) >= 0) break;
|
|
1658
|
+
this.elements[index] = minItem;
|
|
1659
|
+
index = left;
|
|
1366
1660
|
}
|
|
1367
|
-
|
|
1661
|
+
this.elements[index] = element;
|
|
1662
|
+
return true;
|
|
1368
1663
|
}
|
|
1369
1664
|
/**
|
|
1370
|
-
* Create
|
|
1371
|
-
* @
|
|
1372
|
-
* @param
|
|
1373
|
-
* @returns
|
|
1374
|
-
* @remarks Time O(n), Space O(n)
|
|
1665
|
+
* (Protected) Create an empty instance of the same concrete class.
|
|
1666
|
+
* @remarks Time O(1), Space O(1)
|
|
1667
|
+
* @param [options] - Options to override comparator or toElementFn.
|
|
1668
|
+
* @returns A like-kind empty heap instance.
|
|
1375
1669
|
*/
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
const newList = this._createInstance();
|
|
1380
|
-
for (let i = start; i < end; i++) {
|
|
1381
|
-
newList.push(this.at(i));
|
|
1382
|
-
}
|
|
1383
|
-
return newList;
|
|
1670
|
+
_createInstance(options) {
|
|
1671
|
+
const Ctor = this.constructor;
|
|
1672
|
+
return new Ctor([], { comparator: this.comparator, toElementFn: this.toElementFn, ...options != null ? options : {} });
|
|
1384
1673
|
}
|
|
1385
1674
|
/**
|
|
1386
|
-
*
|
|
1387
|
-
* @
|
|
1388
|
-
* @
|
|
1389
|
-
* @
|
|
1390
|
-
* @
|
|
1391
|
-
* @
|
|
1675
|
+
* (Protected) Create a like-kind instance seeded by elements.
|
|
1676
|
+
* @remarks Time O(N log N), Space O(N)
|
|
1677
|
+
* @template EM
|
|
1678
|
+
* @template RM
|
|
1679
|
+
* @param [elements] - Iterable of elements or raw values to seed.
|
|
1680
|
+
* @param [options] - Options forwarded to the constructor.
|
|
1681
|
+
* @returns A like-kind heap instance.
|
|
1392
1682
|
*/
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1683
|
+
_createLike(elements = [], options) {
|
|
1684
|
+
const Ctor = this.constructor;
|
|
1685
|
+
return new Ctor(elements, options);
|
|
1686
|
+
}
|
|
1687
|
+
/**
|
|
1688
|
+
* (Protected) Spawn an empty like-kind heap instance.
|
|
1689
|
+
* @remarks Time O(1), Space O(1)
|
|
1690
|
+
* @template EM
|
|
1691
|
+
* @template RM
|
|
1692
|
+
* @param [options] - Options forwarded to the constructor.
|
|
1693
|
+
* @returns An empty like-kind heap instance.
|
|
1694
|
+
*/
|
|
1695
|
+
_spawnLike(options) {
|
|
1696
|
+
return this._createLike([], options);
|
|
1403
1697
|
}
|
|
1404
1698
|
};
|
|
1405
1699
|
|
|
@@ -1471,6 +1765,27 @@ var graphTyped = (() => {
|
|
|
1471
1765
|
|
|
1472
1766
|
|
|
1473
1767
|
|
|
1768
|
+
|
|
1769
|
+
|
|
1770
|
+
|
|
1771
|
+
|
|
1772
|
+
|
|
1773
|
+
|
|
1774
|
+
|
|
1775
|
+
|
|
1776
|
+
|
|
1777
|
+
|
|
1778
|
+
|
|
1779
|
+
|
|
1780
|
+
|
|
1781
|
+
|
|
1782
|
+
|
|
1783
|
+
|
|
1784
|
+
|
|
1785
|
+
|
|
1786
|
+
|
|
1787
|
+
|
|
1788
|
+
|
|
1474
1789
|
* @example
|
|
1475
1790
|
* // Track queue length
|
|
1476
1791
|
* const q = new Queue<number>();
|
|
@@ -1497,6 +1812,27 @@ var graphTyped = (() => {
|
|
|
1497
1812
|
|
|
1498
1813
|
|
|
1499
1814
|
|
|
1815
|
+
|
|
1816
|
+
|
|
1817
|
+
|
|
1818
|
+
|
|
1819
|
+
|
|
1820
|
+
|
|
1821
|
+
|
|
1822
|
+
|
|
1823
|
+
|
|
1824
|
+
|
|
1825
|
+
|
|
1826
|
+
|
|
1827
|
+
|
|
1828
|
+
|
|
1829
|
+
|
|
1830
|
+
|
|
1831
|
+
|
|
1832
|
+
|
|
1833
|
+
|
|
1834
|
+
|
|
1835
|
+
|
|
1500
1836
|
* @example
|
|
1501
1837
|
* // View the front element
|
|
1502
1838
|
* const q = new Queue<string>(['first', 'second', 'third']);
|
|
@@ -1539,6 +1875,27 @@ var graphTyped = (() => {
|
|
|
1539
1875
|
|
|
1540
1876
|
|
|
1541
1877
|
|
|
1878
|
+
|
|
1879
|
+
|
|
1880
|
+
|
|
1881
|
+
|
|
1882
|
+
|
|
1883
|
+
|
|
1884
|
+
|
|
1885
|
+
|
|
1886
|
+
|
|
1887
|
+
|
|
1888
|
+
|
|
1889
|
+
|
|
1890
|
+
|
|
1891
|
+
|
|
1892
|
+
|
|
1893
|
+
|
|
1894
|
+
|
|
1895
|
+
|
|
1896
|
+
|
|
1897
|
+
|
|
1898
|
+
|
|
1542
1899
|
* @example
|
|
1543
1900
|
* // Queue for...of iteration and isEmpty check
|
|
1544
1901
|
* const queue = new Queue<string>(['A', 'B', 'C', 'D']);
|
|
@@ -1577,6 +1934,27 @@ var graphTyped = (() => {
|
|
|
1577
1934
|
|
|
1578
1935
|
|
|
1579
1936
|
|
|
1937
|
+
|
|
1938
|
+
|
|
1939
|
+
|
|
1940
|
+
|
|
1941
|
+
|
|
1942
|
+
|
|
1943
|
+
|
|
1944
|
+
|
|
1945
|
+
|
|
1946
|
+
|
|
1947
|
+
|
|
1948
|
+
|
|
1949
|
+
|
|
1950
|
+
|
|
1951
|
+
|
|
1952
|
+
|
|
1953
|
+
|
|
1954
|
+
|
|
1955
|
+
|
|
1956
|
+
|
|
1957
|
+
|
|
1580
1958
|
* @example
|
|
1581
1959
|
* // basic Queue creation and push operation
|
|
1582
1960
|
* // Create a simple Queue with initial values
|
|
@@ -1622,6 +2000,27 @@ var graphTyped = (() => {
|
|
|
1622
2000
|
|
|
1623
2001
|
|
|
1624
2002
|
|
|
2003
|
+
|
|
2004
|
+
|
|
2005
|
+
|
|
2006
|
+
|
|
2007
|
+
|
|
2008
|
+
|
|
2009
|
+
|
|
2010
|
+
|
|
2011
|
+
|
|
2012
|
+
|
|
2013
|
+
|
|
2014
|
+
|
|
2015
|
+
|
|
2016
|
+
|
|
2017
|
+
|
|
2018
|
+
|
|
2019
|
+
|
|
2020
|
+
|
|
2021
|
+
|
|
2022
|
+
|
|
2023
|
+
|
|
1625
2024
|
* @example
|
|
1626
2025
|
* // Queue shift and peek operations
|
|
1627
2026
|
* const queue = new Queue<number>([10, 20, 30, 40]);
|
|
@@ -1657,6 +2056,27 @@ var graphTyped = (() => {
|
|
|
1657
2056
|
|
|
1658
2057
|
|
|
1659
2058
|
|
|
2059
|
+
|
|
2060
|
+
|
|
2061
|
+
|
|
2062
|
+
|
|
2063
|
+
|
|
2064
|
+
|
|
2065
|
+
|
|
2066
|
+
|
|
2067
|
+
|
|
2068
|
+
|
|
2069
|
+
|
|
2070
|
+
|
|
2071
|
+
|
|
2072
|
+
|
|
2073
|
+
|
|
2074
|
+
|
|
2075
|
+
|
|
2076
|
+
|
|
2077
|
+
|
|
2078
|
+
|
|
2079
|
+
|
|
1660
2080
|
* @example
|
|
1661
2081
|
* // Remove specific element
|
|
1662
2082
|
* const q = new Queue<number>([1, 2, 3, 2]);
|
|
@@ -1685,6 +2105,27 @@ var graphTyped = (() => {
|
|
|
1685
2105
|
|
|
1686
2106
|
|
|
1687
2107
|
|
|
2108
|
+
|
|
2109
|
+
|
|
2110
|
+
|
|
2111
|
+
|
|
2112
|
+
|
|
2113
|
+
|
|
2114
|
+
|
|
2115
|
+
|
|
2116
|
+
|
|
2117
|
+
|
|
2118
|
+
|
|
2119
|
+
|
|
2120
|
+
|
|
2121
|
+
|
|
2122
|
+
|
|
2123
|
+
|
|
2124
|
+
|
|
2125
|
+
|
|
2126
|
+
|
|
2127
|
+
|
|
2128
|
+
|
|
1688
2129
|
* @example
|
|
1689
2130
|
* // Access element by index
|
|
1690
2131
|
* const q = new Queue<string>(['a', 'b', 'c']);
|
|
@@ -1754,6 +2195,27 @@ var graphTyped = (() => {
|
|
|
1754
2195
|
|
|
1755
2196
|
|
|
1756
2197
|
|
|
2198
|
+
|
|
2199
|
+
|
|
2200
|
+
|
|
2201
|
+
|
|
2202
|
+
|
|
2203
|
+
|
|
2204
|
+
|
|
2205
|
+
|
|
2206
|
+
|
|
2207
|
+
|
|
2208
|
+
|
|
2209
|
+
|
|
2210
|
+
|
|
2211
|
+
|
|
2212
|
+
|
|
2213
|
+
|
|
2214
|
+
|
|
2215
|
+
|
|
2216
|
+
|
|
2217
|
+
|
|
2218
|
+
|
|
1757
2219
|
* @example
|
|
1758
2220
|
* // Remove all elements
|
|
1759
2221
|
* const q = new Queue<number>([1, 2, 3]);
|
|
@@ -1776,6 +2238,27 @@ var graphTyped = (() => {
|
|
|
1776
2238
|
|
|
1777
2239
|
|
|
1778
2240
|
|
|
2241
|
+
|
|
2242
|
+
|
|
2243
|
+
|
|
2244
|
+
|
|
2245
|
+
|
|
2246
|
+
|
|
2247
|
+
|
|
2248
|
+
|
|
2249
|
+
|
|
2250
|
+
|
|
2251
|
+
|
|
2252
|
+
|
|
2253
|
+
|
|
2254
|
+
|
|
2255
|
+
|
|
2256
|
+
|
|
2257
|
+
|
|
2258
|
+
|
|
2259
|
+
|
|
2260
|
+
|
|
2261
|
+
|
|
1779
2262
|
* @example
|
|
1780
2263
|
* // Reclaim unused memory
|
|
1781
2264
|
* const q = new Queue<number>([1, 2, 3, 4, 5]);
|
|
@@ -1821,6 +2304,27 @@ var graphTyped = (() => {
|
|
|
1821
2304
|
|
|
1822
2305
|
|
|
1823
2306
|
|
|
2307
|
+
|
|
2308
|
+
|
|
2309
|
+
|
|
2310
|
+
|
|
2311
|
+
|
|
2312
|
+
|
|
2313
|
+
|
|
2314
|
+
|
|
2315
|
+
|
|
2316
|
+
|
|
2317
|
+
|
|
2318
|
+
|
|
2319
|
+
|
|
2320
|
+
|
|
2321
|
+
|
|
2322
|
+
|
|
2323
|
+
|
|
2324
|
+
|
|
2325
|
+
|
|
2326
|
+
|
|
2327
|
+
|
|
1824
2328
|
* @example
|
|
1825
2329
|
* // Create independent copy
|
|
1826
2330
|
* const q = new Queue<number>([1, 2, 3]);
|
|
@@ -1850,6 +2354,27 @@ var graphTyped = (() => {
|
|
|
1850
2354
|
|
|
1851
2355
|
|
|
1852
2356
|
|
|
2357
|
+
|
|
2358
|
+
|
|
2359
|
+
|
|
2360
|
+
|
|
2361
|
+
|
|
2362
|
+
|
|
2363
|
+
|
|
2364
|
+
|
|
2365
|
+
|
|
2366
|
+
|
|
2367
|
+
|
|
2368
|
+
|
|
2369
|
+
|
|
2370
|
+
|
|
2371
|
+
|
|
2372
|
+
|
|
2373
|
+
|
|
2374
|
+
|
|
2375
|
+
|
|
2376
|
+
|
|
2377
|
+
|
|
1853
2378
|
* @example
|
|
1854
2379
|
* // Filter elements
|
|
1855
2380
|
* const q = new Queue<number>([1, 2, 3, 4, 5]);
|
|
@@ -1883,6 +2408,27 @@ var graphTyped = (() => {
|
|
|
1883
2408
|
|
|
1884
2409
|
|
|
1885
2410
|
|
|
2411
|
+
|
|
2412
|
+
|
|
2413
|
+
|
|
2414
|
+
|
|
2415
|
+
|
|
2416
|
+
|
|
2417
|
+
|
|
2418
|
+
|
|
2419
|
+
|
|
2420
|
+
|
|
2421
|
+
|
|
2422
|
+
|
|
2423
|
+
|
|
2424
|
+
|
|
2425
|
+
|
|
2426
|
+
|
|
2427
|
+
|
|
2428
|
+
|
|
2429
|
+
|
|
2430
|
+
|
|
2431
|
+
|
|
1886
2432
|
* @example
|
|
1887
2433
|
* // Transform elements
|
|
1888
2434
|
* const q = new Queue<number>([1, 2, 3]);
|
|
@@ -2989,6 +3535,27 @@ var graphTyped = (() => {
|
|
|
2989
3535
|
|
|
2990
3536
|
|
|
2991
3537
|
|
|
3538
|
+
|
|
3539
|
+
|
|
3540
|
+
|
|
3541
|
+
|
|
3542
|
+
|
|
3543
|
+
|
|
3544
|
+
|
|
3545
|
+
|
|
3546
|
+
|
|
3547
|
+
|
|
3548
|
+
|
|
3549
|
+
|
|
3550
|
+
|
|
3551
|
+
|
|
3552
|
+
|
|
3553
|
+
|
|
3554
|
+
|
|
3555
|
+
|
|
3556
|
+
|
|
3557
|
+
|
|
3558
|
+
|
|
2992
3559
|
* @example
|
|
2993
3560
|
* // Get edge between vertices
|
|
2994
3561
|
* const g = new DirectedGraph();
|
|
@@ -3053,6 +3620,27 @@ var graphTyped = (() => {
|
|
|
3053
3620
|
|
|
3054
3621
|
|
|
3055
3622
|
|
|
3623
|
+
|
|
3624
|
+
|
|
3625
|
+
|
|
3626
|
+
|
|
3627
|
+
|
|
3628
|
+
|
|
3629
|
+
|
|
3630
|
+
|
|
3631
|
+
|
|
3632
|
+
|
|
3633
|
+
|
|
3634
|
+
|
|
3635
|
+
|
|
3636
|
+
|
|
3637
|
+
|
|
3638
|
+
|
|
3639
|
+
|
|
3640
|
+
|
|
3641
|
+
|
|
3642
|
+
|
|
3643
|
+
|
|
3056
3644
|
* @example
|
|
3057
3645
|
* // DirectedGraph deleteEdge and vertex operations
|
|
3058
3646
|
* const graph = new DirectedGraph<string>();
|
|
@@ -3115,6 +3703,27 @@ var graphTyped = (() => {
|
|
|
3115
3703
|
|
|
3116
3704
|
|
|
3117
3705
|
|
|
3706
|
+
|
|
3707
|
+
|
|
3708
|
+
|
|
3709
|
+
|
|
3710
|
+
|
|
3711
|
+
|
|
3712
|
+
|
|
3713
|
+
|
|
3714
|
+
|
|
3715
|
+
|
|
3716
|
+
|
|
3717
|
+
|
|
3718
|
+
|
|
3719
|
+
|
|
3720
|
+
|
|
3721
|
+
|
|
3722
|
+
|
|
3723
|
+
|
|
3724
|
+
|
|
3725
|
+
|
|
3726
|
+
|
|
3118
3727
|
* @example
|
|
3119
3728
|
* // Remove a vertex
|
|
3120
3729
|
* const g = new DirectedGraph();
|
|
@@ -3168,6 +3777,27 @@ var graphTyped = (() => {
|
|
|
3168
3777
|
|
|
3169
3778
|
|
|
3170
3779
|
|
|
3780
|
+
|
|
3781
|
+
|
|
3782
|
+
|
|
3783
|
+
|
|
3784
|
+
|
|
3785
|
+
|
|
3786
|
+
|
|
3787
|
+
|
|
3788
|
+
|
|
3789
|
+
|
|
3790
|
+
|
|
3791
|
+
|
|
3792
|
+
|
|
3793
|
+
|
|
3794
|
+
|
|
3795
|
+
|
|
3796
|
+
|
|
3797
|
+
|
|
3798
|
+
|
|
3799
|
+
|
|
3800
|
+
|
|
3171
3801
|
* @example
|
|
3172
3802
|
* // Get incoming edges
|
|
3173
3803
|
* const g = new DirectedGraph();
|
|
@@ -3198,6 +3828,27 @@ var graphTyped = (() => {
|
|
|
3198
3828
|
|
|
3199
3829
|
|
|
3200
3830
|
|
|
3831
|
+
|
|
3832
|
+
|
|
3833
|
+
|
|
3834
|
+
|
|
3835
|
+
|
|
3836
|
+
|
|
3837
|
+
|
|
3838
|
+
|
|
3839
|
+
|
|
3840
|
+
|
|
3841
|
+
|
|
3842
|
+
|
|
3843
|
+
|
|
3844
|
+
|
|
3845
|
+
|
|
3846
|
+
|
|
3847
|
+
|
|
3848
|
+
|
|
3849
|
+
|
|
3850
|
+
|
|
3851
|
+
|
|
3201
3852
|
* @example
|
|
3202
3853
|
* // Get outgoing edges
|
|
3203
3854
|
* const g = new DirectedGraph();
|
|
@@ -3281,6 +3932,27 @@ var graphTyped = (() => {
|
|
|
3281
3932
|
|
|
3282
3933
|
|
|
3283
3934
|
|
|
3935
|
+
|
|
3936
|
+
|
|
3937
|
+
|
|
3938
|
+
|
|
3939
|
+
|
|
3940
|
+
|
|
3941
|
+
|
|
3942
|
+
|
|
3943
|
+
|
|
3944
|
+
|
|
3945
|
+
|
|
3946
|
+
|
|
3947
|
+
|
|
3948
|
+
|
|
3949
|
+
|
|
3950
|
+
|
|
3951
|
+
|
|
3952
|
+
|
|
3953
|
+
|
|
3954
|
+
|
|
3955
|
+
|
|
3284
3956
|
* @example
|
|
3285
3957
|
* // DirectedGraph topologicalSort for task scheduling
|
|
3286
3958
|
* const graph = new DirectedGraph<string>();
|
|
@@ -3345,6 +4017,27 @@ var graphTyped = (() => {
|
|
|
3345
4017
|
|
|
3346
4018
|
|
|
3347
4019
|
|
|
4020
|
+
|
|
4021
|
+
|
|
4022
|
+
|
|
4023
|
+
|
|
4024
|
+
|
|
4025
|
+
|
|
4026
|
+
|
|
4027
|
+
|
|
4028
|
+
|
|
4029
|
+
|
|
4030
|
+
|
|
4031
|
+
|
|
4032
|
+
|
|
4033
|
+
|
|
4034
|
+
|
|
4035
|
+
|
|
4036
|
+
|
|
4037
|
+
|
|
4038
|
+
|
|
4039
|
+
|
|
4040
|
+
|
|
3348
4041
|
* @example
|
|
3349
4042
|
* // Get all edges
|
|
3350
4043
|
* const g = new DirectedGraph();
|
|
@@ -3371,6 +4064,27 @@ var graphTyped = (() => {
|
|
|
3371
4064
|
|
|
3372
4065
|
|
|
3373
4066
|
|
|
4067
|
+
|
|
4068
|
+
|
|
4069
|
+
|
|
4070
|
+
|
|
4071
|
+
|
|
4072
|
+
|
|
4073
|
+
|
|
4074
|
+
|
|
4075
|
+
|
|
4076
|
+
|
|
4077
|
+
|
|
4078
|
+
|
|
4079
|
+
|
|
4080
|
+
|
|
4081
|
+
|
|
4082
|
+
|
|
4083
|
+
|
|
4084
|
+
|
|
4085
|
+
|
|
4086
|
+
|
|
4087
|
+
|
|
3374
4088
|
* @example
|
|
3375
4089
|
* // Get outgoing neighbors
|
|
3376
4090
|
* const g = new DirectedGraph();
|
|
@@ -3450,6 +4164,27 @@ var graphTyped = (() => {
|
|
|
3450
4164
|
|
|
3451
4165
|
|
|
3452
4166
|
|
|
4167
|
+
|
|
4168
|
+
|
|
4169
|
+
|
|
4170
|
+
|
|
4171
|
+
|
|
4172
|
+
|
|
4173
|
+
|
|
4174
|
+
|
|
4175
|
+
|
|
4176
|
+
|
|
4177
|
+
|
|
4178
|
+
|
|
4179
|
+
|
|
4180
|
+
|
|
4181
|
+
|
|
4182
|
+
|
|
4183
|
+
|
|
4184
|
+
|
|
4185
|
+
|
|
4186
|
+
|
|
4187
|
+
|
|
3453
4188
|
* @example
|
|
3454
4189
|
* // Find strongly connected components
|
|
3455
4190
|
* const g = new DirectedGraph();
|
|
@@ -3532,6 +4267,27 @@ var graphTyped = (() => {
|
|
|
3532
4267
|
|
|
3533
4268
|
|
|
3534
4269
|
|
|
4270
|
+
|
|
4271
|
+
|
|
4272
|
+
|
|
4273
|
+
|
|
4274
|
+
|
|
4275
|
+
|
|
4276
|
+
|
|
4277
|
+
|
|
4278
|
+
|
|
4279
|
+
|
|
4280
|
+
|
|
4281
|
+
|
|
4282
|
+
|
|
4283
|
+
|
|
4284
|
+
|
|
4285
|
+
|
|
4286
|
+
|
|
4287
|
+
|
|
4288
|
+
|
|
4289
|
+
|
|
4290
|
+
|
|
3535
4291
|
* @example
|
|
3536
4292
|
* // Get strongly connected components
|
|
3537
4293
|
* const g = new DirectedGraph();
|
|
@@ -3672,6 +4428,27 @@ var graphTyped = (() => {
|
|
|
3672
4428
|
|
|
3673
4429
|
|
|
3674
4430
|
|
|
4431
|
+
|
|
4432
|
+
|
|
4433
|
+
|
|
4434
|
+
|
|
4435
|
+
|
|
4436
|
+
|
|
4437
|
+
|
|
4438
|
+
|
|
4439
|
+
|
|
4440
|
+
|
|
4441
|
+
|
|
4442
|
+
|
|
4443
|
+
|
|
4444
|
+
|
|
4445
|
+
|
|
4446
|
+
|
|
4447
|
+
|
|
4448
|
+
|
|
4449
|
+
|
|
4450
|
+
|
|
4451
|
+
|
|
3675
4452
|
* @example
|
|
3676
4453
|
* // Get edge between vertices
|
|
3677
4454
|
* const g = new UndirectedGraph();
|
|
@@ -3733,6 +4510,27 @@ var graphTyped = (() => {
|
|
|
3733
4510
|
|
|
3734
4511
|
|
|
3735
4512
|
|
|
4513
|
+
|
|
4514
|
+
|
|
4515
|
+
|
|
4516
|
+
|
|
4517
|
+
|
|
4518
|
+
|
|
4519
|
+
|
|
4520
|
+
|
|
4521
|
+
|
|
4522
|
+
|
|
4523
|
+
|
|
4524
|
+
|
|
4525
|
+
|
|
4526
|
+
|
|
4527
|
+
|
|
4528
|
+
|
|
4529
|
+
|
|
4530
|
+
|
|
4531
|
+
|
|
4532
|
+
|
|
4533
|
+
|
|
3736
4534
|
* @example
|
|
3737
4535
|
* // UndirectedGraph deleteEdge and vertex operations
|
|
3738
4536
|
* const graph = new UndirectedGraph<string>();
|
|
@@ -3793,6 +4591,27 @@ var graphTyped = (() => {
|
|
|
3793
4591
|
|
|
3794
4592
|
|
|
3795
4593
|
|
|
4594
|
+
|
|
4595
|
+
|
|
4596
|
+
|
|
4597
|
+
|
|
4598
|
+
|
|
4599
|
+
|
|
4600
|
+
|
|
4601
|
+
|
|
4602
|
+
|
|
4603
|
+
|
|
4604
|
+
|
|
4605
|
+
|
|
4606
|
+
|
|
4607
|
+
|
|
4608
|
+
|
|
4609
|
+
|
|
4610
|
+
|
|
4611
|
+
|
|
4612
|
+
|
|
4613
|
+
|
|
4614
|
+
|
|
3796
4615
|
* @example
|
|
3797
4616
|
* // Remove vertex and edges
|
|
3798
4617
|
* const g = new UndirectedGraph();
|
|
@@ -3868,6 +4687,27 @@ var graphTyped = (() => {
|
|
|
3868
4687
|
|
|
3869
4688
|
|
|
3870
4689
|
|
|
4690
|
+
|
|
4691
|
+
|
|
4692
|
+
|
|
4693
|
+
|
|
4694
|
+
|
|
4695
|
+
|
|
4696
|
+
|
|
4697
|
+
|
|
4698
|
+
|
|
4699
|
+
|
|
4700
|
+
|
|
4701
|
+
|
|
4702
|
+
|
|
4703
|
+
|
|
4704
|
+
|
|
4705
|
+
|
|
4706
|
+
|
|
4707
|
+
|
|
4708
|
+
|
|
4709
|
+
|
|
4710
|
+
|
|
3871
4711
|
* @example
|
|
3872
4712
|
* // Get all edges
|
|
3873
4713
|
* const g = new UndirectedGraph();
|
|
@@ -3898,6 +4738,27 @@ var graphTyped = (() => {
|
|
|
3898
4738
|
|
|
3899
4739
|
|
|
3900
4740
|
|
|
4741
|
+
|
|
4742
|
+
|
|
4743
|
+
|
|
4744
|
+
|
|
4745
|
+
|
|
4746
|
+
|
|
4747
|
+
|
|
4748
|
+
|
|
4749
|
+
|
|
4750
|
+
|
|
4751
|
+
|
|
4752
|
+
|
|
4753
|
+
|
|
4754
|
+
|
|
4755
|
+
|
|
4756
|
+
|
|
4757
|
+
|
|
4758
|
+
|
|
4759
|
+
|
|
4760
|
+
|
|
4761
|
+
|
|
3901
4762
|
* @example
|
|
3902
4763
|
* // UndirectedGraph connectivity and neighbors
|
|
3903
4764
|
* const graph = new UndirectedGraph<string>();
|
|
@@ -3998,6 +4859,27 @@ var graphTyped = (() => {
|
|
|
3998
4859
|
|
|
3999
4860
|
|
|
4000
4861
|
|
|
4862
|
+
|
|
4863
|
+
|
|
4864
|
+
|
|
4865
|
+
|
|
4866
|
+
|
|
4867
|
+
|
|
4868
|
+
|
|
4869
|
+
|
|
4870
|
+
|
|
4871
|
+
|
|
4872
|
+
|
|
4873
|
+
|
|
4874
|
+
|
|
4875
|
+
|
|
4876
|
+
|
|
4877
|
+
|
|
4878
|
+
|
|
4879
|
+
|
|
4880
|
+
|
|
4881
|
+
|
|
4882
|
+
|
|
4001
4883
|
* @example
|
|
4002
4884
|
* // Find articulation points and bridges
|
|
4003
4885
|
* const g = new UndirectedGraph();
|
|
@@ -4120,6 +5002,27 @@ var graphTyped = (() => {
|
|
|
4120
5002
|
|
|
4121
5003
|
|
|
4122
5004
|
|
|
5005
|
+
|
|
5006
|
+
|
|
5007
|
+
|
|
5008
|
+
|
|
5009
|
+
|
|
5010
|
+
|
|
5011
|
+
|
|
5012
|
+
|
|
5013
|
+
|
|
5014
|
+
|
|
5015
|
+
|
|
5016
|
+
|
|
5017
|
+
|
|
5018
|
+
|
|
5019
|
+
|
|
5020
|
+
|
|
5021
|
+
|
|
5022
|
+
|
|
5023
|
+
|
|
5024
|
+
|
|
5025
|
+
|
|
4123
5026
|
* @example
|
|
4124
5027
|
* // Detect cycle
|
|
4125
5028
|
* const g = new UndirectedGraph();
|
|
@@ -4164,6 +5067,27 @@ var graphTyped = (() => {
|
|
|
4164
5067
|
|
|
4165
5068
|
|
|
4166
5069
|
|
|
5070
|
+
|
|
5071
|
+
|
|
5072
|
+
|
|
5073
|
+
|
|
5074
|
+
|
|
5075
|
+
|
|
5076
|
+
|
|
5077
|
+
|
|
5078
|
+
|
|
5079
|
+
|
|
5080
|
+
|
|
5081
|
+
|
|
5082
|
+
|
|
5083
|
+
|
|
5084
|
+
|
|
5085
|
+
|
|
5086
|
+
|
|
5087
|
+
|
|
5088
|
+
|
|
5089
|
+
|
|
5090
|
+
|
|
4167
5091
|
* @example
|
|
4168
5092
|
* // Find bridge edges
|
|
4169
5093
|
* const g = new UndirectedGraph();
|
|
@@ -4190,6 +5114,27 @@ var graphTyped = (() => {
|
|
|
4190
5114
|
|
|
4191
5115
|
|
|
4192
5116
|
|
|
5117
|
+
|
|
5118
|
+
|
|
5119
|
+
|
|
5120
|
+
|
|
5121
|
+
|
|
5122
|
+
|
|
5123
|
+
|
|
5124
|
+
|
|
5125
|
+
|
|
5126
|
+
|
|
5127
|
+
|
|
5128
|
+
|
|
5129
|
+
|
|
5130
|
+
|
|
5131
|
+
|
|
5132
|
+
|
|
5133
|
+
|
|
5134
|
+
|
|
5135
|
+
|
|
5136
|
+
|
|
5137
|
+
|
|
4193
5138
|
* @example
|
|
4194
5139
|
* // Find articulation points
|
|
4195
5140
|
* const g = new UndirectedGraph();
|