tree-multimap-typed 2.1.1 → 2.2.0

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 (288) hide show
  1. package/dist/cjs/index.cjs +4298 -0
  2. package/dist/cjs/index.cjs.map +1 -0
  3. package/dist/cjs-legacy/index.cjs +4300 -0
  4. package/dist/cjs-legacy/index.cjs.map +1 -0
  5. package/dist/esm/index.mjs +4287 -0
  6. package/dist/esm/index.mjs.map +1 -0
  7. package/dist/esm-legacy/index.mjs +4289 -0
  8. package/dist/esm-legacy/index.mjs.map +1 -0
  9. package/dist/types/data-structures/base/index.d.ts +2 -1
  10. package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +236 -2
  11. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +197 -2
  12. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +345 -2
  13. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +174 -1
  14. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +754 -29
  15. package/dist/types/data-structures/binary-tree/bst.d.ts +467 -12
  16. package/dist/types/data-structures/binary-tree/index.d.ts +3 -2
  17. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +262 -3
  18. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +160 -1
  19. package/dist/types/data-structures/binary-tree/tree-counter.d.ts +244 -2
  20. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +332 -2
  21. package/dist/types/data-structures/graph/abstract-graph.d.ts +340 -14
  22. package/dist/types/data-structures/graph/directed-graph.d.ts +207 -1
  23. package/dist/types/data-structures/graph/index.d.ts +2 -1
  24. package/dist/types/data-structures/graph/map-graph.d.ts +78 -1
  25. package/dist/types/data-structures/graph/undirected-graph.d.ts +188 -1
  26. package/dist/types/data-structures/hash/hash-map.d.ts +345 -19
  27. package/dist/types/data-structures/hash/index.d.ts +0 -1
  28. package/dist/types/data-structures/heap/heap.d.ts +503 -5
  29. package/dist/types/data-structures/heap/index.d.ts +2 -0
  30. package/dist/types/data-structures/heap/max-heap.d.ts +32 -1
  31. package/dist/types/data-structures/heap/min-heap.d.ts +33 -1
  32. package/dist/types/data-structures/index.d.ts +7 -7
  33. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +769 -2
  34. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +451 -2
  35. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +27 -4
  36. package/dist/types/data-structures/matrix/index.d.ts +1 -1
  37. package/dist/types/data-structures/matrix/matrix.d.ts +168 -7
  38. package/dist/types/data-structures/matrix/navigator.d.ts +54 -13
  39. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +27 -1
  40. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +26 -1
  41. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +15 -2
  42. package/dist/types/data-structures/queue/deque.d.ts +431 -4
  43. package/dist/types/data-structures/queue/queue.d.ts +308 -4
  44. package/dist/types/data-structures/stack/stack.d.ts +306 -2
  45. package/dist/types/data-structures/tree/tree.d.ts +62 -1
  46. package/dist/types/data-structures/trie/trie.d.ts +350 -4
  47. package/dist/types/index.d.ts +17 -2
  48. package/dist/{interfaces → types/interfaces}/binary-tree.d.ts +1 -1
  49. package/dist/types/types/data-structures/base/index.d.ts +1 -0
  50. package/dist/types/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
  51. package/dist/types/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -0
  52. package/dist/types/types/data-structures/binary-tree/avl-tree.d.ts +2 -0
  53. package/dist/types/types/data-structures/binary-tree/binary-indexed-tree.d.ts +1 -0
  54. package/dist/types/types/data-structures/binary-tree/binary-tree.d.ts +29 -0
  55. package/dist/types/types/data-structures/binary-tree/bst.d.ts +12 -0
  56. package/dist/{data-structures → types/types/data-structures}/binary-tree/index.d.ts +2 -3
  57. package/dist/types/types/data-structures/binary-tree/red-black-tree.d.ts +3 -0
  58. package/dist/types/types/data-structures/binary-tree/segment-tree.d.ts +1 -0
  59. package/dist/types/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
  60. package/dist/types/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -0
  61. package/dist/types/types/data-structures/graph/abstract-graph.d.ts +14 -0
  62. package/dist/types/types/data-structures/graph/directed-graph.d.ts +1 -0
  63. package/dist/{data-structures → types/types/data-structures}/graph/index.d.ts +1 -2
  64. package/dist/types/types/data-structures/graph/map-graph.d.ts +1 -0
  65. package/dist/types/types/data-structures/graph/undirected-graph.d.ts +1 -0
  66. package/dist/types/types/data-structures/hash/hash-map.d.ts +19 -0
  67. package/dist/types/types/data-structures/hash/index.d.ts +2 -0
  68. package/dist/types/types/data-structures/heap/heap.d.ts +5 -0
  69. package/dist/types/types/data-structures/heap/index.d.ts +1 -0
  70. package/dist/types/types/data-structures/heap/max-heap.d.ts +1 -0
  71. package/dist/types/types/data-structures/heap/min-heap.d.ts +1 -0
  72. package/dist/types/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -0
  73. package/dist/types/types/data-structures/linked-list/singly-linked-list.d.ts +2 -0
  74. package/dist/types/types/data-structures/linked-list/skip-linked-list.d.ts +4 -0
  75. package/dist/types/types/data-structures/matrix/matrix.d.ts +7 -0
  76. package/dist/types/types/data-structures/matrix/navigator.d.ts +14 -0
  77. package/dist/types/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -0
  78. package/dist/types/types/data-structures/priority-queue/min-priority-queue.d.ts +1 -0
  79. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +2 -0
  80. package/dist/types/types/data-structures/queue/deque.d.ts +4 -0
  81. package/dist/types/types/data-structures/queue/queue.d.ts +4 -0
  82. package/dist/types/types/data-structures/stack/stack.d.ts +2 -0
  83. package/dist/types/types/data-structures/tree/tree.d.ts +1 -0
  84. package/dist/types/types/data-structures/trie/trie.d.ts +4 -0
  85. package/dist/types/types/index.d.ts +3 -0
  86. package/dist/types/types/utils/index.d.ts +2 -0
  87. package/dist/types/types/utils/utils.d.ts +22 -0
  88. package/dist/types/utils/index.d.ts +1 -1
  89. package/dist/types/utils/utils.d.ts +209 -22
  90. package/dist/umd/tree-multimap-typed.js +4289 -0
  91. package/dist/umd/tree-multimap-typed.js.map +1 -0
  92. package/dist/umd/tree-multimap-typed.min.js +13 -0
  93. package/dist/umd/tree-multimap-typed.min.js.map +1 -0
  94. package/package.json +43 -5
  95. package/src/data-structures/binary-tree/avl-tree-counter.ts +106 -15
  96. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +116 -12
  97. package/src/data-structures/binary-tree/avl-tree.ts +107 -16
  98. package/src/data-structures/binary-tree/binary-tree.ts +4 -4
  99. package/src/data-structures/binary-tree/bst.ts +103 -12
  100. package/src/data-structures/binary-tree/red-black-tree.ts +110 -20
  101. package/src/data-structures/binary-tree/tree-counter.ts +105 -14
  102. package/src/data-structures/binary-tree/tree-multi-map.ts +123 -12
  103. package/src/data-structures/graph/abstract-graph.ts +5 -5
  104. package/src/data-structures/graph/directed-graph.ts +5 -5
  105. package/src/data-structures/graph/undirected-graph.ts +5 -5
  106. package/src/data-structures/heap/heap.ts +5 -5
  107. package/src/data-structures/linked-list/singly-linked-list.ts +2 -2
  108. package/src/interfaces/binary-tree.ts +1 -1
  109. package/tsconfig.base.json +23 -0
  110. package/tsconfig.json +8 -34
  111. package/tsconfig.test.json +8 -0
  112. package/tsconfig.types.json +15 -0
  113. package/tsup.config.js +28 -0
  114. package/tsup.node.config.js +71 -0
  115. package/dist/common/index.js +0 -28
  116. package/dist/constants/index.js +0 -8
  117. package/dist/data-structures/base/index.d.ts +0 -2
  118. package/dist/data-structures/base/index.js +0 -18
  119. package/dist/data-structures/base/iterable-element-base.js +0 -243
  120. package/dist/data-structures/base/iterable-entry-base.js +0 -183
  121. package/dist/data-structures/base/linear-base.js +0 -415
  122. package/dist/data-structures/binary-tree/avl-tree-counter.d.ts +0 -182
  123. package/dist/data-structures/binary-tree/avl-tree-counter.js +0 -374
  124. package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -135
  125. package/dist/data-structures/binary-tree/avl-tree-multi-map.js +0 -250
  126. package/dist/data-structures/binary-tree/avl-tree.d.ts +0 -291
  127. package/dist/data-structures/binary-tree/avl-tree.js +0 -611
  128. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -174
  129. package/dist/data-structures/binary-tree/binary-indexed-tree.js +0 -294
  130. package/dist/data-structures/binary-tree/binary-tree.d.ts +0 -754
  131. package/dist/data-structures/binary-tree/binary-tree.js +0 -1925
  132. package/dist/data-structures/binary-tree/bst.d.ts +0 -413
  133. package/dist/data-structures/binary-tree/bst.js +0 -903
  134. package/dist/data-structures/binary-tree/index.js +0 -26
  135. package/dist/data-structures/binary-tree/red-black-tree.d.ts +0 -208
  136. package/dist/data-structures/binary-tree/red-black-tree.js +0 -546
  137. package/dist/data-structures/binary-tree/segment-tree.d.ts +0 -160
  138. package/dist/data-structures/binary-tree/segment-tree.js +0 -297
  139. package/dist/data-structures/binary-tree/tree-counter.d.ts +0 -190
  140. package/dist/data-structures/binary-tree/tree-counter.js +0 -413
  141. package/dist/data-structures/binary-tree/tree-multi-map.d.ts +0 -270
  142. package/dist/data-structures/binary-tree/tree-multi-map.js +0 -384
  143. package/dist/data-structures/graph/abstract-graph.d.ts +0 -340
  144. package/dist/data-structures/graph/abstract-graph.js +0 -896
  145. package/dist/data-structures/graph/directed-graph.d.ts +0 -207
  146. package/dist/data-structures/graph/directed-graph.js +0 -525
  147. package/dist/data-structures/graph/index.js +0 -20
  148. package/dist/data-structures/graph/map-graph.d.ts +0 -78
  149. package/dist/data-structures/graph/map-graph.js +0 -107
  150. package/dist/data-structures/graph/undirected-graph.d.ts +0 -188
  151. package/dist/data-structures/graph/undirected-graph.js +0 -424
  152. package/dist/data-structures/hash/hash-map.d.ts +0 -345
  153. package/dist/data-structures/hash/hash-map.js +0 -692
  154. package/dist/data-structures/hash/index.d.ts +0 -1
  155. package/dist/data-structures/hash/index.js +0 -17
  156. package/dist/data-structures/heap/heap.d.ts +0 -503
  157. package/dist/data-structures/heap/heap.js +0 -901
  158. package/dist/data-structures/heap/index.d.ts +0 -3
  159. package/dist/data-structures/heap/index.js +0 -19
  160. package/dist/data-structures/heap/max-heap.d.ts +0 -32
  161. package/dist/data-structures/heap/max-heap.js +0 -40
  162. package/dist/data-structures/heap/min-heap.d.ts +0 -33
  163. package/dist/data-structures/heap/min-heap.js +0 -31
  164. package/dist/data-structures/index.js +0 -28
  165. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +0 -769
  166. package/dist/data-structures/linked-list/doubly-linked-list.js +0 -1111
  167. package/dist/data-structures/linked-list/index.js +0 -19
  168. package/dist/data-structures/linked-list/singly-linked-list.d.ts +0 -451
  169. package/dist/data-structures/linked-list/singly-linked-list.js +0 -850
  170. package/dist/data-structures/linked-list/skip-linked-list.d.ts +0 -27
  171. package/dist/data-structures/linked-list/skip-linked-list.js +0 -144
  172. package/dist/data-structures/matrix/index.js +0 -18
  173. package/dist/data-structures/matrix/matrix.d.ts +0 -168
  174. package/dist/data-structures/matrix/matrix.js +0 -448
  175. package/dist/data-structures/matrix/navigator.d.ts +0 -55
  176. package/dist/data-structures/matrix/navigator.js +0 -111
  177. package/dist/data-structures/priority-queue/index.js +0 -19
  178. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +0 -27
  179. package/dist/data-structures/priority-queue/max-priority-queue.js +0 -34
  180. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +0 -26
  181. package/dist/data-structures/priority-queue/min-priority-queue.js +0 -24
  182. package/dist/data-structures/priority-queue/priority-queue.d.ts +0 -15
  183. package/dist/data-structures/priority-queue/priority-queue.js +0 -20
  184. package/dist/data-structures/queue/deque.d.ts +0 -431
  185. package/dist/data-structures/queue/deque.js +0 -879
  186. package/dist/data-structures/queue/index.js +0 -18
  187. package/dist/data-structures/queue/queue.d.ts +0 -308
  188. package/dist/data-structures/queue/queue.js +0 -473
  189. package/dist/data-structures/stack/index.js +0 -17
  190. package/dist/data-structures/stack/stack.d.ts +0 -306
  191. package/dist/data-structures/stack/stack.js +0 -401
  192. package/dist/data-structures/tree/index.js +0 -17
  193. package/dist/data-structures/tree/tree.d.ts +0 -62
  194. package/dist/data-structures/tree/tree.js +0 -107
  195. package/dist/data-structures/trie/index.js +0 -17
  196. package/dist/data-structures/trie/trie.d.ts +0 -350
  197. package/dist/data-structures/trie/trie.js +0 -610
  198. package/dist/index.d.ts +0 -18
  199. package/dist/index.js +0 -34
  200. package/dist/interfaces/binary-tree.js +0 -2
  201. package/dist/interfaces/doubly-linked-list.js +0 -2
  202. package/dist/interfaces/graph.js +0 -2
  203. package/dist/interfaces/heap.js +0 -2
  204. package/dist/interfaces/index.js +0 -24
  205. package/dist/interfaces/navigator.js +0 -2
  206. package/dist/interfaces/priority-queue.js +0 -2
  207. package/dist/interfaces/segment-tree.js +0 -2
  208. package/dist/interfaces/singly-linked-list.js +0 -2
  209. package/dist/types/common.js +0 -2
  210. package/dist/types/data-structures/base/base.js +0 -2
  211. package/dist/types/data-structures/base/index.js +0 -17
  212. package/dist/types/data-structures/binary-tree/avl-tree-counter.js +0 -2
  213. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.js +0 -2
  214. package/dist/types/data-structures/binary-tree/avl-tree.js +0 -2
  215. package/dist/types/data-structures/binary-tree/binary-indexed-tree.js +0 -2
  216. package/dist/types/data-structures/binary-tree/binary-tree.js +0 -2
  217. package/dist/types/data-structures/binary-tree/bst.js +0 -2
  218. package/dist/types/data-structures/binary-tree/index.js +0 -25
  219. package/dist/types/data-structures/binary-tree/red-black-tree.js +0 -2
  220. package/dist/types/data-structures/binary-tree/segment-tree.js +0 -2
  221. package/dist/types/data-structures/binary-tree/tree-counter.js +0 -2
  222. package/dist/types/data-structures/binary-tree/tree-multi-map.js +0 -2
  223. package/dist/types/data-structures/graph/abstract-graph.js +0 -2
  224. package/dist/types/data-structures/graph/directed-graph.js +0 -2
  225. package/dist/types/data-structures/graph/index.js +0 -19
  226. package/dist/types/data-structures/graph/map-graph.js +0 -2
  227. package/dist/types/data-structures/graph/undirected-graph.js +0 -2
  228. package/dist/types/data-structures/hash/hash-map.js +0 -2
  229. package/dist/types/data-structures/hash/index.js +0 -17
  230. package/dist/types/data-structures/heap/heap.js +0 -2
  231. package/dist/types/data-structures/heap/index.js +0 -17
  232. package/dist/types/data-structures/heap/max-heap.js +0 -2
  233. package/dist/types/data-structures/heap/min-heap.js +0 -2
  234. package/dist/types/data-structures/index.js +0 -28
  235. package/dist/types/data-structures/linked-list/doubly-linked-list.js +0 -2
  236. package/dist/types/data-structures/linked-list/index.js +0 -19
  237. package/dist/types/data-structures/linked-list/singly-linked-list.js +0 -2
  238. package/dist/types/data-structures/linked-list/skip-linked-list.js +0 -2
  239. package/dist/types/data-structures/matrix/index.js +0 -18
  240. package/dist/types/data-structures/matrix/matrix.js +0 -2
  241. package/dist/types/data-structures/matrix/navigator.js +0 -2
  242. package/dist/types/data-structures/priority-queue/index.js +0 -19
  243. package/dist/types/data-structures/priority-queue/max-priority-queue.js +0 -2
  244. package/dist/types/data-structures/priority-queue/min-priority-queue.js +0 -2
  245. package/dist/types/data-structures/priority-queue/priority-queue.js +0 -2
  246. package/dist/types/data-structures/queue/deque.js +0 -2
  247. package/dist/types/data-structures/queue/index.js +0 -18
  248. package/dist/types/data-structures/queue/queue.js +0 -2
  249. package/dist/types/data-structures/stack/index.js +0 -17
  250. package/dist/types/data-structures/stack/stack.js +0 -2
  251. package/dist/types/data-structures/tree/index.js +0 -17
  252. package/dist/types/data-structures/tree/tree.js +0 -2
  253. package/dist/types/data-structures/trie/index.js +0 -17
  254. package/dist/types/data-structures/trie/trie.js +0 -2
  255. package/dist/types/index.js +0 -19
  256. package/dist/types/utils/index.js +0 -18
  257. package/dist/types/utils/utils.js +0 -2
  258. package/dist/types/utils/validate-type.js +0 -2
  259. package/dist/utils/index.d.ts +0 -2
  260. package/dist/utils/index.js +0 -18
  261. package/dist/utils/number.js +0 -24
  262. package/dist/utils/utils.d.ts +0 -209
  263. package/dist/utils/utils.js +0 -353
  264. package/dist/{common → types/common}/index.d.ts +0 -0
  265. package/dist/{constants → types/constants}/index.d.ts +0 -0
  266. package/dist/{data-structures → types/data-structures}/base/iterable-element-base.d.ts +0 -0
  267. package/dist/{data-structures → types/data-structures}/base/iterable-entry-base.d.ts +0 -0
  268. package/dist/{data-structures → types/data-structures}/base/linear-base.d.ts +0 -0
  269. package/dist/{interfaces → types/interfaces}/doubly-linked-list.d.ts +0 -0
  270. package/dist/{interfaces → types/interfaces}/graph.d.ts +0 -0
  271. package/dist/{interfaces → types/interfaces}/heap.d.ts +0 -0
  272. package/dist/{interfaces → types/interfaces}/index.d.ts +0 -0
  273. package/dist/{interfaces → types/interfaces}/navigator.d.ts +0 -0
  274. package/dist/{interfaces → types/interfaces}/priority-queue.d.ts +0 -0
  275. package/dist/{interfaces → types/interfaces}/segment-tree.d.ts +0 -0
  276. package/dist/{interfaces → types/interfaces}/singly-linked-list.d.ts +0 -0
  277. package/dist/types/{common.d.ts → types/common.d.ts} +0 -0
  278. package/dist/types/{data-structures → types/data-structures}/base/base.d.ts +0 -0
  279. package/dist/{data-structures → types/types/data-structures}/index.d.ts +7 -7
  280. package/dist/{data-structures → types/types/data-structures}/linked-list/index.d.ts +0 -0
  281. package/dist/{data-structures → types/types/data-structures}/matrix/index.d.ts +1 -1
  282. /package/dist/{data-structures → types/types/data-structures}/priority-queue/index.d.ts +0 -0
  283. /package/dist/{data-structures → types/types/data-structures}/queue/index.d.ts +0 -0
  284. /package/dist/{data-structures → types/types/data-structures}/stack/index.d.ts +0 -0
  285. /package/dist/{data-structures → types/types/data-structures}/tree/index.d.ts +0 -0
  286. /package/dist/{data-structures → types/types/data-structures}/trie/index.d.ts +0 -0
  287. /package/dist/types/{utils → types/utils}/validate-type.d.ts +0 -0
  288. /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
- }