directed-graph-typed 2.1.2 → 2.2.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.
Files changed (37) hide show
  1. package/dist/cjs/index.cjs +108 -106
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +2798 -0
  4. package/dist/cjs-legacy/index.cjs.map +1 -0
  5. package/dist/esm/index.mjs +108 -106
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +2789 -0
  8. package/dist/esm-legacy/index.mjs.map +1 -0
  9. package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +57 -3
  10. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +65 -3
  11. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +61 -5
  12. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +1 -0
  13. package/dist/types/data-structures/binary-tree/bst.d.ts +58 -3
  14. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +59 -4
  15. package/dist/types/data-structures/binary-tree/tree-counter.d.ts +57 -3
  16. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +66 -3
  17. package/dist/types/types/data-structures/base/base.d.ts +1 -1
  18. package/dist/umd/directed-graph-typed.js +7 -7
  19. package/dist/umd/directed-graph-typed.js.map +1 -1
  20. package/dist/umd/directed-graph-typed.min.js +1 -1
  21. package/dist/umd/directed-graph-typed.min.js.map +1 -1
  22. package/package.json +20 -2
  23. package/src/data-structures/base/iterable-entry-base.ts +4 -4
  24. package/src/data-structures/binary-tree/avl-tree-counter.ts +103 -12
  25. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +116 -12
  26. package/src/data-structures/binary-tree/avl-tree.ts +109 -16
  27. package/src/data-structures/binary-tree/binary-tree.ts +3 -2
  28. package/src/data-structures/binary-tree/bst.ts +104 -12
  29. package/src/data-structures/binary-tree/red-black-tree.ts +110 -19
  30. package/src/data-structures/binary-tree/tree-counter.ts +102 -11
  31. package/src/data-structures/binary-tree/tree-multi-map.ts +124 -12
  32. package/src/data-structures/graph/abstract-graph.ts +8 -8
  33. package/src/data-structures/graph/directed-graph.ts +5 -5
  34. package/src/data-structures/graph/undirected-graph.ts +5 -5
  35. package/src/data-structures/hash/hash-map.ts +4 -4
  36. package/src/types/data-structures/base/base.ts +1 -1
  37. package/tsup.node.config.js +40 -6
@@ -1,9 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var __defProp = Object.defineProperty;
4
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5
4
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
5
 
8
6
  // src/utils/utils.ts
9
7
  var uuidV4 = /* @__PURE__ */ __name(function() {
@@ -59,7 +57,10 @@ function isComparable(value, isForceObjectComparable = false) {
59
57
  __name(isComparable, "isComparable");
60
58
 
61
59
  // src/data-structures/base/iterable-entry-base.ts
62
- var _IterableEntryBase = class _IterableEntryBase {
60
+ var IterableEntryBase = class {
61
+ static {
62
+ __name(this, "IterableEntryBase");
63
+ }
63
64
  /**
64
65
  * Default iterator yielding `[key, value]` entries.
65
66
  * @returns Iterator of `[K, V]`.
@@ -108,7 +109,7 @@ var _IterableEntryBase = class _IterableEntryBase {
108
109
  every(predicate, thisArg) {
109
110
  let index = 0;
110
111
  for (const item of this) {
111
- if (!predicate.call(thisArg, item[0], item[1], index++, this)) {
112
+ if (!predicate.call(thisArg, item[1], item[0], index++, this)) {
112
113
  return false;
113
114
  }
114
115
  }
@@ -124,7 +125,7 @@ var _IterableEntryBase = class _IterableEntryBase {
124
125
  some(predicate, thisArg) {
125
126
  let index = 0;
126
127
  for (const item of this) {
127
- if (predicate.call(thisArg, item[0], item[1], index++, this)) {
128
+ if (predicate.call(thisArg, item[1], item[0], index++, this)) {
128
129
  return true;
129
130
  }
130
131
  }
@@ -140,7 +141,7 @@ var _IterableEntryBase = class _IterableEntryBase {
140
141
  let index = 0;
141
142
  for (const item of this) {
142
143
  const [key, value] = item;
143
- callbackfn.call(thisArg, key, value, index++, this);
144
+ callbackfn.call(thisArg, value, key, index++, this);
144
145
  }
145
146
  }
146
147
  /**
@@ -154,7 +155,7 @@ var _IterableEntryBase = class _IterableEntryBase {
154
155
  let index = 0;
155
156
  for (const item of this) {
156
157
  const [key, value] = item;
157
- if (callbackfn.call(thisArg, key, value, index++, this)) return item;
158
+ if (callbackfn.call(thisArg, value, key, index++, this)) return item;
158
159
  }
159
160
  return;
160
161
  }
@@ -228,11 +229,12 @@ var _IterableEntryBase = class _IterableEntryBase {
228
229
  console.log(this.toVisual());
229
230
  }
230
231
  };
231
- __name(_IterableEntryBase, "IterableEntryBase");
232
- var IterableEntryBase = _IterableEntryBase;
233
232
 
234
233
  // src/data-structures/base/iterable-element-base.ts
235
- var _IterableElementBase = class _IterableElementBase {
234
+ var IterableElementBase = class {
235
+ static {
236
+ __name(this, "IterableElementBase");
237
+ }
236
238
  /**
237
239
  * Create a new iterable base.
238
240
  *
@@ -243,19 +245,19 @@ var _IterableElementBase = class _IterableElementBase {
243
245
  * Time O(1), Space O(1).
244
246
  */
245
247
  constructor(options) {
246
- /**
247
- * The converter used to transform a raw element (`R`) into a public element (`E`).
248
- *
249
- * @remarks
250
- * Time O(1), Space O(1).
251
- */
252
- __publicField(this, "_toElementFn");
253
248
  if (options) {
254
249
  const { toElementFn } = options;
255
250
  if (typeof toElementFn === "function") this._toElementFn = toElementFn;
256
251
  else if (toElementFn) throw new TypeError("toElementFn must be a function type");
257
252
  }
258
253
  }
254
+ /**
255
+ * The converter used to transform a raw element (`R`) into a public element (`E`).
256
+ *
257
+ * @remarks
258
+ * Time O(1), Space O(1).
259
+ */
260
+ _toElementFn;
259
261
  /**
260
262
  * Exposes the current `toElementFn`, if configured.
261
263
  *
@@ -450,11 +452,13 @@ var _IterableElementBase = class _IterableElementBase {
450
452
  console.log(this.toVisual());
451
453
  }
452
454
  };
453
- __name(_IterableElementBase, "IterableElementBase");
454
- var IterableElementBase = _IterableElementBase;
455
455
 
456
456
  // src/data-structures/heap/heap.ts
457
- var _Heap = class _Heap extends IterableElementBase {
457
+ var Heap = class _Heap extends IterableElementBase {
458
+ static {
459
+ __name(this, "Heap");
460
+ }
461
+ _equals = Object.is;
458
462
  /**
459
463
  * Create a Heap and optionally bulk-insert elements.
460
464
  * @remarks Time O(N), Space O(N)
@@ -464,23 +468,13 @@ var _Heap = class _Heap extends IterableElementBase {
464
468
  */
465
469
  constructor(elements = [], options) {
466
470
  super(options);
467
- __publicField(this, "_equals", Object.is);
468
- __publicField(this, "_elements", []);
469
- __publicField(this, "_DEFAULT_COMPARATOR", /* @__PURE__ */ __name((a, b) => {
470
- if (typeof a === "object" || typeof b === "object") {
471
- throw TypeError("When comparing object types, define a custom comparator in options.");
472
- }
473
- if (a > b) return 1;
474
- if (a < b) return -1;
475
- return 0;
476
- }, "_DEFAULT_COMPARATOR"));
477
- __publicField(this, "_comparator", this._DEFAULT_COMPARATOR);
478
471
  if (options) {
479
472
  const { comparator } = options;
480
473
  if (comparator) this._comparator = comparator;
481
474
  }
482
475
  this.addMany(elements);
483
476
  }
477
+ _elements = [];
484
478
  /**
485
479
  * Get the backing array of the heap.
486
480
  * @remarks Time O(1), Space O(1)
@@ -503,8 +497,7 @@ var _Heap = class _Heap extends IterableElementBase {
503
497
  * @returns Last element or undefined.
504
498
  */
505
499
  get leaf() {
506
- var _a;
507
- return (_a = this.elements[this.size - 1]) != null ? _a : void 0;
500
+ return this.elements[this.size - 1] ?? void 0;
508
501
  }
509
502
  /**
510
503
  * Create a heap of the same class from an iterable.
@@ -777,7 +770,7 @@ var _Heap = class _Heap extends IterableElementBase {
777
770
  * @returns A new heap with mapped elements.
778
771
  */
779
772
  map(callback, options, thisArg) {
780
- const { comparator, toElementFn, ...rest } = options != null ? options : {};
773
+ const { comparator, toElementFn, ...rest } = options ?? {};
781
774
  if (!comparator) throw new TypeError("Heap.map requires options.comparator for EM");
782
775
  const out = this._createLike([], { ...rest, comparator, toElementFn });
783
776
  let i = 0;
@@ -803,6 +796,15 @@ var _Heap = class _Heap extends IterableElementBase {
803
796
  }
804
797
  return out;
805
798
  }
799
+ _DEFAULT_COMPARATOR = /* @__PURE__ */ __name((a, b) => {
800
+ if (typeof a === "object" || typeof b === "object") {
801
+ throw TypeError("When comparing object types, define a custom comparator in options.");
802
+ }
803
+ if (a > b) return 1;
804
+ if (a < b) return -1;
805
+ return 0;
806
+ }, "_DEFAULT_COMPARATOR");
807
+ _comparator = this._DEFAULT_COMPARATOR;
806
808
  /**
807
809
  * Get the comparator used to order elements.
808
810
  * @remarks Time O(1), Space O(1)
@@ -856,7 +858,7 @@ var _Heap = class _Heap extends IterableElementBase {
856
858
  */
857
859
  _createInstance(options) {
858
860
  const Ctor = this.constructor;
859
- const next = new Ctor([], { comparator: this.comparator, toElementFn: this.toElementFn, ...options != null ? options : {} });
861
+ const next = new Ctor([], { comparator: this.comparator, toElementFn: this.toElementFn, ...options ?? {} });
860
862
  return next;
861
863
  }
862
864
  /**
@@ -884,11 +886,12 @@ var _Heap = class _Heap extends IterableElementBase {
884
886
  return this._createLike([], options);
885
887
  }
886
888
  };
887
- __name(_Heap, "Heap");
888
- var Heap = _Heap;
889
889
 
890
890
  // src/data-structures/base/linear-base.ts
891
- var _LinearBase = class _LinearBase extends IterableElementBase {
891
+ var LinearBase = class _LinearBase extends IterableElementBase {
892
+ static {
893
+ __name(this, "LinearBase");
894
+ }
892
895
  /**
893
896
  * Construct a linear container with runtime options.
894
897
  * @param options - `{ maxLen?, ... }` bounds/behavior options.
@@ -896,12 +899,12 @@ var _LinearBase = class _LinearBase extends IterableElementBase {
896
899
  */
897
900
  constructor(options) {
898
901
  super(options);
899
- __publicField(this, "_maxLen", -1);
900
902
  if (options) {
901
903
  const { maxLen } = options;
902
904
  if (typeof maxLen === "number" && maxLen > 0 && maxLen % 1 === 0) this._maxLen = maxLen;
903
905
  }
904
906
  }
907
+ _maxLen = -1;
905
908
  /**
906
909
  * Upper bound for length (if positive), or `-1` when unbounded.
907
910
  * @returns Maximum allowed length.
@@ -1034,7 +1037,7 @@ var _LinearBase = class _LinearBase extends IterableElementBase {
1034
1037
  return array;
1035
1038
  }
1036
1039
  reduceRight(callbackfn, initialValue) {
1037
- let accumulator = initialValue != null ? initialValue : 0;
1040
+ let accumulator = initialValue ?? 0;
1038
1041
  for (let i = this.length - 1; i >= 0; i--) {
1039
1042
  accumulator = callbackfn(accumulator, this.at(i), i, this);
1040
1043
  }
@@ -1076,11 +1079,12 @@ var _LinearBase = class _LinearBase extends IterableElementBase {
1076
1079
  return this;
1077
1080
  }
1078
1081
  };
1079
- __name(_LinearBase, "LinearBase");
1080
- var LinearBase = _LinearBase;
1081
1082
 
1082
1083
  // src/data-structures/queue/queue.ts
1083
- var _Queue = class _Queue extends LinearBase {
1084
+ var Queue = class _Queue extends LinearBase {
1085
+ static {
1086
+ __name(this, "Queue");
1087
+ }
1084
1088
  /**
1085
1089
  * Create a Queue and optionally bulk-insert elements.
1086
1090
  * @remarks Time O(N), Space O(N)
@@ -1090,15 +1094,13 @@ var _Queue = class _Queue extends LinearBase {
1090
1094
  */
1091
1095
  constructor(elements = [], options) {
1092
1096
  super(options);
1093
- __publicField(this, "_elements", []);
1094
- __publicField(this, "_offset", 0);
1095
- __publicField(this, "_autoCompactRatio", 0.5);
1096
1097
  if (options) {
1097
1098
  const { autoCompactRatio = 0.5 } = options;
1098
1099
  this._autoCompactRatio = autoCompactRatio;
1099
1100
  }
1100
1101
  this.pushMany(elements);
1101
1102
  }
1103
+ _elements = [];
1102
1104
  /**
1103
1105
  * Get the underlying array buffer.
1104
1106
  * @remarks Time O(1), Space O(1)
@@ -1107,6 +1109,7 @@ var _Queue = class _Queue extends LinearBase {
1107
1109
  get elements() {
1108
1110
  return this._elements;
1109
1111
  }
1112
+ _offset = 0;
1110
1113
  /**
1111
1114
  * Get the current start offset into the array.
1112
1115
  * @remarks Time O(1), Space O(1)
@@ -1115,6 +1118,7 @@ var _Queue = class _Queue extends LinearBase {
1115
1118
  get offset() {
1116
1119
  return this._offset;
1117
1120
  }
1121
+ _autoCompactRatio = 0.5;
1118
1122
  /**
1119
1123
  * Get the compaction threshold (offset/size).
1120
1124
  * @remarks Time O(1), Space O(1)
@@ -1359,11 +1363,10 @@ var _Queue = class _Queue extends LinearBase {
1359
1363
  * @returns A new Queue with mapped elements.
1360
1364
  */
1361
1365
  map(callback, options, thisArg) {
1362
- var _a, _b;
1363
1366
  const out = new this.constructor([], {
1364
- toElementFn: options == null ? void 0 : options.toElementFn,
1365
- maxLen: (_a = options == null ? void 0 : options.maxLen) != null ? _a : this._maxLen,
1366
- autoCompactRatio: (_b = options == null ? void 0 : options.autoCompactRatio) != null ? _b : this._autoCompactRatio
1367
+ toElementFn: options?.toElementFn,
1368
+ maxLen: options?.maxLen ?? this._maxLen,
1369
+ autoCompactRatio: options?.autoCompactRatio ?? this._autoCompactRatio
1367
1370
  });
1368
1371
  let index = 0;
1369
1372
  for (const v of this)
@@ -1378,14 +1381,13 @@ var _Queue = class _Queue extends LinearBase {
1378
1381
  * @returns A new queue with mapped elements (same element type).
1379
1382
  */
1380
1383
  mapSame(callback, thisArg) {
1381
- var _a;
1382
1384
  const Ctor = this.constructor;
1383
1385
  const out = new Ctor([], {
1384
1386
  toElementFn: this.toElementFn,
1385
1387
  maxLen: this._maxLen,
1386
1388
  autoCompactRatio: this._autoCompactRatio
1387
1389
  });
1388
- (_a = out._setAutoCompactRatio) == null ? void 0 : _a.call(out, this._autoCompactRatio);
1390
+ out._setAutoCompactRatio?.(this._autoCompactRatio);
1389
1391
  let index = 0;
1390
1392
  for (const v of this) {
1391
1393
  const mv = thisArg === void 0 ? callback(v, index++, this) : callback.call(thisArg, v, index++, this);
@@ -1445,36 +1447,39 @@ var _Queue = class _Queue extends LinearBase {
1445
1447
  return new Ctor(elements, options);
1446
1448
  }
1447
1449
  };
1448
- __name(_Queue, "Queue");
1449
- var Queue = _Queue;
1450
1450
 
1451
1451
  // src/data-structures/graph/abstract-graph.ts
1452
- var _AbstractVertex = class _AbstractVertex {
1452
+ var AbstractVertex = class {
1453
+ static {
1454
+ __name(this, "AbstractVertex");
1455
+ }
1456
+ key;
1457
+ value;
1453
1458
  constructor(key, value) {
1454
- __publicField(this, "key");
1455
- __publicField(this, "value");
1456
1459
  this.key = key;
1457
1460
  this.value = value;
1458
1461
  }
1459
1462
  };
1460
- __name(_AbstractVertex, "AbstractVertex");
1461
- var AbstractVertex = _AbstractVertex;
1462
- var _AbstractEdge = class _AbstractEdge {
1463
+ var AbstractEdge = class {
1464
+ static {
1465
+ __name(this, "AbstractEdge");
1466
+ }
1467
+ value;
1468
+ weight;
1463
1469
  constructor(weight, value) {
1464
- __publicField(this, "value");
1465
- __publicField(this, "weight");
1466
- __publicField(this, "_hashCode");
1467
1470
  this.weight = weight !== void 0 ? weight : 1;
1468
1471
  this.value = value;
1469
1472
  this._hashCode = uuidV4();
1470
1473
  }
1474
+ _hashCode;
1471
1475
  get hashCode() {
1472
1476
  return this._hashCode;
1473
1477
  }
1474
1478
  };
1475
- __name(_AbstractEdge, "AbstractEdge");
1476
- var AbstractEdge = _AbstractEdge;
1477
- var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
1479
+ var AbstractGraph = class extends IterableEntryBase {
1480
+ static {
1481
+ __name(this, "AbstractGraph");
1482
+ }
1478
1483
  /**
1479
1484
  * Construct a graph with runtime defaults.
1480
1485
  * @param options - `GraphOptions<V>` in `options.graph` (e.g. `vertexValueInitializer`, `defaultEdgeWeight`).
@@ -1482,14 +1487,14 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
1482
1487
  */
1483
1488
  constructor(options) {
1484
1489
  super();
1485
- __publicField(this, "_options", { defaultEdgeWeight: 1 });
1486
- __publicField(this, "_vertexMap", /* @__PURE__ */ new Map());
1487
- const graph = options == null ? void 0 : options.graph;
1488
- this._options = { defaultEdgeWeight: 1, ...graph != null ? graph : {} };
1490
+ const graph = options?.graph;
1491
+ this._options = { defaultEdgeWeight: 1, ...graph ?? {} };
1489
1492
  }
1493
+ _options = { defaultEdgeWeight: 1 };
1490
1494
  get options() {
1491
1495
  return this._options;
1492
1496
  }
1497
+ _vertexMap = /* @__PURE__ */ new Map();
1493
1498
  get vertexMap() {
1494
1499
  return this._vertexMap;
1495
1500
  }
@@ -1647,10 +1652,9 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
1647
1652
  * @remarks Time O(L), Space O(1) where L is path length
1648
1653
  */
1649
1654
  getPathSumWeight(path) {
1650
- var _a;
1651
1655
  let sum = 0;
1652
1656
  for (let i = 0; i < path.length; i++) {
1653
- sum += ((_a = this.getEdge(path[i], path[i + 1])) == null ? void 0 : _a.weight) || 0;
1657
+ sum += this.getEdge(path[i], path[i + 1])?.weight || 0;
1654
1658
  }
1655
1659
  return sum;
1656
1660
  }
@@ -1712,7 +1716,6 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
1712
1716
  * @remarks Time O((V + E) log V) weighted / O(V + E) unweighted, Space O(V + E)
1713
1717
  */
1714
1718
  getMinPathBetween(v1, v2, isWeight, isDFS = false) {
1715
- var _a, _b;
1716
1719
  if (isWeight === void 0) isWeight = false;
1717
1720
  if (isWeight) {
1718
1721
  if (isDFS) {
@@ -1730,7 +1733,7 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
1730
1733
  }
1731
1734
  return allPaths[minIndex] || void 0;
1732
1735
  } else {
1733
- return (_b = (_a = this.dijkstra(v1, v2, true, true)) == null ? void 0 : _a.minPath) != null ? _b : [];
1736
+ return this.dijkstra(v1, v2, true, true)?.minPath ?? [];
1734
1737
  }
1735
1738
  } else {
1736
1739
  let minPath = [];
@@ -1859,7 +1862,6 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
1859
1862
  return { distMap, preMap, seen, paths, minDist, minPath };
1860
1863
  }
1861
1864
  dijkstra(src, dest = void 0, getMinDist = false, genPaths = false) {
1862
- var _a;
1863
1865
  let minDist = Number.MAX_SAFE_INTEGER;
1864
1866
  let minDest = void 0;
1865
1867
  let minPath = [];
@@ -1897,8 +1899,8 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
1897
1899
  }, "getPaths");
1898
1900
  while (heap.size > 0) {
1899
1901
  const curHeapNode = heap.poll();
1900
- const dist = curHeapNode == null ? void 0 : curHeapNode.key;
1901
- const cur = curHeapNode == null ? void 0 : curHeapNode.value;
1902
+ const dist = curHeapNode?.key;
1903
+ const cur = curHeapNode?.value;
1902
1904
  if (dist !== void 0) {
1903
1905
  if (cur) {
1904
1906
  seen.add(cur);
@@ -1914,7 +1916,7 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
1914
1916
  const neighbors = this.getNeighbors(cur);
1915
1917
  for (const neighbor of neighbors) {
1916
1918
  if (!seen.has(neighbor)) {
1917
- const weight = (_a = this.getEdge(cur, neighbor)) == null ? void 0 : _a.weight;
1919
+ const weight = this.getEdge(cur, neighbor)?.weight;
1918
1920
  if (typeof weight === "number") {
1919
1921
  const distSrcToNeighbor = distMap.get(neighbor);
1920
1922
  if (distSrcToNeighbor !== void 0) {
@@ -2037,7 +2039,6 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
2037
2039
  * @remarks Time O(V^3), Space O(V^2)
2038
2040
  */
2039
2041
  floydWarshall() {
2040
- var _a;
2041
2042
  const idAndVertices = [...this._vertexMap];
2042
2043
  const n = idAndVertices.length;
2043
2044
  const costs = [];
@@ -2051,7 +2052,7 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
2051
2052
  }
2052
2053
  for (let i = 0; i < n; i++) {
2053
2054
  for (let j = 0; j < n; j++) {
2054
- costs[i][j] = ((_a = this.getEdge(idAndVertices[i][1], idAndVertices[j][1])) == null ? void 0 : _a.weight) || Number.MAX_SAFE_INTEGER;
2055
+ costs[i][j] = this.getEdge(idAndVertices[i][1], idAndVertices[j][1])?.weight || Number.MAX_SAFE_INTEGER;
2055
2056
  }
2056
2057
  }
2057
2058
  for (let k = 0; k < n; k++) {
@@ -2115,7 +2116,7 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
2115
2116
  const filtered = [];
2116
2117
  let index = 0;
2117
2118
  for (const [key, value] of this) {
2118
- if (predicate.call(thisArg, key, value, index, this)) {
2119
+ if (predicate.call(thisArg, value, key, index, this)) {
2119
2120
  filtered.push([key, value]);
2120
2121
  }
2121
2122
  index++;
@@ -2130,7 +2131,7 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
2130
2131
  const filtered = [];
2131
2132
  let index = 0;
2132
2133
  for (const [key, value] of this) {
2133
- if (predicate.call(thisArg, key, value, index, this)) {
2134
+ if (predicate.call(thisArg, value, key, index, this)) {
2134
2135
  filtered.push([key, value]);
2135
2136
  }
2136
2137
  index++;
@@ -2141,7 +2142,7 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
2141
2142
  const mapped = [];
2142
2143
  let index = 0;
2143
2144
  for (const [key, value] of this) {
2144
- mapped.push(callback.call(thisArg, key, value, index, this));
2145
+ mapped.push(callback.call(thisArg, value, key, index, this));
2145
2146
  index++;
2146
2147
  }
2147
2148
  return mapped;
@@ -2194,7 +2195,7 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
2194
2195
  _createInstance(_options) {
2195
2196
  const Ctor = this.constructor;
2196
2197
  const instance = new Ctor();
2197
- const graph = _options == null ? void 0 : _options.graph;
2198
+ const graph = _options?.graph;
2198
2199
  if (graph) instance._options = { ...instance._options, ...graph };
2199
2200
  else instance._options = { ...instance._options, ...this._options };
2200
2201
  return instance;
@@ -2273,29 +2274,32 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
2273
2274
  return vertexOrKey instanceof AbstractVertex ? vertexOrKey.key : vertexOrKey;
2274
2275
  }
2275
2276
  };
2276
- __name(_AbstractGraph, "AbstractGraph");
2277
- var AbstractGraph = _AbstractGraph;
2278
2277
 
2279
2278
  // src/data-structures/graph/directed-graph.ts
2280
- var _DirectedVertex = class _DirectedVertex extends AbstractVertex {
2279
+ var DirectedVertex = class extends AbstractVertex {
2280
+ static {
2281
+ __name(this, "DirectedVertex");
2282
+ }
2281
2283
  constructor(key, value) {
2282
2284
  super(key, value);
2283
2285
  }
2284
2286
  };
2285
- __name(_DirectedVertex, "DirectedVertex");
2286
- var DirectedVertex = _DirectedVertex;
2287
- var _DirectedEdge = class _DirectedEdge extends AbstractEdge {
2287
+ var DirectedEdge = class extends AbstractEdge {
2288
+ static {
2289
+ __name(this, "DirectedEdge");
2290
+ }
2291
+ src;
2292
+ dest;
2288
2293
  constructor(src, dest, weight, value) {
2289
2294
  super(weight, value);
2290
- __publicField(this, "src");
2291
- __publicField(this, "dest");
2292
2295
  this.src = src;
2293
2296
  this.dest = dest;
2294
2297
  }
2295
2298
  };
2296
- __name(_DirectedEdge, "DirectedEdge");
2297
- var DirectedEdge = _DirectedEdge;
2298
- var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
2299
+ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
2300
+ static {
2301
+ __name(this, "DirectedGraph");
2302
+ }
2299
2303
  /**
2300
2304
  * Construct a directed graph with runtime defaults.
2301
2305
  * @param options - `GraphOptions<V>` (e.g. `vertexValueInitializer`, `defaultEdgeWeight`).
@@ -2303,15 +2307,15 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
2303
2307
  */
2304
2308
  constructor(options) {
2305
2309
  super(options);
2306
- __publicField(this, "_outEdgeMap", /* @__PURE__ */ new Map());
2307
- __publicField(this, "_inEdgeMap", /* @__PURE__ */ new Map());
2308
2310
  }
2311
+ _outEdgeMap = /* @__PURE__ */ new Map();
2309
2312
  get outEdgeMap() {
2310
2313
  return this._outEdgeMap;
2311
2314
  }
2312
2315
  set outEdgeMap(v) {
2313
2316
  this._outEdgeMap = v;
2314
2317
  }
2318
+ _inEdgeMap = /* @__PURE__ */ new Map();
2315
2319
  get inEdgeMap() {
2316
2320
  return this._inEdgeMap;
2317
2321
  }
@@ -2364,8 +2368,7 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
2364
2368
  * @remarks Time O(1), Space O(1)
2365
2369
  */
2366
2370
  createEdge(src, dest, weight, value) {
2367
- var _a;
2368
- return new DirectedEdge(src, dest, (_a = weight != null ? weight : this.options.defaultEdgeWeight) != null ? _a : 1, value);
2371
+ return new DirectedEdge(src, dest, weight ?? this.options.defaultEdgeWeight ?? 1, value);
2369
2372
  }
2370
2373
  /**
2371
2374
  * Get the unique edge from `src` to `dest`, if present.
@@ -2436,7 +2439,7 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
2436
2439
  if (src && dest) {
2437
2440
  const srcOutEdges = this._outEdgeMap.get(src);
2438
2441
  if (srcOutEdges && srcOutEdges.length > 0) {
2439
- arrayRemove(srcOutEdges, (edge) => edge.src === src.key && edge.dest === (dest == null ? void 0 : dest.key));
2442
+ arrayRemove(srcOutEdges, (edge) => edge.src === src.key && edge.dest === dest?.key);
2440
2443
  }
2441
2444
  const destInEdges = this._inEdgeMap.get(dest);
2442
2445
  if (destInEdges && destInEdges.length > 0) {
@@ -2558,7 +2561,7 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
2558
2561
  * @remarks Time O(V + E), Space O(V)
2559
2562
  */
2560
2563
  topologicalSort(propertyName) {
2561
- propertyName = propertyName != null ? propertyName : "key";
2564
+ propertyName = propertyName ?? "key";
2562
2565
  const statusMap = /* @__PURE__ */ new Map();
2563
2566
  for (const entry of this.vertexMap) {
2564
2567
  statusMap.set(entry[1], 0);
@@ -2751,8 +2754,6 @@ var _DirectedGraph = class _DirectedGraph extends AbstractGraph {
2751
2754
  }
2752
2755
  }
2753
2756
  };
2754
- __name(_DirectedGraph, "DirectedGraph");
2755
- var DirectedGraph = _DirectedGraph;
2756
2757
 
2757
2758
  // src/common/index.ts
2758
2759
  var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
@@ -2760,7 +2761,7 @@ var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
2760
2761
  DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
2761
2762
  return DFSOperation2;
2762
2763
  })(DFSOperation || {});
2763
- var _Range = class _Range {
2764
+ var Range = class {
2764
2765
  constructor(low, high, includeLow = true, includeHigh = true) {
2765
2766
  this.low = low;
2766
2767
  this.high = high;
@@ -2769,6 +2770,9 @@ var _Range = class _Range {
2769
2770
  if (!(isComparable(low) && isComparable(high))) throw new RangeError("low or high is not comparable");
2770
2771
  if (low > high) throw new RangeError("low must be less than or equal to high");
2771
2772
  }
2773
+ static {
2774
+ __name(this, "Range");
2775
+ }
2772
2776
  // Determine whether a key is within the range
2773
2777
  isInRange(key, comparator) {
2774
2778
  const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
@@ -2776,8 +2780,6 @@ var _Range = class _Range {
2776
2780
  return lowCheck && highCheck;
2777
2781
  }
2778
2782
  };
2779
- __name(_Range, "Range");
2780
- var Range = _Range;
2781
2783
  /**
2782
2784
  * data-structure-typed
2783
2785
  *