graph-typed 2.4.3 → 2.4.4
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 +6 -14
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +6 -14
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +6 -14
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +6 -14
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/data-structures/base/iterable-element-base.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +5 -5
- package/dist/types/data-structures/binary-tree/bst.d.ts +1 -1
- package/dist/types/data-structures/graph/directed-graph.d.ts +2 -2
- package/dist/types/data-structures/graph/undirected-graph.d.ts +2 -2
- package/dist/types/data-structures/hash/hash-map.d.ts +2 -2
- package/dist/types/data-structures/heap/heap.d.ts +3 -7
- package/dist/types/types/data-structures/binary-tree/avl-tree.d.ts +1 -1
- package/dist/types/types/data-structures/binary-tree/red-black-tree.d.ts +1 -1
- package/dist/types/types/data-structures/linked-list/doubly-linked-list.d.ts +1 -1
- package/dist/types/types/data-structures/linked-list/singly-linked-list.d.ts +1 -1
- package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
- package/dist/types/types/data-structures/stack/stack.d.ts +1 -1
- package/dist/umd/graph-typed.js +6 -14
- package/dist/umd/graph-typed.js.map +1 -1
- package/dist/umd/graph-typed.min.js +1 -1
- package/dist/umd/graph-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/data-structures/base/iterable-element-base.ts +2 -2
- package/src/data-structures/binary-tree/binary-tree.ts +8 -7
- package/src/data-structures/binary-tree/bst.ts +1 -1
- package/src/data-structures/binary-tree/tree-multi-set.ts +5 -5
- package/src/data-structures/graph/abstract-graph.ts +18 -18
- package/src/data-structures/graph/directed-graph.ts +4 -4
- package/src/data-structures/graph/map-graph.ts +1 -1
- package/src/data-structures/graph/undirected-graph.ts +4 -4
- package/src/data-structures/hash/hash-map.ts +6 -4
- package/src/data-structures/heap/heap.ts +17 -14
- package/src/data-structures/linked-list/doubly-linked-list.ts +4 -4
- package/src/data-structures/linked-list/singly-linked-list.ts +15 -9
- package/src/data-structures/queue/deque.ts +1 -1
- package/src/data-structures/stack/stack.ts +1 -1
- package/src/data-structures/trie/trie.ts +10 -5
- package/src/types/data-structures/binary-tree/avl-tree.ts +1 -1
- package/src/types/data-structures/binary-tree/red-black-tree.ts +1 -1
- package/src/types/data-structures/linked-list/doubly-linked-list.ts +1 -1
- package/src/types/data-structures/linked-list/singly-linked-list.ts +1 -1
- package/src/types/data-structures/priority-queue/priority-queue.ts +1 -1
- package/src/types/data-structures/stack/stack.ts +1 -1
|
@@ -777,11 +777,6 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
777
777
|
}
|
|
778
778
|
return out;
|
|
779
779
|
}
|
|
780
|
-
/**
|
|
781
|
-
* Get the comparator used to order elements.
|
|
782
|
-
* @remarks Time O(1), Space O(1)
|
|
783
|
-
* @returns Comparator function.
|
|
784
|
-
*/
|
|
785
780
|
/**
|
|
786
781
|
* Get the comparator used to order elements.
|
|
787
782
|
* @remarks Time O(1), Space O(1)
|
|
@@ -830,8 +825,7 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
830
825
|
*/
|
|
831
826
|
_createInstance(options) {
|
|
832
827
|
const Ctor = this.constructor;
|
|
833
|
-
|
|
834
|
-
return next;
|
|
828
|
+
return new Ctor([], { comparator: this.comparator, toElementFn: this.toElementFn, ...options != null ? options : {} });
|
|
835
829
|
}
|
|
836
830
|
/**
|
|
837
831
|
* (Protected) Create a like-kind instance seeded by elements.
|
|
@@ -2169,8 +2163,8 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
|
|
|
2169
2163
|
const Ctor = this.constructor;
|
|
2170
2164
|
const instance = new Ctor();
|
|
2171
2165
|
const graph = _options == null ? void 0 : _options.graph;
|
|
2172
|
-
if (graph) instance
|
|
2173
|
-
else instance
|
|
2166
|
+
if (graph) instance["_options"] = { ...instance["_options"], ...graph };
|
|
2167
|
+
else instance["_options"] = { ...instance["_options"], ...this._options };
|
|
2174
2168
|
return instance;
|
|
2175
2169
|
}
|
|
2176
2170
|
/**
|
|
@@ -2203,12 +2197,10 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
|
|
|
2203
2197
|
const [va, vb] = ends;
|
|
2204
2198
|
const ka = va.key;
|
|
2205
2199
|
const kb = vb.key;
|
|
2206
|
-
const hasA = g.hasVertex ? g.hasVertex(ka) : false;
|
|
2207
|
-
const hasB = g.hasVertex ? g.hasVertex(kb) : false;
|
|
2200
|
+
const hasA = typeof g.hasVertex === "function" ? g.hasVertex(ka) : false;
|
|
2201
|
+
const hasB = typeof g.hasVertex === "function" ? g.hasVertex(kb) : false;
|
|
2208
2202
|
if (hasA && hasB) {
|
|
2209
|
-
const
|
|
2210
|
-
const val = e.value;
|
|
2211
|
-
const newEdge = g.createEdge(ka, kb, w, val);
|
|
2203
|
+
const newEdge = g.createEdge(ka, kb, e.weight, e.value);
|
|
2212
2204
|
g._addEdge(newEdge);
|
|
2213
2205
|
}
|
|
2214
2206
|
}
|