bst-typed 2.1.1 → 2.1.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 +3413 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/esm/index.mjs +3406 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/types/data-structures/base/index.d.ts +2 -1
- package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +182 -2
- package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +135 -2
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +291 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +174 -1
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +754 -29
- package/dist/types/data-structures/binary-tree/bst.d.ts +413 -12
- package/dist/types/data-structures/binary-tree/index.d.ts +3 -2
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +208 -3
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +160 -1
- package/dist/types/data-structures/binary-tree/tree-counter.d.ts +190 -2
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +270 -2
- package/dist/types/data-structures/graph/abstract-graph.d.ts +340 -14
- package/dist/types/data-structures/graph/directed-graph.d.ts +207 -1
- package/dist/types/data-structures/graph/index.d.ts +2 -1
- package/dist/types/data-structures/graph/map-graph.d.ts +78 -1
- package/dist/types/data-structures/graph/undirected-graph.d.ts +188 -1
- package/dist/types/data-structures/hash/hash-map.d.ts +345 -19
- package/dist/types/data-structures/hash/index.d.ts +0 -1
- package/dist/types/data-structures/heap/heap.d.ts +503 -5
- package/dist/types/data-structures/heap/index.d.ts +2 -0
- package/dist/types/data-structures/heap/max-heap.d.ts +32 -1
- package/dist/types/data-structures/heap/min-heap.d.ts +33 -1
- package/dist/types/data-structures/index.d.ts +7 -7
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +769 -2
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +451 -2
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +27 -4
- package/dist/types/data-structures/matrix/index.d.ts +1 -1
- package/dist/types/data-structures/matrix/matrix.d.ts +168 -7
- package/dist/types/data-structures/matrix/navigator.d.ts +54 -13
- package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +27 -1
- package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +26 -1
- package/dist/types/data-structures/priority-queue/priority-queue.d.ts +15 -2
- package/dist/types/data-structures/queue/deque.d.ts +431 -4
- package/dist/types/data-structures/queue/queue.d.ts +308 -4
- package/dist/types/data-structures/stack/stack.d.ts +306 -2
- package/dist/types/data-structures/tree/tree.d.ts +62 -1
- package/dist/types/data-structures/trie/trie.d.ts +350 -4
- package/dist/types/index.d.ts +13 -2
- package/dist/{interfaces → types/interfaces}/binary-tree.d.ts +1 -1
- package/dist/types/types/data-structures/base/index.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
- package/dist/types/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -0
- package/dist/types/types/data-structures/binary-tree/avl-tree.d.ts +2 -0
- package/dist/types/types/data-structures/binary-tree/binary-indexed-tree.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/binary-tree.d.ts +29 -0
- package/dist/types/types/data-structures/binary-tree/bst.d.ts +12 -0
- package/dist/{data-structures → types/types/data-structures}/binary-tree/index.d.ts +2 -3
- package/dist/types/types/data-structures/binary-tree/red-black-tree.d.ts +3 -0
- package/dist/types/types/data-structures/binary-tree/segment-tree.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
- package/dist/types/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -0
- package/dist/types/types/data-structures/graph/abstract-graph.d.ts +14 -0
- package/dist/types/types/data-structures/graph/directed-graph.d.ts +1 -0
- package/dist/{data-structures → types/types/data-structures}/graph/index.d.ts +1 -2
- package/dist/types/types/data-structures/graph/map-graph.d.ts +1 -0
- package/dist/types/types/data-structures/graph/undirected-graph.d.ts +1 -0
- package/dist/types/types/data-structures/hash/hash-map.d.ts +19 -0
- package/dist/types/types/data-structures/hash/index.d.ts +2 -0
- package/dist/types/types/data-structures/heap/heap.d.ts +5 -0
- package/dist/types/types/data-structures/heap/index.d.ts +1 -0
- package/dist/types/types/data-structures/heap/max-heap.d.ts +1 -0
- package/dist/types/types/data-structures/heap/min-heap.d.ts +1 -0
- package/dist/types/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -0
- package/dist/types/types/data-structures/linked-list/singly-linked-list.d.ts +2 -0
- package/dist/types/types/data-structures/linked-list/skip-linked-list.d.ts +4 -0
- package/dist/types/types/data-structures/matrix/matrix.d.ts +7 -0
- package/dist/types/types/data-structures/matrix/navigator.d.ts +14 -0
- package/dist/types/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -0
- package/dist/types/types/data-structures/priority-queue/min-priority-queue.d.ts +1 -0
- package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +2 -0
- package/dist/types/types/data-structures/queue/deque.d.ts +4 -0
- package/dist/types/types/data-structures/queue/queue.d.ts +4 -0
- package/dist/types/types/data-structures/stack/stack.d.ts +2 -0
- package/dist/types/types/data-structures/tree/tree.d.ts +1 -0
- package/dist/types/types/data-structures/trie/trie.d.ts +4 -0
- package/dist/types/types/index.d.ts +3 -0
- package/dist/types/types/utils/index.d.ts +2 -0
- package/dist/types/types/utils/utils.d.ts +22 -0
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/utils.d.ts +209 -22
- package/dist/umd/bst-typed.js +3410 -0
- package/dist/umd/bst-typed.js.map +1 -0
- package/dist/umd/bst-typed.min.js +13 -0
- package/dist/umd/bst-typed.min.js.map +1 -0
- package/package.json +24 -5
- package/src/data-structures/binary-tree/avl-tree-counter.ts +4 -4
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +1 -1
- package/src/data-structures/binary-tree/avl-tree.ts +2 -2
- package/src/data-structures/binary-tree/binary-tree.ts +4 -4
- package/src/data-structures/binary-tree/bst.ts +1 -1
- package/src/data-structures/binary-tree/red-black-tree.ts +2 -2
- package/src/data-structures/binary-tree/tree-counter.ts +4 -4
- package/src/data-structures/binary-tree/tree-multi-map.ts +1 -1
- package/src/data-structures/heap/heap.ts +5 -5
- package/src/data-structures/linked-list/singly-linked-list.ts +2 -2
- package/src/interfaces/binary-tree.ts +1 -1
- package/tsconfig.base.json +23 -0
- package/tsconfig.json +8 -34
- package/tsconfig.test.json +8 -0
- package/tsconfig.types.json +15 -0
- package/tsup.config.js +28 -0
- package/tsup.node.config.js +37 -0
- package/dist/common/index.js +0 -28
- package/dist/constants/index.js +0 -8
- package/dist/data-structures/base/index.d.ts +0 -2
- package/dist/data-structures/base/index.js +0 -18
- package/dist/data-structures/base/iterable-element-base.js +0 -243
- package/dist/data-structures/base/iterable-entry-base.js +0 -183
- package/dist/data-structures/base/linear-base.js +0 -415
- package/dist/data-structures/binary-tree/avl-tree-counter.d.ts +0 -182
- package/dist/data-structures/binary-tree/avl-tree-counter.js +0 -374
- package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -135
- package/dist/data-structures/binary-tree/avl-tree-multi-map.js +0 -250
- package/dist/data-structures/binary-tree/avl-tree.d.ts +0 -291
- package/dist/data-structures/binary-tree/avl-tree.js +0 -611
- package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -174
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +0 -294
- package/dist/data-structures/binary-tree/binary-tree.d.ts +0 -754
- package/dist/data-structures/binary-tree/binary-tree.js +0 -1925
- package/dist/data-structures/binary-tree/bst.d.ts +0 -413
- package/dist/data-structures/binary-tree/bst.js +0 -903
- package/dist/data-structures/binary-tree/index.js +0 -26
- package/dist/data-structures/binary-tree/red-black-tree.d.ts +0 -208
- package/dist/data-structures/binary-tree/red-black-tree.js +0 -546
- package/dist/data-structures/binary-tree/segment-tree.d.ts +0 -160
- package/dist/data-structures/binary-tree/segment-tree.js +0 -297
- package/dist/data-structures/binary-tree/tree-counter.d.ts +0 -190
- package/dist/data-structures/binary-tree/tree-counter.js +0 -413
- package/dist/data-structures/binary-tree/tree-multi-map.d.ts +0 -270
- package/dist/data-structures/binary-tree/tree-multi-map.js +0 -384
- package/dist/data-structures/graph/abstract-graph.d.ts +0 -340
- package/dist/data-structures/graph/abstract-graph.js +0 -896
- package/dist/data-structures/graph/directed-graph.d.ts +0 -207
- package/dist/data-structures/graph/directed-graph.js +0 -525
- package/dist/data-structures/graph/index.js +0 -20
- package/dist/data-structures/graph/map-graph.d.ts +0 -78
- package/dist/data-structures/graph/map-graph.js +0 -107
- package/dist/data-structures/graph/undirected-graph.d.ts +0 -188
- package/dist/data-structures/graph/undirected-graph.js +0 -424
- package/dist/data-structures/hash/hash-map.d.ts +0 -345
- package/dist/data-structures/hash/hash-map.js +0 -692
- package/dist/data-structures/hash/index.d.ts +0 -1
- package/dist/data-structures/hash/index.js +0 -17
- package/dist/data-structures/heap/heap.d.ts +0 -503
- package/dist/data-structures/heap/heap.js +0 -901
- package/dist/data-structures/heap/index.d.ts +0 -3
- package/dist/data-structures/heap/index.js +0 -19
- package/dist/data-structures/heap/max-heap.d.ts +0 -32
- package/dist/data-structures/heap/max-heap.js +0 -40
- package/dist/data-structures/heap/min-heap.d.ts +0 -33
- package/dist/data-structures/heap/min-heap.js +0 -31
- package/dist/data-structures/index.js +0 -28
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +0 -769
- package/dist/data-structures/linked-list/doubly-linked-list.js +0 -1111
- package/dist/data-structures/linked-list/index.js +0 -19
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +0 -451
- package/dist/data-structures/linked-list/singly-linked-list.js +0 -850
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +0 -27
- package/dist/data-structures/linked-list/skip-linked-list.js +0 -144
- package/dist/data-structures/matrix/index.js +0 -18
- package/dist/data-structures/matrix/matrix.d.ts +0 -168
- package/dist/data-structures/matrix/matrix.js +0 -448
- package/dist/data-structures/matrix/navigator.d.ts +0 -55
- package/dist/data-structures/matrix/navigator.js +0 -111
- package/dist/data-structures/priority-queue/index.js +0 -19
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +0 -27
- package/dist/data-structures/priority-queue/max-priority-queue.js +0 -34
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +0 -26
- package/dist/data-structures/priority-queue/min-priority-queue.js +0 -24
- package/dist/data-structures/priority-queue/priority-queue.d.ts +0 -15
- package/dist/data-structures/priority-queue/priority-queue.js +0 -20
- package/dist/data-structures/queue/deque.d.ts +0 -431
- package/dist/data-structures/queue/deque.js +0 -879
- package/dist/data-structures/queue/index.js +0 -18
- package/dist/data-structures/queue/queue.d.ts +0 -308
- package/dist/data-structures/queue/queue.js +0 -473
- package/dist/data-structures/stack/index.js +0 -17
- package/dist/data-structures/stack/stack.d.ts +0 -306
- package/dist/data-structures/stack/stack.js +0 -401
- package/dist/data-structures/tree/index.js +0 -17
- package/dist/data-structures/tree/tree.d.ts +0 -62
- package/dist/data-structures/tree/tree.js +0 -107
- package/dist/data-structures/trie/index.js +0 -17
- package/dist/data-structures/trie/trie.d.ts +0 -350
- package/dist/data-structures/trie/trie.js +0 -610
- package/dist/index.d.ts +0 -14
- package/dist/index.js +0 -30
- package/dist/interfaces/binary-tree.js +0 -2
- package/dist/interfaces/doubly-linked-list.js +0 -2
- package/dist/interfaces/graph.js +0 -2
- package/dist/interfaces/heap.js +0 -2
- package/dist/interfaces/index.js +0 -24
- package/dist/interfaces/navigator.js +0 -2
- package/dist/interfaces/priority-queue.js +0 -2
- package/dist/interfaces/segment-tree.js +0 -2
- package/dist/interfaces/singly-linked-list.js +0 -2
- package/dist/types/common.js +0 -2
- package/dist/types/data-structures/base/base.js +0 -2
- package/dist/types/data-structures/base/index.js +0 -17
- package/dist/types/data-structures/binary-tree/avl-tree-counter.js +0 -2
- package/dist/types/data-structures/binary-tree/avl-tree-multi-map.js +0 -2
- package/dist/types/data-structures/binary-tree/avl-tree.js +0 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.js +0 -2
- package/dist/types/data-structures/binary-tree/binary-tree.js +0 -2
- package/dist/types/data-structures/binary-tree/bst.js +0 -2
- package/dist/types/data-structures/binary-tree/index.js +0 -25
- package/dist/types/data-structures/binary-tree/red-black-tree.js +0 -2
- package/dist/types/data-structures/binary-tree/segment-tree.js +0 -2
- package/dist/types/data-structures/binary-tree/tree-counter.js +0 -2
- package/dist/types/data-structures/binary-tree/tree-multi-map.js +0 -2
- package/dist/types/data-structures/graph/abstract-graph.js +0 -2
- package/dist/types/data-structures/graph/directed-graph.js +0 -2
- package/dist/types/data-structures/graph/index.js +0 -19
- package/dist/types/data-structures/graph/map-graph.js +0 -2
- package/dist/types/data-structures/graph/undirected-graph.js +0 -2
- package/dist/types/data-structures/hash/hash-map.js +0 -2
- package/dist/types/data-structures/hash/index.js +0 -17
- package/dist/types/data-structures/heap/heap.js +0 -2
- package/dist/types/data-structures/heap/index.js +0 -17
- package/dist/types/data-structures/heap/max-heap.js +0 -2
- package/dist/types/data-structures/heap/min-heap.js +0 -2
- package/dist/types/data-structures/index.js +0 -28
- package/dist/types/data-structures/linked-list/doubly-linked-list.js +0 -2
- package/dist/types/data-structures/linked-list/index.js +0 -19
- package/dist/types/data-structures/linked-list/singly-linked-list.js +0 -2
- package/dist/types/data-structures/linked-list/skip-linked-list.js +0 -2
- package/dist/types/data-structures/matrix/index.js +0 -18
- package/dist/types/data-structures/matrix/matrix.js +0 -2
- package/dist/types/data-structures/matrix/navigator.js +0 -2
- package/dist/types/data-structures/priority-queue/index.js +0 -19
- package/dist/types/data-structures/priority-queue/max-priority-queue.js +0 -2
- package/dist/types/data-structures/priority-queue/min-priority-queue.js +0 -2
- package/dist/types/data-structures/priority-queue/priority-queue.js +0 -2
- package/dist/types/data-structures/queue/deque.js +0 -2
- package/dist/types/data-structures/queue/index.js +0 -18
- package/dist/types/data-structures/queue/queue.js +0 -2
- package/dist/types/data-structures/stack/index.js +0 -17
- package/dist/types/data-structures/stack/stack.js +0 -2
- package/dist/types/data-structures/tree/index.js +0 -17
- package/dist/types/data-structures/tree/tree.js +0 -2
- package/dist/types/data-structures/trie/index.js +0 -17
- package/dist/types/data-structures/trie/trie.js +0 -2
- package/dist/types/index.js +0 -19
- package/dist/types/utils/index.js +0 -18
- package/dist/types/utils/utils.js +0 -2
- package/dist/types/utils/validate-type.js +0 -2
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +0 -18
- package/dist/utils/number.js +0 -24
- package/dist/utils/utils.d.ts +0 -209
- package/dist/utils/utils.js +0 -353
- package/dist/{common → types/common}/index.d.ts +0 -0
- package/dist/{constants → types/constants}/index.d.ts +0 -0
- package/dist/{data-structures → types/data-structures}/base/iterable-element-base.d.ts +0 -0
- package/dist/{data-structures → types/data-structures}/base/iterable-entry-base.d.ts +0 -0
- package/dist/{data-structures → types/data-structures}/base/linear-base.d.ts +0 -0
- package/dist/{interfaces → types/interfaces}/doubly-linked-list.d.ts +0 -0
- package/dist/{interfaces → types/interfaces}/graph.d.ts +0 -0
- package/dist/{interfaces → types/interfaces}/heap.d.ts +0 -0
- package/dist/{interfaces → types/interfaces}/index.d.ts +0 -0
- package/dist/{interfaces → types/interfaces}/navigator.d.ts +0 -0
- package/dist/{interfaces → types/interfaces}/priority-queue.d.ts +0 -0
- package/dist/{interfaces → types/interfaces}/segment-tree.d.ts +0 -0
- package/dist/{interfaces → types/interfaces}/singly-linked-list.d.ts +0 -0
- package/dist/types/{common.d.ts → types/common.d.ts} +0 -0
- package/dist/types/{data-structures → types/data-structures}/base/base.d.ts +0 -0
- package/dist/{data-structures → types/types/data-structures}/index.d.ts +7 -7
- package/dist/{data-structures → types/types/data-structures}/linked-list/index.d.ts +0 -0
- package/dist/{data-structures → types/types/data-structures}/matrix/index.d.ts +1 -1
- /package/dist/{data-structures → types/types/data-structures}/priority-queue/index.d.ts +0 -0
- /package/dist/{data-structures → types/types/data-structures}/queue/index.d.ts +0 -0
- /package/dist/{data-structures → types/types/data-structures}/stack/index.d.ts +0 -0
- /package/dist/{data-structures → types/types/data-structures}/tree/index.d.ts +0 -0
- /package/dist/{data-structures → types/types/data-structures}/trie/index.d.ts +0 -0
- /package/dist/types/{utils → types/utils}/validate-type.d.ts +0 -0
- /package/dist/{utils → types/utils}/number.d.ts +0 -0
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* data-structure-typed
|
|
4
|
-
*
|
|
5
|
-
* @author Pablo Zeng
|
|
6
|
-
* @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
|
|
7
|
-
* @license MIT License
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.MapGraph = exports.MapEdge = exports.MapVertex = void 0;
|
|
11
|
-
const directed_graph_1 = require("./directed-graph");
|
|
12
|
-
class MapVertex extends directed_graph_1.DirectedVertex {
|
|
13
|
-
constructor(key, value, lat, long) {
|
|
14
|
-
super(key, value);
|
|
15
|
-
this.lat = lat;
|
|
16
|
-
this.long = long;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.MapVertex = MapVertex;
|
|
20
|
-
class MapEdge extends directed_graph_1.DirectedEdge {
|
|
21
|
-
constructor(src, dest, weight, value) {
|
|
22
|
-
super(src, dest, weight, value);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.MapEdge = MapEdge;
|
|
26
|
-
/**
|
|
27
|
-
* Directed graph variant carrying geospatial coordinates.
|
|
28
|
-
* @template V - Vertex value type.
|
|
29
|
-
* @template E - Edge value type.
|
|
30
|
-
* @template VO - Concrete vertex class (MapVertex<V>).
|
|
31
|
-
* @template EO - Concrete edge class (MapEdge<E>).
|
|
32
|
-
* @remarks Time O(1), Space O(1)
|
|
33
|
-
* @example examples will be generated by unit test
|
|
34
|
-
*/
|
|
35
|
-
class MapGraph extends directed_graph_1.DirectedGraph {
|
|
36
|
-
/**
|
|
37
|
-
* Construct a MapGraph.
|
|
38
|
-
* @param originCoord - Origin coordinate `[lat, long]` used as default.
|
|
39
|
-
* @param bottomRight - Optional bottom-right coordinate for bounding boxes.
|
|
40
|
-
* @remarks Time O(1), Space O(1)
|
|
41
|
-
*/
|
|
42
|
-
constructor(originCoord, bottomRight) {
|
|
43
|
-
super();
|
|
44
|
-
this._originCoord = [0, 0];
|
|
45
|
-
this._originCoord = originCoord;
|
|
46
|
-
this._bottomRight = bottomRight;
|
|
47
|
-
}
|
|
48
|
-
get originCoord() {
|
|
49
|
-
return this._originCoord;
|
|
50
|
-
}
|
|
51
|
-
get bottomRight() {
|
|
52
|
-
return this._bottomRight;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Create a map vertex with optional coordinates.
|
|
56
|
-
* @param key - Vertex identifier.
|
|
57
|
-
* @param value - Optional payload.
|
|
58
|
-
* @param lat - Latitude (defaults to `originCoord[0]`).
|
|
59
|
-
* @param long - Longitude (defaults to `originCoord[1]`).
|
|
60
|
-
* @returns MapVertex instance.
|
|
61
|
-
* @remarks Time O(1), Space O(1)
|
|
62
|
-
*/
|
|
63
|
-
createVertex(key, value, lat = this.originCoord[0], long = this.originCoord[1]) {
|
|
64
|
-
return new MapVertex(key, value, lat, long);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Create a map edge (directed) with optional weight/value.
|
|
68
|
-
* @param src - Source key.
|
|
69
|
-
* @param dest - Destination key.
|
|
70
|
-
* @param weight - Edge weight.
|
|
71
|
-
* @param value - Edge payload.
|
|
72
|
-
* @returns MapEdge instance.
|
|
73
|
-
* @remarks Time O(1), Space O(1)
|
|
74
|
-
*/
|
|
75
|
-
createEdge(src, dest, weight, value) {
|
|
76
|
-
return new MapEdge(src, dest, weight, value);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Deep clone as the same concrete class.
|
|
80
|
-
* @returns A new graph of the same concrete class (`this` type).
|
|
81
|
-
* @remarks Time O(V + E), Space O(V + E)
|
|
82
|
-
*/
|
|
83
|
-
clone() {
|
|
84
|
-
return super.clone();
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Include `originCoord` and `bottomRight` so `clone()/filter()` preserve geospatial settings.
|
|
88
|
-
* @returns Options bag extending super snapshot.
|
|
89
|
-
* @remarks Time O(1), Space O(1)
|
|
90
|
-
*/
|
|
91
|
-
_snapshotOptions() {
|
|
92
|
-
return Object.assign(Object.assign({}, super._snapshotOptions()), { originCoord: this.originCoord, bottomRight: this.bottomRight });
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Re-create a same-species MapGraph instance from snapshot options.
|
|
96
|
-
* @param options - Snapshot options providing `originCoord`/`bottomRight`.
|
|
97
|
-
* @returns Empty MapGraph instance of `this` type.
|
|
98
|
-
* @remarks Time O(1), Space O(1)
|
|
99
|
-
*/
|
|
100
|
-
_createInstance(options) {
|
|
101
|
-
const { originCoord, bottomRight } = (options || {});
|
|
102
|
-
const oc = (originCoord !== null && originCoord !== void 0 ? originCoord : this.originCoord);
|
|
103
|
-
const br = (bottomRight !== null && bottomRight !== void 0 ? bottomRight : this.bottomRight);
|
|
104
|
-
return new MapGraph(oc, br);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
exports.MapGraph = MapGraph;
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* data-structure-typed
|
|
3
|
-
*
|
|
4
|
-
* @author Pablo Zeng
|
|
5
|
-
* @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
|
|
6
|
-
* @license MIT License
|
|
7
|
-
*/
|
|
8
|
-
import type { GraphOptions, VertexKey } from '../../types';
|
|
9
|
-
import { IGraph } from '../../interfaces';
|
|
10
|
-
import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';
|
|
11
|
-
export declare class UndirectedVertex<V = any> extends AbstractVertex<V> {
|
|
12
|
-
constructor(key: VertexKey, value?: V);
|
|
13
|
-
}
|
|
14
|
-
export declare class UndirectedEdge<E = number> extends AbstractEdge<E> {
|
|
15
|
-
endpoints: [VertexKey, VertexKey];
|
|
16
|
-
constructor(v1: VertexKey, v2: VertexKey, weight?: number, value?: E);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Undirected graph implementation.
|
|
20
|
-
* @template V - Vertex value type.
|
|
21
|
-
* @template E - Edge value type.
|
|
22
|
-
* @template VO - Concrete vertex class (extends AbstractVertex<V>).
|
|
23
|
-
* @template EO - Concrete edge class (extends AbstractEdge<E>).
|
|
24
|
-
* @remarks Time O(1), Space O(1)
|
|
25
|
-
* @example examples will be generated by unit test
|
|
26
|
-
*/
|
|
27
|
-
export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVertex<V> = UndirectedVertex<V>, EO extends UndirectedEdge<E> = UndirectedEdge<E>> extends AbstractGraph<V, E, VO, EO> implements IGraph<V, E, VO, EO> {
|
|
28
|
-
/**
|
|
29
|
-
* Construct an undirected graph with runtime defaults.
|
|
30
|
-
* @param options - `GraphOptions<V>` (e.g. `vertexValueInitializer`, `defaultEdgeWeight`).
|
|
31
|
-
* @remarks Time O(1), Space O(1)
|
|
32
|
-
*/
|
|
33
|
-
constructor(options?: Partial<GraphOptions<V>>);
|
|
34
|
-
protected _edgeMap: Map<VO, EO[]>;
|
|
35
|
-
get edgeMap(): Map<VO, EO[]>;
|
|
36
|
-
set edgeMap(v: Map<VO, EO[]>);
|
|
37
|
-
/**
|
|
38
|
-
* Construct an undirected graph from keys with value initializer `v => v`.
|
|
39
|
-
* @template K - Vertex key type.
|
|
40
|
-
* @param keys - Iterable of vertex keys.
|
|
41
|
-
* @returns UndirectedGraph with all keys added.
|
|
42
|
-
* @remarks Time O(V), Space O(V)
|
|
43
|
-
*/
|
|
44
|
-
static fromKeys<K extends VertexKey>(keys: Iterable<K>): UndirectedGraph<K, any, UndirectedVertex<K>, UndirectedEdge<any>>;
|
|
45
|
-
/**
|
|
46
|
-
* Construct an undirected graph from `[key, value]` entries.
|
|
47
|
-
* @template V - Vertex value type.
|
|
48
|
-
* @param entries - Iterable of `[key, value]` pairs.
|
|
49
|
-
* @returns UndirectedGraph with all vertices added.
|
|
50
|
-
* @remarks Time O(V), Space O(V)
|
|
51
|
-
*/
|
|
52
|
-
static fromEntries<V>(entries: Iterable<[VertexKey, V]>): UndirectedGraph<V, any, UndirectedVertex<V>, UndirectedEdge<any>>;
|
|
53
|
-
/**
|
|
54
|
-
* Create an undirected vertex instance. Does not insert into the graph.
|
|
55
|
-
* @param key - Vertex identifier.
|
|
56
|
-
* @param value - Optional payload.
|
|
57
|
-
* @returns Concrete vertex instance.
|
|
58
|
-
* @remarks Time O(1), Space O(1)
|
|
59
|
-
*/
|
|
60
|
-
createVertex(key: VertexKey, value?: VO['value']): VO;
|
|
61
|
-
/**
|
|
62
|
-
* Create an undirected edge instance. Does not insert into the graph.
|
|
63
|
-
* @param v1 - One endpoint key.
|
|
64
|
-
* @param v2 - The other endpoint key.
|
|
65
|
-
* @param weight - Edge weight; defaults to `defaultEdgeWeight`.
|
|
66
|
-
* @param value - Edge payload.
|
|
67
|
-
* @returns Concrete edge instance.
|
|
68
|
-
* @remarks Time O(1), Space O(1)
|
|
69
|
-
*/
|
|
70
|
-
createEdge(v1: VertexKey, v2: VertexKey, weight?: number, value?: EO['value']): EO;
|
|
71
|
-
/**
|
|
72
|
-
* Get an undirected edge between two vertices, if present.
|
|
73
|
-
* @param v1 - One vertex or key.
|
|
74
|
-
* @param v2 - The other vertex or key.
|
|
75
|
-
* @returns Edge instance or `undefined`.
|
|
76
|
-
* @remarks Time O(1) avg, Space O(1)
|
|
77
|
-
*/
|
|
78
|
-
getEdge(v1: VO | VertexKey | undefined, v2: VO | VertexKey | undefined): EO | undefined;
|
|
79
|
-
/**
|
|
80
|
-
* Delete a single undirected edge between two vertices.
|
|
81
|
-
* @param v1 - One vertex or key.
|
|
82
|
-
* @param v2 - The other vertex or key.
|
|
83
|
-
* @returns Removed edge or `undefined`.
|
|
84
|
-
* @remarks Time O(1) avg, Space O(1)
|
|
85
|
-
*/
|
|
86
|
-
deleteEdgeBetween(v1: VO | VertexKey, v2: VO | VertexKey): EO | undefined;
|
|
87
|
-
/**
|
|
88
|
-
* Delete an edge by instance or by a pair of keys.
|
|
89
|
-
* @param edgeOrOneSideVertexKey - Edge instance or one endpoint vertex/key.
|
|
90
|
-
* @param otherSideVertexKey - Required second endpoint when deleting by pair.
|
|
91
|
-
* @returns Removed edge or `undefined`.
|
|
92
|
-
* @remarks Time O(1) avg, Space O(1)
|
|
93
|
-
*/
|
|
94
|
-
deleteEdge(edgeOrOneSideVertexKey: EO | VertexKey, otherSideVertexKey?: VertexKey): EO | undefined;
|
|
95
|
-
/**
|
|
96
|
-
* Delete a vertex and remove it from all neighbor lists.
|
|
97
|
-
* @param vertexOrKey - Vertex or key.
|
|
98
|
-
* @returns `true` if removed; otherwise `false`.
|
|
99
|
-
* @remarks Time O(deg), Space O(1)
|
|
100
|
-
*/
|
|
101
|
-
deleteVertex(vertexOrKey: VO | VertexKey): boolean;
|
|
102
|
-
/**
|
|
103
|
-
* Degree of a vertex (# of incident undirected edges).
|
|
104
|
-
* @param vertexOrKey - Vertex or key.
|
|
105
|
-
* @returns Non-negative integer.
|
|
106
|
-
* @remarks Time O(1) avg, Space O(1)
|
|
107
|
-
*/
|
|
108
|
-
degreeOf(vertexOrKey: VertexKey | VO): number;
|
|
109
|
-
/**
|
|
110
|
-
* Incident undirected edges of a vertex.
|
|
111
|
-
* @param vertexOrKey - Vertex or key.
|
|
112
|
-
* @returns Array of incident edges.
|
|
113
|
-
* @remarks Time O(deg), Space O(deg)
|
|
114
|
-
*/
|
|
115
|
-
edgesOf(vertexOrKey: VertexKey | VO): EO[];
|
|
116
|
-
/**
|
|
117
|
-
* Unique set of undirected edges across endpoints.
|
|
118
|
-
* @returns Array of edges.
|
|
119
|
-
* @remarks Time O(E), Space O(E)
|
|
120
|
-
*/
|
|
121
|
-
edgeSet(): EO[];
|
|
122
|
-
getNeighbors(vertexOrKey: VO | VertexKey): VO[];
|
|
123
|
-
/**
|
|
124
|
-
* Resolve an edge's two endpoints to vertex instances.
|
|
125
|
-
* @param edge - Edge instance.
|
|
126
|
-
* @returns `[v1, v2]` or `undefined` if either endpoint is missing.
|
|
127
|
-
* @remarks Time O(1), Space O(1)
|
|
128
|
-
*/
|
|
129
|
-
getEndsOfEdge(edge: EO): [VO, VO] | undefined;
|
|
130
|
-
/**
|
|
131
|
-
* Whether the graph has no vertices and no edges.
|
|
132
|
-
* @remarks Time O(1), Space O(1)
|
|
133
|
-
*/
|
|
134
|
-
isEmpty(): boolean;
|
|
135
|
-
/**
|
|
136
|
-
* Remove all vertices and edges.
|
|
137
|
-
* @remarks Time O(V + E), Space O(1)
|
|
138
|
-
*/
|
|
139
|
-
clear(): void;
|
|
140
|
-
/**
|
|
141
|
-
* Deep clone as the same concrete class.
|
|
142
|
-
* @returns A new graph of the same concrete class (`this` type).
|
|
143
|
-
* @remarks Time O(V + E), Space O(V + E)
|
|
144
|
-
*/
|
|
145
|
-
clone(): this;
|
|
146
|
-
/**
|
|
147
|
-
* Tarjan-based bridge and articulation point detection.
|
|
148
|
-
* @returns `{ dfnMap, lowMap, bridges, cutVertices }`.
|
|
149
|
-
* @remarks Time O(V + E), Space O(V + E)
|
|
150
|
-
*/
|
|
151
|
-
tarjan(): {
|
|
152
|
-
dfnMap: Map<VO, number>;
|
|
153
|
-
lowMap: Map<VO, number>;
|
|
154
|
-
bridges: EO[];
|
|
155
|
-
cutVertices: VO[];
|
|
156
|
-
};
|
|
157
|
-
/**
|
|
158
|
-
* Get bridges discovered by `tarjan()`.
|
|
159
|
-
* @returns Array of edges that are bridges.
|
|
160
|
-
* @remarks Time O(B), Space O(1)
|
|
161
|
-
*/
|
|
162
|
-
getBridges(): EO[];
|
|
163
|
-
/**
|
|
164
|
-
* Get articulation points discovered by `tarjan()`.
|
|
165
|
-
* @returns Array of cut vertices.
|
|
166
|
-
* @remarks Time O(C), Space O(1)
|
|
167
|
-
*/
|
|
168
|
-
getCutVertices(): VO[];
|
|
169
|
-
/**
|
|
170
|
-
* DFN index map computed by `tarjan()`.
|
|
171
|
-
* @returns Map from vertex to DFN index.
|
|
172
|
-
* @remarks Time O(V), Space O(V)
|
|
173
|
-
*/
|
|
174
|
-
getDFNMap(): Map<VO, number>;
|
|
175
|
-
/**
|
|
176
|
-
* LOW link map computed by `tarjan()`.
|
|
177
|
-
* @returns Map from vertex to LOW value.
|
|
178
|
-
* @remarks Time O(V), Space O(V)
|
|
179
|
-
*/
|
|
180
|
-
getLowMap(): Map<VO, number>;
|
|
181
|
-
/**
|
|
182
|
-
* Internal hook to attach an undirected edge into adjacency maps.
|
|
183
|
-
* @param edge - Edge instance.
|
|
184
|
-
* @returns `true` if both endpoints exist; otherwise `false`.
|
|
185
|
-
* @remarks Time O(1) avg, Space O(1)
|
|
186
|
-
*/
|
|
187
|
-
protected _addEdge(edge: EO): boolean;
|
|
188
|
-
}
|