data-structure-typed 1.32.1 → 1.32.9

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 (342) hide show
  1. package/.idea/data-structure-typed.iml +19 -0
  2. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  3. package/.idea/misc.xml +6 -0
  4. package/.idea/modules.xml +8 -0
  5. package/.idea/vcs.xml +6 -0
  6. package/CHANGELOG.md +1 -1
  7. package/README.md +415 -255
  8. package/coverage/coverage-final.json +4 -4
  9. package/docs/index.html +268 -21
  10. package/package.json +48 -16
  11. package/test/unit/data-structures/binary-tree/tree-multiset.test.ts +46 -1
  12. package/.auto-changelog-template.hbs +0 -36
  13. package/coverage/clover.xml +0 -3393
  14. package/coverage/lcov-report/base.css +0 -224
  15. package/coverage/lcov-report/block-navigation.js +0 -87
  16. package/coverage/lcov-report/favicon.png +0 -0
  17. package/coverage/lcov-report/index.html +0 -386
  18. package/coverage/lcov-report/prettify.css +0 -1
  19. package/coverage/lcov-report/prettify.js +0 -2
  20. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  21. package/coverage/lcov-report/sorter.js +0 -196
  22. package/coverage/lcov-report/src/data-structures/binary-tree/aa-tree.ts.html +0 -88
  23. package/coverage/lcov-report/src/data-structures/binary-tree/abstract-binary-tree.ts.html +0 -4978
  24. package/coverage/lcov-report/src/data-structures/binary-tree/avl-tree.ts.html +0 -1015
  25. package/coverage/lcov-report/src/data-structures/binary-tree/b-tree.ts.html +0 -88
  26. package/coverage/lcov-report/src/data-structures/binary-tree/binary-indexed-tree.ts.html +0 -313
  27. package/coverage/lcov-report/src/data-structures/binary-tree/binary-tree.ts.html +0 -226
  28. package/coverage/lcov-report/src/data-structures/binary-tree/bst.ts.html +0 -1696
  29. package/coverage/lcov-report/src/data-structures/binary-tree/index.html +0 -296
  30. package/coverage/lcov-report/src/data-structures/binary-tree/index.ts.html +0 -121
  31. package/coverage/lcov-report/src/data-structures/binary-tree/rb-tree.ts.html +0 -388
  32. package/coverage/lcov-report/src/data-structures/binary-tree/segment-tree.ts.html +0 -811
  33. package/coverage/lcov-report/src/data-structures/binary-tree/splay-tree.ts.html +0 -88
  34. package/coverage/lcov-report/src/data-structures/binary-tree/tree-multiset.ts.html +0 -2185
  35. package/coverage/lcov-report/src/data-structures/binary-tree/two-three-tree.ts.html +0 -88
  36. package/coverage/lcov-report/src/data-structures/graph/abstract-graph.ts.html +0 -3205
  37. package/coverage/lcov-report/src/data-structures/graph/directed-graph.ts.html +0 -1495
  38. package/coverage/lcov-report/src/data-structures/graph/index.html +0 -176
  39. package/coverage/lcov-report/src/data-structures/graph/index.ts.html +0 -97
  40. package/coverage/lcov-report/src/data-structures/graph/map-graph.ts.html +0 -472
  41. package/coverage/lcov-report/src/data-structures/graph/undirected-graph.ts.html +0 -907
  42. package/coverage/lcov-report/src/data-structures/hash/coordinate-map.ts.html +0 -286
  43. package/coverage/lcov-report/src/data-structures/hash/coordinate-set.ts.html +0 -253
  44. package/coverage/lcov-report/src/data-structures/hash/hash-table.ts.html +0 -88
  45. package/coverage/lcov-report/src/data-structures/hash/index.html +0 -206
  46. package/coverage/lcov-report/src/data-structures/hash/index.ts.html +0 -103
  47. package/coverage/lcov-report/src/data-structures/hash/pair.ts.html +0 -88
  48. package/coverage/lcov-report/src/data-structures/hash/tree-map.ts.html +0 -88
  49. package/coverage/lcov-report/src/data-structures/hash/tree-set.ts.html +0 -88
  50. package/coverage/lcov-report/src/data-structures/heap/heap.ts.html +0 -721
  51. package/coverage/lcov-report/src/data-structures/heap/index.html +0 -161
  52. package/coverage/lcov-report/src/data-structures/heap/index.ts.html +0 -94
  53. package/coverage/lcov-report/src/data-structures/heap/max-heap.ts.html +0 -178
  54. package/coverage/lcov-report/src/data-structures/heap/min-heap.ts.html +0 -181
  55. package/coverage/lcov-report/src/data-structures/index.html +0 -116
  56. package/coverage/lcov-report/src/data-structures/index.ts.html +0 -118
  57. package/coverage/lcov-report/src/data-structures/linked-list/doubly-linked-list.ts.html +0 -1804
  58. package/coverage/lcov-report/src/data-structures/linked-list/index.html +0 -161
  59. package/coverage/lcov-report/src/data-structures/linked-list/index.ts.html +0 -94
  60. package/coverage/lcov-report/src/data-structures/linked-list/singly-linked-list.ts.html +0 -1588
  61. package/coverage/lcov-report/src/data-structures/linked-list/skip-linked-list.ts.html +0 -88
  62. package/coverage/lcov-report/src/data-structures/matrix/index.html +0 -176
  63. package/coverage/lcov-report/src/data-structures/matrix/index.ts.html +0 -97
  64. package/coverage/lcov-report/src/data-structures/matrix/matrix.ts.html +0 -166
  65. package/coverage/lcov-report/src/data-structures/matrix/matrix2d.ts.html +0 -721
  66. package/coverage/lcov-report/src/data-structures/matrix/navigator.ts.html +0 -448
  67. package/coverage/lcov-report/src/data-structures/matrix/vector2d.ts.html +0 -1033
  68. package/coverage/lcov-report/src/data-structures/priority-queue/index.html +0 -161
  69. package/coverage/lcov-report/src/data-structures/priority-queue/index.ts.html +0 -94
  70. package/coverage/lcov-report/src/data-structures/priority-queue/max-priority-queue.ts.html +0 -253
  71. package/coverage/lcov-report/src/data-structures/priority-queue/min-priority-queue.ts.html +0 -256
  72. package/coverage/lcov-report/src/data-structures/priority-queue/priority-queue.ts.html +0 -1162
  73. package/coverage/lcov-report/src/data-structures/queue/deque.ts.html +0 -976
  74. package/coverage/lcov-report/src/data-structures/queue/index.html +0 -146
  75. package/coverage/lcov-report/src/data-structures/queue/index.ts.html +0 -91
  76. package/coverage/lcov-report/src/data-structures/queue/queue.ts.html +0 -658
  77. package/coverage/lcov-report/src/data-structures/stack/index.html +0 -131
  78. package/coverage/lcov-report/src/data-structures/stack/index.ts.html +0 -88
  79. package/coverage/lcov-report/src/data-structures/stack/stack.ts.html +0 -379
  80. package/coverage/lcov-report/src/data-structures/tree/index.html +0 -131
  81. package/coverage/lcov-report/src/data-structures/tree/index.ts.html +0 -88
  82. package/coverage/lcov-report/src/data-structures/tree/tree.ts.html +0 -292
  83. package/coverage/lcov-report/src/data-structures/trie/index.html +0 -131
  84. package/coverage/lcov-report/src/data-structures/trie/index.ts.html +0 -88
  85. package/coverage/lcov-report/src/data-structures/trie/trie.ts.html +0 -760
  86. package/coverage/lcov-report/src/index.html +0 -116
  87. package/coverage/lcov-report/src/index.ts.html +0 -97
  88. package/coverage/lcov-report/src/interfaces/index.html +0 -116
  89. package/coverage/lcov-report/src/interfaces/index.ts.html +0 -130
  90. package/coverage/lcov-report/src/types/data-structures/abstract-binary-tree.ts.html +0 -235
  91. package/coverage/lcov-report/src/types/data-structures/bst.ts.html +0 -124
  92. package/coverage/lcov-report/src/types/data-structures/directed-graph.ts.html +0 -109
  93. package/coverage/lcov-report/src/types/data-structures/index.html +0 -176
  94. package/coverage/lcov-report/src/types/data-structures/index.ts.html +0 -130
  95. package/coverage/lcov-report/src/types/data-structures/rb-tree.ts.html +0 -106
  96. package/coverage/lcov-report/src/types/index.html +0 -116
  97. package/coverage/lcov-report/src/types/index.ts.html +0 -94
  98. package/coverage/lcov-report/src/types/utils/index.html +0 -116
  99. package/coverage/lcov-report/src/types/utils/index.ts.html +0 -91
  100. package/coverage/lcov-report/src/utils/index.html +0 -131
  101. package/coverage/lcov-report/src/utils/index.ts.html +0 -88
  102. package/coverage/lcov-report/src/utils/utils.ts.html +0 -322
  103. package/coverage/lcov-report/test/utils/index.html +0 -146
  104. package/coverage/lcov-report/test/utils/index.ts.html +0 -91
  105. package/coverage/lcov-report/test/utils/magnitude.ts.html +0 -148
  106. package/coverage/lcov-report/test/utils/number.ts.html +0 -94
  107. package/coverage/lcov.info +0 -6676
  108. package/docs/assets/highlight.css +0 -127
  109. package/docs/assets/main.js +0 -58
  110. package/docs/assets/search.js +0 -1
  111. package/docs/assets/style.css +0 -1367
  112. package/docs/classes/AVLTree.html +0 -2182
  113. package/docs/classes/AVLTreeNode.html +0 -399
  114. package/docs/classes/AaTree.html +0 -202
  115. package/docs/classes/AbstractBinaryTree.html +0 -1836
  116. package/docs/classes/AbstractBinaryTreeNode.html +0 -441
  117. package/docs/classes/AbstractEdge.html +0 -345
  118. package/docs/classes/AbstractGraph.html +0 -1105
  119. package/docs/classes/AbstractVertex.html +0 -299
  120. package/docs/classes/ArrayDeque.html +0 -469
  121. package/docs/classes/BST.html +0 -2026
  122. package/docs/classes/BSTNode.html +0 -400
  123. package/docs/classes/BTree.html +0 -202
  124. package/docs/classes/BinaryIndexedTree.html +0 -371
  125. package/docs/classes/BinaryTree.html +0 -1867
  126. package/docs/classes/BinaryTreeNode.html +0 -399
  127. package/docs/classes/Character.html +0 -250
  128. package/docs/classes/CoordinateMap.html +0 -513
  129. package/docs/classes/CoordinateSet.html +0 -474
  130. package/docs/classes/Deque.html +0 -1005
  131. package/docs/classes/DirectedEdge.html +0 -404
  132. package/docs/classes/DirectedGraph.html +0 -1530
  133. package/docs/classes/DirectedVertex.html +0 -286
  134. package/docs/classes/DoublyLinkedList.html +0 -998
  135. package/docs/classes/DoublyLinkedListNode.html +0 -327
  136. package/docs/classes/HashTable.html +0 -202
  137. package/docs/classes/Heap.html +0 -647
  138. package/docs/classes/HeapItem.html +0 -296
  139. package/docs/classes/LinkedListQueue.html +0 -884
  140. package/docs/classes/MapEdge.html +0 -391
  141. package/docs/classes/MapGraph.html +0 -1583
  142. package/docs/classes/MapVertex.html +0 -356
  143. package/docs/classes/Matrix2D.html +0 -532
  144. package/docs/classes/MatrixNTI2D.html +0 -270
  145. package/docs/classes/MaxHeap.html +0 -671
  146. package/docs/classes/MaxPriorityQueue.html +0 -866
  147. package/docs/classes/MinHeap.html +0 -672
  148. package/docs/classes/MinPriorityQueue.html +0 -868
  149. package/docs/classes/Navigator.html +0 -343
  150. package/docs/classes/ObjectDeque.html +0 -527
  151. package/docs/classes/Pair.html +0 -202
  152. package/docs/classes/PriorityQueue.html +0 -790
  153. package/docs/classes/Queue.html +0 -521
  154. package/docs/classes/RBTree.html +0 -2024
  155. package/docs/classes/RBTreeNode.html +0 -431
  156. package/docs/classes/SegmentTree.html +0 -464
  157. package/docs/classes/SegmentTreeNode.html +0 -387
  158. package/docs/classes/SinglyLinkedList.html +0 -830
  159. package/docs/classes/SinglyLinkedListNode.html +0 -300
  160. package/docs/classes/SkipLinkedList.html +0 -202
  161. package/docs/classes/SplayTree.html +0 -202
  162. package/docs/classes/Stack.html +0 -398
  163. package/docs/classes/TreeMap.html +0 -202
  164. package/docs/classes/TreeMultiset.html +0 -2510
  165. package/docs/classes/TreeMultisetNode.html +0 -447
  166. package/docs/classes/TreeNode.html +0 -344
  167. package/docs/classes/TreeSet.html +0 -202
  168. package/docs/classes/Trie.html +0 -402
  169. package/docs/classes/TrieNode.html +0 -310
  170. package/docs/classes/TwoThreeTree.html +0 -202
  171. package/docs/classes/UndirectedEdge.html +0 -374
  172. package/docs/classes/UndirectedGraph.html +0 -1285
  173. package/docs/classes/UndirectedVertex.html +0 -284
  174. package/docs/classes/Vector2D.html +0 -835
  175. package/docs/enums/CP.html +0 -211
  176. package/docs/enums/FamilyPosition.html +0 -239
  177. package/docs/enums/LoopType.html +0 -212
  178. package/docs/enums/RBColor.html +0 -204
  179. package/docs/enums/TopologicalProperty.html +0 -211
  180. package/docs/functions/arrayRemove.html +0 -208
  181. package/docs/functions/isThunk.html +0 -186
  182. package/docs/functions/toThunk.html +0 -186
  183. package/docs/functions/trampoline.html +0 -186
  184. package/docs/functions/trampolineAsync.html +0 -186
  185. package/docs/functions/uuidV4.html +0 -181
  186. package/docs/interfaces/IAVLTree.html +0 -1245
  187. package/docs/interfaces/IAbstractBinaryTree.html +0 -1101
  188. package/docs/interfaces/IAbstractBinaryTreeNode.html +0 -335
  189. package/docs/interfaces/IAbstractGraph.html +0 -433
  190. package/docs/interfaces/IBST.html +0 -1245
  191. package/docs/interfaces/IDirectedGraph.html +0 -570
  192. package/docs/interfaces/IRBTree.html +0 -1247
  193. package/docs/interfaces/IUNDirectedGraph.html +0 -463
  194. package/docs/types/AVLTreeNodeNested.html +0 -182
  195. package/docs/types/AVLTreeOptions.html +0 -180
  196. package/docs/types/AbstractBinaryTreeNodeNested.html +0 -182
  197. package/docs/types/AbstractBinaryTreeNodeProperties.html +0 -182
  198. package/docs/types/AbstractBinaryTreeNodeProperty.html +0 -182
  199. package/docs/types/AbstractBinaryTreeOptions.html +0 -182
  200. package/docs/types/BSTComparator.html +0 -192
  201. package/docs/types/BSTNodeNested.html +0 -182
  202. package/docs/types/BSTOptions.html +0 -182
  203. package/docs/types/BinaryTreeDeletedResult.html +0 -189
  204. package/docs/types/BinaryTreeNodeId.html +0 -177
  205. package/docs/types/BinaryTreeNodeNested.html +0 -182
  206. package/docs/types/BinaryTreeNodePropertyName.html +0 -177
  207. package/docs/types/BinaryTreeOptions.html +0 -180
  208. package/docs/types/DFSOrderPattern.html +0 -177
  209. package/docs/types/DijkstraResult.html +0 -199
  210. package/docs/types/Direction.html +0 -177
  211. package/docs/types/DummyAny.html +0 -190
  212. package/docs/types/EdgeId.html +0 -177
  213. package/docs/types/HeapOptions.html +0 -198
  214. package/docs/types/IAVLTreeNode.html +0 -184
  215. package/docs/types/IBSTNode.html +0 -184
  216. package/docs/types/IBinaryTree.html +0 -182
  217. package/docs/types/IBinaryTreeNode.html +0 -184
  218. package/docs/types/IRBTreeNode.html +0 -184
  219. package/docs/types/ITreeMultiset.html +0 -182
  220. package/docs/types/ITreeMultisetNode.html +0 -184
  221. package/docs/types/KeyValueObject.html +0 -182
  222. package/docs/types/KeyValueObjectWithId.html +0 -184
  223. package/docs/types/MapGraphCoordinate.html +0 -177
  224. package/docs/types/NavigatorParams.html +0 -211
  225. package/docs/types/NodeOrPropertyName.html +0 -177
  226. package/docs/types/NonNumberNonObjectButDefined.html +0 -177
  227. package/docs/types/ObjectWithNonNumberId.html +0 -184
  228. package/docs/types/ObjectWithNumberId.html +0 -184
  229. package/docs/types/ObjectWithoutId.html +0 -177
  230. package/docs/types/PriorityQueueComparator.html +0 -197
  231. package/docs/types/PriorityQueueDFSOrderPattern.html +0 -177
  232. package/docs/types/PriorityQueueOptions.html +0 -191
  233. package/docs/types/RBTreeNodeNested.html +0 -182
  234. package/docs/types/RBTreeOptions.html +0 -180
  235. package/docs/types/RestrictValById.html +0 -177
  236. package/docs/types/SegmentTreeNodeVal.html +0 -177
  237. package/docs/types/SpecifyOptional.html +0 -184
  238. package/docs/types/Thunk.html +0 -185
  239. package/docs/types/ToThunkFn.html +0 -185
  240. package/docs/types/TopologicalStatus.html +0 -177
  241. package/docs/types/TreeMultisetNodeNested.html +0 -182
  242. package/docs/types/TreeMultisetOptions.html +0 -180
  243. package/docs/types/TrlAsyncFn.html +0 -190
  244. package/docs/types/TrlFn.html +0 -190
  245. package/docs/types/Turning.html +0 -177
  246. package/docs/types/VertexId.html +0 -177
  247. package/docs/variables/THUNK_SYMBOL.html +0 -177
  248. package/rename_clear_files.sh +0 -29
  249. package/src/data-structures/binary-tree/aa-tree.ts +0 -1
  250. package/src/data-structures/binary-tree/abstract-binary-tree.ts +0 -1631
  251. package/src/data-structures/binary-tree/avl-tree.ts +0 -310
  252. package/src/data-structures/binary-tree/b-tree.ts +0 -1
  253. package/src/data-structures/binary-tree/binary-indexed-tree.ts +0 -76
  254. package/src/data-structures/binary-tree/binary-tree.ts +0 -47
  255. package/src/data-structures/binary-tree/bst.ts +0 -537
  256. package/src/data-structures/binary-tree/index.ts +0 -12
  257. package/src/data-structures/binary-tree/rb-tree.ts +0 -101
  258. package/src/data-structures/binary-tree/segment-tree.ts +0 -242
  259. package/src/data-structures/binary-tree/splay-tree.ts +0 -1
  260. package/src/data-structures/binary-tree/tree-multiset.ts +0 -700
  261. package/src/data-structures/binary-tree/two-three-tree.ts +0 -1
  262. package/src/data-structures/diagrams/README.md +0 -5
  263. package/src/data-structures/graph/abstract-graph.ts +0 -1040
  264. package/src/data-structures/graph/directed-graph.ts +0 -470
  265. package/src/data-structures/graph/index.ts +0 -4
  266. package/src/data-structures/graph/map-graph.ts +0 -129
  267. package/src/data-structures/graph/undirected-graph.ts +0 -274
  268. package/src/data-structures/hash/coordinate-map.ts +0 -67
  269. package/src/data-structures/hash/coordinate-set.ts +0 -56
  270. package/src/data-structures/hash/hash-table.ts +0 -1
  271. package/src/data-structures/hash/index.ts +0 -6
  272. package/src/data-structures/hash/pair.ts +0 -1
  273. package/src/data-structures/hash/tree-map.ts +0 -1
  274. package/src/data-structures/hash/tree-set.ts +0 -1
  275. package/src/data-structures/heap/heap.ts +0 -212
  276. package/src/data-structures/heap/index.ts +0 -3
  277. package/src/data-structures/heap/max-heap.ts +0 -31
  278. package/src/data-structures/heap/min-heap.ts +0 -32
  279. package/src/data-structures/index.ts +0 -11
  280. package/src/data-structures/linked-list/doubly-linked-list.ts +0 -573
  281. package/src/data-structures/linked-list/index.ts +0 -3
  282. package/src/data-structures/linked-list/singly-linked-list.ts +0 -501
  283. package/src/data-structures/linked-list/skip-linked-list.ts +0 -1
  284. package/src/data-structures/matrix/index.ts +0 -4
  285. package/src/data-structures/matrix/matrix.ts +0 -27
  286. package/src/data-structures/matrix/matrix2d.ts +0 -212
  287. package/src/data-structures/matrix/navigator.ts +0 -121
  288. package/src/data-structures/matrix/vector2d.ts +0 -316
  289. package/src/data-structures/priority-queue/index.ts +0 -3
  290. package/src/data-structures/priority-queue/max-priority-queue.ts +0 -56
  291. package/src/data-structures/priority-queue/min-priority-queue.ts +0 -57
  292. package/src/data-structures/priority-queue/priority-queue.ts +0 -359
  293. package/src/data-structures/queue/deque.ts +0 -297
  294. package/src/data-structures/queue/index.ts +0 -2
  295. package/src/data-structures/queue/queue.ts +0 -191
  296. package/src/data-structures/stack/index.ts +0 -1
  297. package/src/data-structures/stack/stack.ts +0 -98
  298. package/src/data-structures/tree/index.ts +0 -1
  299. package/src/data-structures/tree/tree.ts +0 -69
  300. package/src/data-structures/trie/index.ts +0 -1
  301. package/src/data-structures/trie/trie.ts +0 -225
  302. package/src/index.ts +0 -4
  303. package/src/interfaces/abstract-binary-tree.ts +0 -191
  304. package/src/interfaces/abstract-graph.ts +0 -31
  305. package/src/interfaces/avl-tree.ts +0 -25
  306. package/src/interfaces/binary-tree.ts +0 -6
  307. package/src/interfaces/bst.ts +0 -31
  308. package/src/interfaces/directed-graph.ts +0 -20
  309. package/src/interfaces/doubly-linked-list.ts +0 -1
  310. package/src/interfaces/heap.ts +0 -1
  311. package/src/interfaces/index.ts +0 -15
  312. package/src/interfaces/navigator.ts +0 -1
  313. package/src/interfaces/priority-queue.ts +0 -1
  314. package/src/interfaces/rb-tree.ts +0 -9
  315. package/src/interfaces/segment-tree.ts +0 -1
  316. package/src/interfaces/singly-linked-list.ts +0 -1
  317. package/src/interfaces/tree-multiset.ts +0 -7
  318. package/src/interfaces/undirected-graph.ts +0 -6
  319. package/src/types/data-structures/abstract-binary-tree.ts +0 -50
  320. package/src/types/data-structures/abstract-graph.ts +0 -11
  321. package/src/types/data-structures/avl-tree.ts +0 -5
  322. package/src/types/data-structures/binary-tree.ts +0 -5
  323. package/src/types/data-structures/bst.ts +0 -13
  324. package/src/types/data-structures/directed-graph.ts +0 -8
  325. package/src/types/data-structures/doubly-linked-list.ts +0 -1
  326. package/src/types/data-structures/heap.ts +0 -5
  327. package/src/types/data-structures/index.ts +0 -15
  328. package/src/types/data-structures/map-graph.ts +0 -1
  329. package/src/types/data-structures/navigator.ts +0 -13
  330. package/src/types/data-structures/priority-queue.ts +0 -9
  331. package/src/types/data-structures/rb-tree.ts +0 -8
  332. package/src/types/data-structures/segment-tree.ts +0 -1
  333. package/src/types/data-structures/singly-linked-list.ts +0 -1
  334. package/src/types/data-structures/tree-multiset.ts +0 -6
  335. package/src/types/helpers.ts +0 -1
  336. package/src/types/index.ts +0 -3
  337. package/src/types/utils/index.ts +0 -2
  338. package/src/types/utils/utils.ts +0 -6
  339. package/src/types/utils/validate-type.ts +0 -35
  340. package/src/utils/index.ts +0 -1
  341. package/src/utils/utils.ts +0 -79
  342. package/tsconfig.build.json +0 -33
@@ -1,470 +0,0 @@
1
- /**
2
- * data-structure-typed
3
- *
4
- * @author Tyler Zeng
5
- * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
- * @license MIT License
7
- */
8
- import {arrayRemove} from '../../utils';
9
- import {AbstractEdge, AbstractGraph, AbstractVertex} from './abstract-graph';
10
- import type {TopologicalStatus, VertexId} from '../../types';
11
- import {IDirectedGraph} from '../../interfaces';
12
-
13
- export class DirectedVertex<T = number> extends AbstractVertex<T> {
14
- /**
15
- * The constructor function initializes a vertex with an optional value.
16
- * @param {VertexId} id - The `id` parameter is of type `VertexId` and represents the identifier of the vertex. It is
17
- * used to uniquely identify the vertex within a graph or data structure.
18
- * @param {T} [val] - The "val" parameter is an optional parameter of type T. It is used to initialize the value of the
19
- * vertex. If no value is provided, the vertex will be initialized with a default value.
20
- */
21
- constructor(id: VertexId, val?: T) {
22
- super(id, val);
23
- }
24
- }
25
-
26
- export class DirectedEdge<T = number> extends AbstractEdge<T> {
27
- /**
28
- * The constructor function initializes the source and destination vertices of an edge, along with an optional weight
29
- * and value.
30
- * @param {VertexId} src - The `src` parameter is the source vertex ID. It represents the starting point of an edge in
31
- * a graph.
32
- * @param {VertexId} dest - The `dest` parameter represents the destination vertex of an edge. It is of type
33
- * `VertexId`, which is likely a unique identifier for a vertex in a graph.
34
- * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
35
- * @param {T} [val] - The `val` parameter is an optional parameter of type `T`. It represents the value associated with
36
- * the edge.
37
- */
38
- constructor(src: VertexId, dest: VertexId, weight?: number, val?: T) {
39
- super(weight, val);
40
- this._src = src;
41
- this._dest = dest;
42
- }
43
-
44
- private _src: VertexId;
45
-
46
- get src(): VertexId {
47
- return this._src;
48
- }
49
-
50
- set src(v: VertexId) {
51
- this._src = v;
52
- }
53
-
54
- private _dest: VertexId;
55
-
56
- get dest(): VertexId {
57
- return this._dest;
58
- }
59
-
60
- set dest(v: VertexId) {
61
- this._dest = v;
62
- }
63
- }
64
-
65
- export class DirectedGraph<V extends DirectedVertex<any> = DirectedVertex, E extends DirectedEdge<any> = DirectedEdge>
66
- extends AbstractGraph<V, E>
67
- implements IDirectedGraph<V, E>
68
- {
69
- /**
70
- * The constructor function initializes an instance of a class.
71
- */
72
- constructor() {
73
- super();
74
- }
75
-
76
- private _outEdgeMap: Map<V, E[]> = new Map<V, E[]>();
77
-
78
- get outEdgeMap(): Map<V, E[]> {
79
- return this._outEdgeMap;
80
- }
81
-
82
- private _inEdgeMap: Map<V, E[]> = new Map<V, E[]>();
83
-
84
- get inEdgeMap(): Map<V, E[]> {
85
- return this._inEdgeMap;
86
- }
87
-
88
- /**
89
- * In TypeScript, a subclass inherits the interface implementation of its parent class, without needing to implement the same interface again in the subclass. This behavior differs from Java's approach. In Java, if a parent class implements an interface, the subclass needs to explicitly implement the same interface, even if the parent class has already implemented it.
90
- * This means that using abstract methods in the parent class cannot constrain the grandchild classes. Defining methods within an interface also cannot constrain the descendant classes. When inheriting from this class, developers need to be aware that this method needs to be overridden.
91
- */
92
-
93
- /**
94
- * The function creates a new vertex with an optional value and returns it.
95
- * @param {VertexId} id - The `id` parameter is the unique identifier for the vertex. It is of type `VertexId`, which
96
- * could be a number or a string depending on how you want to identify your vertices.
97
- * @param [val] - The 'val' parameter is an optional value that can be assigned to the vertex. If a value is provided,
98
- * it will be assigned to the 'val' property of the vertex. If no value is provided, the 'val' property will be
99
- * assigned the same value as the 'id' parameter
100
- * @returns a new instance of a DirectedVertex object, casted as type V.
101
- */
102
- createVertex(id: VertexId, val?: V['val']): V {
103
- return new DirectedVertex(id, val ?? id) as V;
104
- }
105
-
106
- /**
107
- * In TypeScript, a subclass inherits the interface implementation of its parent class, without needing to implement the same interface again in the subclass. This behavior differs from Java's approach. In Java, if a parent class implements an interface, the subclass needs to explicitly implement the same interface, even if the parent class has already implemented it.
108
- * This means that using abstract methods in the parent class cannot constrain the grandchild classes. Defining methods within an interface also cannot constrain the descendant classes. When inheriting from this class, developers need to be aware that this method needs to be overridden.
109
- */
110
-
111
- /**
112
- * The function creates a directed edge between two vertices with an optional weight and value.
113
- * @param {VertexId} src - The source vertex ID of the edge. It represents the starting point of the edge.
114
- * @param {VertexId} dest - The `dest` parameter is the identifier of the destination vertex for the edge.
115
- * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge. If no
116
- * weight is provided, it defaults to 1.
117
- * @param [val] - The 'val' parameter is an optional value that can be assigned to the edge. It can be of any type and
118
- * is used to store additional information or data associated with the edge.
119
- * @returns a new instance of a DirectedEdge object, casted as type E.
120
- */
121
- createEdge(src: VertexId, dest: VertexId, weight?: number, val?: E['val']): E {
122
- return new DirectedEdge(src, dest, weight ?? 1, val) as E;
123
- }
124
-
125
- /**
126
- * The `getEdge` function retrieves an edge between two vertices based on their source and destination IDs.
127
- * @param {V | null | VertexId} srcOrId - The source vertex or its ID. It can be either a vertex object or a vertex ID.
128
- * @param {V | null | VertexId} destOrId - The `destOrId` parameter in the `getEdge` function represents the
129
- * destination vertex of the edge. It can be either a vertex object (`V`), a vertex ID (`VertexId`), or `null` if the
130
- * destination is not specified.
131
- * @returns the first edge found between the source and destination vertices, or null if no such edge is found.
132
- */
133
- getEdge(srcOrId: V | null | VertexId, destOrId: V | null | VertexId): E | null {
134
- let edges: E[] = [];
135
-
136
- if (srcOrId !== null && destOrId !== null) {
137
- const src: V | null = this._getVertex(srcOrId);
138
- const dest: V | null = this._getVertex(destOrId);
139
-
140
- if (src && dest) {
141
- const srcOutEdges = this._outEdgeMap.get(src);
142
- if (srcOutEdges) {
143
- edges = srcOutEdges.filter(edge => edge.dest === dest.id);
144
- }
145
- }
146
- }
147
-
148
- return edges[0] || null;
149
- }
150
-
151
- /**
152
- * The function removes an edge between two vertices in a graph and returns the removed edge.
153
- * @param {V | VertexId} srcOrId - The source vertex or its ID.
154
- * @param {V | VertexId} destOrId - The `destOrId` parameter represents the destination vertex or its ID.
155
- * @returns the removed edge (E) if it exists, or null if either the source or destination vertex does not exist.
156
- */
157
- removeEdgeSrcToDest(srcOrId: V | VertexId, destOrId: V | VertexId): E | null {
158
- const src: V | null = this._getVertex(srcOrId);
159
- const dest: V | null = this._getVertex(destOrId);
160
- let removed: E | null = null;
161
- if (!src || !dest) {
162
- return null;
163
- }
164
-
165
- const srcOutEdges = this._outEdgeMap.get(src);
166
- if (srcOutEdges) {
167
- arrayRemove<E>(srcOutEdges, (edge: E) => edge.dest === dest.id);
168
- }
169
-
170
- const destInEdges = this._inEdgeMap.get(dest);
171
- if (destInEdges) {
172
- removed = arrayRemove<E>(destInEdges, (edge: E) => edge.src === src.id)[0] || null;
173
- }
174
- return removed;
175
- }
176
-
177
- /**
178
- * The function removes an edge from a graph and returns the removed edge, or null if the edge was not found.
179
- * @param {E} edge - The `edge` parameter is an object that represents an edge in a graph. It has two properties: `src`
180
- * and `dest`, which represent the source and destination vertices of the edge, respectively.
181
- * @returns The method `removeEdge` returns the removed edge (`E`) if it exists, or `null` if the edge does not exist.
182
- */
183
- removeEdge(edge: E): E | null {
184
- let removed: E | null = null;
185
- const src = this._getVertex(edge.src);
186
- const dest = this._getVertex(edge.dest);
187
- if (src && dest) {
188
- const srcOutEdges = this._outEdgeMap.get(src);
189
- if (srcOutEdges && srcOutEdges.length > 0) {
190
- arrayRemove(srcOutEdges, (edge: E) => edge.src === src.id);
191
- }
192
-
193
- const destInEdges = this._inEdgeMap.get(dest);
194
- if (destInEdges && destInEdges.length > 0) {
195
- removed = arrayRemove(destInEdges, (edge: E) => edge.dest === dest.id)[0];
196
- }
197
- }
198
-
199
- return removed;
200
- }
201
-
202
- /**
203
- * The function removes edges between two vertices and returns the removed edges.
204
- * @param {VertexId | V} v1 - The parameter `v1` can be either a `VertexId` or a `V`. A `VertexId` represents the
205
- * unique identifier of a vertex in a graph, while `V` represents the actual vertex object.
206
- * @param {VertexId | V} v2 - The parameter `v2` represents either a `VertexId` or a `V` object. It is used to specify
207
- * the second vertex in the edge that needs to be removed.
208
- * @returns an array of removed edges (E[]).
209
- */
210
- removeEdgesBetween(v1: VertexId | V, v2: VertexId | V): E[] {
211
- const removed: E[] = [];
212
-
213
- if (v1 && v2) {
214
- const v1ToV2 = this.removeEdgeSrcToDest(v1, v2);
215
- const v2ToV1 = this.removeEdgeSrcToDest(v2, v1);
216
-
217
- v1ToV2 && removed.push(v1ToV2);
218
- v2ToV1 && removed.push(v2ToV1);
219
- }
220
-
221
- return removed;
222
- }
223
-
224
- /**
225
- * The function `incomingEdgesOf` returns an array of incoming edges for a given vertex or vertex ID.
226
- * @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can be either a vertex object (`V`) or a vertex ID
227
- * (`VertexId`).
228
- * @returns The method `incomingEdgesOf` returns an array of edges (`E[]`).
229
- */
230
- incomingEdgesOf(vertexOrId: V | VertexId): E[] {
231
- const target = this._getVertex(vertexOrId);
232
- if (target) {
233
- return this.inEdgeMap.get(target) || [];
234
- }
235
- return [];
236
- }
237
-
238
- /**
239
- * The function `outgoingEdgesOf` returns an array of outgoing edges from a given vertex or vertex ID.
240
- * @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can accept either a vertex object (`V`) or a vertex ID
241
- * (`VertexId`).
242
- * @returns The method `outgoingEdgesOf` returns an array of edges (`E[]`).
243
- */
244
- outgoingEdgesOf(vertexOrId: V | VertexId): E[] {
245
- const target = this._getVertex(vertexOrId);
246
- if (target) {
247
- return this._outEdgeMap.get(target) || [];
248
- }
249
- return [];
250
- }
251
-
252
- /**
253
- * The function "degreeOf" returns the total degree of a vertex, which is the sum of its out-degree and in-degree.
254
- * @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a `V`.
255
- * @returns The sum of the out-degree and in-degree of the specified vertex or vertex ID.
256
- */
257
- degreeOf(vertexOrId: VertexId | V): number {
258
- return this.outDegreeOf(vertexOrId) + this.inDegreeOf(vertexOrId);
259
- }
260
-
261
- /**
262
- * The function "inDegreeOf" returns the number of incoming edges for a given vertex.
263
- * @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a `V`.
264
- * @returns The number of incoming edges of the specified vertex or vertex ID.
265
- */
266
- inDegreeOf(vertexOrId: VertexId | V): number {
267
- return this.incomingEdgesOf(vertexOrId).length;
268
- }
269
-
270
- /**
271
- * The function `outDegreeOf` returns the number of outgoing edges from a given vertex.
272
- * @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a `V`.
273
- * @returns The number of outgoing edges from the specified vertex or vertex ID.
274
- */
275
- outDegreeOf(vertexOrId: VertexId | V): number {
276
- return this.outgoingEdgesOf(vertexOrId).length;
277
- }
278
-
279
- /**
280
- * The function "edgesOf" returns an array of both outgoing and incoming edges of a given vertex or vertex ID.
281
- * @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a `V`.
282
- * @returns The function `edgesOf` returns an array of edges.
283
- */
284
- edgesOf(vertexOrId: VertexId | V): E[] {
285
- return [...this.outgoingEdgesOf(vertexOrId), ...this.incomingEdgesOf(vertexOrId)];
286
- }
287
-
288
- /**
289
- * The function "getEdgeSrc" returns the source vertex of an edge, or null if the edge does not exist.
290
- * @param {E} e - The parameter "e" is of type E, which represents an edge in a graph.
291
- * @returns either a vertex object (V) or null.
292
- */
293
- getEdgeSrc(e: E): V | null {
294
- return this._getVertex(e.src);
295
- }
296
-
297
- /**
298
- * The function "getEdgeDest" returns the destination vertex of an edge.
299
- * @param {E} e - The parameter "e" is of type "E", which represents an edge in a graph.
300
- * @returns either a vertex object of type V or null.
301
- */
302
- getEdgeDest(e: E): V | null {
303
- return this._getVertex(e.dest);
304
- }
305
-
306
- /**
307
- * The function `getDestinations` returns an array of destination vertices connected to a given vertex.
308
- * @param {V | VertexId | null} vertex - The `vertex` parameter represents the starting vertex from which we want to
309
- * find the destinations. It can be either a `V` object, a `VertexId` value, or `null`.
310
- * @returns an array of vertices (V[]).
311
- */
312
- getDestinations(vertex: V | VertexId | null): V[] {
313
- if (vertex === null) {
314
- return [];
315
- }
316
- const destinations: V[] = [];
317
- const outgoingEdges = this.outgoingEdgesOf(vertex);
318
- for (const outEdge of outgoingEdges) {
319
- const child = this.getEdgeDest(outEdge);
320
- if (child) {
321
- destinations.push(child);
322
- }
323
- }
324
- return destinations;
325
- }
326
-
327
- /**
328
- * The `topologicalSort` function performs a topological sort on a graph and returns an array of vertices or vertex IDs
329
- * in the sorted order, or null if the graph contains a cycle.
330
- * @param {'vertex' | 'id'} [propertyName] - The `propertyName` parameter is an optional parameter that specifies the
331
- * property to use for sorting the vertices. It can have two possible values: 'vertex' or 'id'. If 'vertex' is
332
- * specified, the vertices themselves will be used for sorting. If 'id' is specified, the ids of
333
- * @returns an array of vertices or vertex IDs in topological order. If there is a cycle in the graph, it returns null.
334
- */
335
- topologicalSort(propertyName?: 'vertex' | 'id'): Array<V | VertexId> | null {
336
- propertyName = propertyName ?? 'id';
337
- // When judging whether there is a cycle in the undirected graph, all nodes with degree of **<= 1** are enqueued
338
- // When judging whether there is a cycle in the directed graph, all nodes with **in degree = 0** are enqueued
339
- const statusMap: Map<V | VertexId, TopologicalStatus> = new Map<V | VertexId, TopologicalStatus>();
340
- for (const entry of this.vertices) {
341
- statusMap.set(entry[1], 0);
342
- }
343
-
344
- let sorted: (V | VertexId)[] = [];
345
- let hasCycle = false;
346
- const dfs = (cur: V | VertexId) => {
347
- statusMap.set(cur, 1);
348
- const children = this.getDestinations(cur);
349
- for (const child of children) {
350
- const childStatus = statusMap.get(child);
351
- if (childStatus === 0) {
352
- dfs(child);
353
- } else if (childStatus === 1) {
354
- hasCycle = true;
355
- }
356
- }
357
- statusMap.set(cur, 2);
358
- sorted.push(cur);
359
- };
360
-
361
- for (const entry of this.vertices) {
362
- if (statusMap.get(entry[1]) === 0) {
363
- dfs(entry[1]);
364
- }
365
- }
366
-
367
- if (hasCycle) return null;
368
-
369
- if (propertyName === 'id') sorted = sorted.map(vertex => (vertex instanceof DirectedVertex ? vertex.id : vertex));
370
- return sorted.reverse();
371
- }
372
-
373
- /**
374
- * The `edgeSet` function returns an array of all the edges in the graph.
375
- * @returns The `edgeSet()` method returns an array of edges (`E[]`).
376
- */
377
- edgeSet(): E[] {
378
- let edges: E[] = [];
379
- this._outEdgeMap.forEach(outEdges => {
380
- edges = [...edges, ...outEdges];
381
- });
382
- return edges;
383
- }
384
-
385
- /**
386
- * The function `getNeighbors` returns an array of neighboring vertices of a given vertex or vertex ID in a graph.
387
- * @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can be either a vertex object (`V`) or a vertex ID
388
- * (`VertexId`).
389
- * @returns an array of vertices (V[]).
390
- */
391
- getNeighbors(vertexOrId: V | VertexId): V[] {
392
- const neighbors: V[] = [];
393
- const vertex = this._getVertex(vertexOrId);
394
- if (vertex) {
395
- const outEdges = this.outgoingEdgesOf(vertex);
396
- for (const outEdge of outEdges) {
397
- const neighbor = this._getVertex(outEdge.dest);
398
- // TODO after no-non-null-assertion not ensure the logic
399
- if (neighbor) {
400
- neighbors.push(neighbor);
401
- }
402
- }
403
- }
404
- return neighbors;
405
- }
406
-
407
- /**
408
- * The function "getEndsOfEdge" returns the source and destination vertices of an edge if it exists in the graph,
409
- * otherwise it returns null.
410
- * @param {E} edge - The parameter `edge` is of type `E`, which represents an edge in a graph.
411
- * @returns The function `getEndsOfEdge` returns an array containing two vertices `[V, V]` if the edge exists in the
412
- * graph. If the edge does not exist, it returns `null`.
413
- */
414
- getEndsOfEdge(edge: E): [V, V] | null {
415
- if (!this.hasEdge(edge.src, edge.dest)) {
416
- return null;
417
- }
418
- const v1 = this._getVertex(edge.src);
419
- const v2 = this._getVertex(edge.dest);
420
- if (v1 && v2) {
421
- return [v1, v2];
422
- } else {
423
- return null;
424
- }
425
- }
426
-
427
- /**
428
- * The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertices exist.
429
- * @param {E} edge - The parameter `edge` is of type `E`, which represents an edge in a graph. It is the edge that
430
- * needs to be added to the graph.
431
- * @returns a boolean value. It returns true if the edge was successfully added to the graph, and false if either the
432
- * source or destination vertex does not exist in the graph.
433
- */
434
- protected _addEdgeOnly(edge: E): boolean {
435
- if (!(this.hasVertex(edge.src) && this.hasVertex(edge.dest))) {
436
- return false;
437
- }
438
-
439
- const srcVertex = this._getVertex(edge.src);
440
- const destVertex = this._getVertex(edge.dest);
441
-
442
- // TODO after no-non-null-assertion not ensure the logic
443
- if (srcVertex && destVertex) {
444
- const srcOutEdges = this._outEdgeMap.get(srcVertex);
445
- if (srcOutEdges) {
446
- srcOutEdges.push(edge);
447
- } else {
448
- this._outEdgeMap.set(srcVertex, [edge]);
449
- }
450
-
451
- const destInEdges = this._inEdgeMap.get(destVertex);
452
- if (destInEdges) {
453
- destInEdges.push(edge);
454
- } else {
455
- this._inEdgeMap.set(destVertex, [edge]);
456
- }
457
- return true;
458
- } else {
459
- return false;
460
- }
461
- }
462
-
463
- protected _setOutEdgeMap(value: Map<V, E[]>) {
464
- this._outEdgeMap = value;
465
- }
466
-
467
- protected _setInEdgeMap(value: Map<V, E[]>) {
468
- this._inEdgeMap = value;
469
- }
470
- }
@@ -1,4 +0,0 @@
1
- export * from './abstract-graph';
2
- export * from './directed-graph';
3
- export * from './undirected-graph';
4
- export * from './map-graph';
@@ -1,129 +0,0 @@
1
- import {MapGraphCoordinate, VertexId} from '../../types';
2
- import {DirectedEdge, DirectedGraph, DirectedVertex} from './directed-graph';
3
-
4
- export class MapVertex<T = any> extends DirectedVertex<T> {
5
- /**
6
- * The constructor function initializes an object with an id, latitude, longitude, and an optional value.
7
- * @param {VertexId} id - The `id` parameter is of type `VertexId` and represents the identifier of the vertex.
8
- * @param {number} lat - The "lat" parameter represents the latitude of a vertex. Latitude is a geographic coordinate
9
- * that specifies the north-south position of a point on the Earth's surface. It is measured in degrees, with positive
10
- * values representing points north of the equator and negative values representing points south of the equator.
11
- * @param {number} long - The "long" parameter represents the longitude of a location. Longitude is a geographic
12
- * coordinate that specifies the east-west position of a point on the Earth's surface. It is measured in degrees, with
13
- * values ranging from -180 to 180.
14
- * @param {T} [val] - The "val" parameter is an optional value of type T. It is not required to be provided when
15
- * creating an instance of the class.
16
- */
17
- constructor(id: VertexId, lat: number, long: number, val?: T) {
18
- super(id, val);
19
- this._lat = lat;
20
- this._long = long;
21
- }
22
-
23
- private _lat: number;
24
-
25
- get lat(): number {
26
- return this._lat;
27
- }
28
-
29
- set lat(value: number) {
30
- this._lat = value;
31
- }
32
-
33
- private _long: number;
34
-
35
- get long(): number {
36
- return this._long;
37
- }
38
-
39
- set long(value: number) {
40
- this._long = value;
41
- }
42
- }
43
-
44
- export class MapEdge<T = any> extends DirectedEdge<T> {
45
- /**
46
- * The constructor function initializes a new instance of a class with the given source, destination, weight, and
47
- * value.
48
- * @param {VertexId} src - The `src` parameter is the source vertex ID. It represents the starting point of an edge in
49
- * a graph.
50
- * @param {VertexId} dest - The `dest` parameter is the identifier of the destination vertex for an edge.
51
- * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
52
- * @param {T} [val] - The "val" parameter is an optional parameter of type T. It is used to store additional
53
- * information or data associated with the edge.
54
- */
55
- constructor(src: VertexId, dest: VertexId, weight?: number, val?: T) {
56
- super(src, dest, weight, val);
57
- }
58
- }
59
-
60
- export class MapGraph<V extends MapVertex<V['val']> = MapVertex, E extends MapEdge = MapEdge> extends DirectedGraph<
61
- V,
62
- E
63
- > {
64
- /**
65
- * The constructor function initializes the origin and bottomRight properties of a MapGraphCoordinate object.
66
- * @param {MapGraphCoordinate} origin - The `origin` parameter is a `MapGraphCoordinate` object that represents the
67
- * starting point or reference point of the map graph. It defines the coordinates of the top-left corner of the map
68
- * graph.
69
- * @param {MapGraphCoordinate} [bottomRight] - The `bottomRight` parameter is an optional parameter of type
70
- * `MapGraphCoordinate`. It represents the bottom right coordinate of a map graph. If this parameter is not provided,
71
- * it will default to `undefined`.
72
- */
73
- constructor(origin: MapGraphCoordinate, bottomRight?: MapGraphCoordinate) {
74
- super();
75
- this._origin = origin;
76
- this._bottomRight = bottomRight;
77
- }
78
-
79
- private _origin: MapGraphCoordinate = [0, 0];
80
-
81
- get origin(): MapGraphCoordinate {
82
- return this._origin;
83
- }
84
-
85
- set origin(value: MapGraphCoordinate) {
86
- this._origin = value;
87
- }
88
-
89
- private _bottomRight: MapGraphCoordinate | undefined;
90
-
91
- get bottomRight(): MapGraphCoordinate | undefined {
92
- return this._bottomRight;
93
- }
94
-
95
- set bottomRight(value: MapGraphCoordinate | undefined) {
96
- this._bottomRight = value;
97
- }
98
-
99
- /**
100
- * The function creates a new vertex with the given id, value, latitude, and longitude.
101
- * @param {VertexId} id - The id parameter is the unique identifier for the vertex. It is of type VertexId, which could
102
- * be a string or a number depending on how you define it in your code.
103
- * @param [val] - The `val` parameter is an optional value that can be assigned to the `val` property of the vertex. It
104
- * is of type `V['val']`, which means it should be of the same type as the `val` property of the vertex class `V`.
105
- * @param {number} lat - The `lat` parameter represents the latitude of the vertex. It is a number that specifies the
106
- * position of the vertex on the Earth's surface in the north-south direction.
107
- * @param {number} long - The `long` parameter represents the longitude coordinate of the vertex.
108
- * @returns The method is returning a new instance of the `MapVertex` class, casted as type `V`.
109
- */
110
- override createVertex(id: VertexId, val?: V['val'], lat: number = this.origin[0], long: number = this.origin[1]): V {
111
- return new MapVertex(id, lat, long, val) as V;
112
- }
113
-
114
- /**
115
- * The function creates a new instance of a MapEdge with the given source, destination, weight, and value.
116
- * @param {VertexId} src - The source vertex ID of the edge. It represents the starting point of the edge.
117
- * @param {VertexId} dest - The `dest` parameter is the identifier of the destination vertex for the edge being
118
- * created.
119
- * @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the edge. It
120
- * is used to assign a numerical value to the edge, which can be used in algorithms such as shortest path algorithms.
121
- * If the weight is not provided, it can be set to a default value or left undefined.
122
- * @param [val] - The `val` parameter is an optional value that can be assigned to the edge. It can be of any type,
123
- * depending on the specific implementation of the `MapEdge` class.
124
- * @returns a new instance of the `MapEdge` class, casted as type `E`.
125
- */
126
- override createEdge(src: VertexId, dest: VertexId, weight?: number, val?: E['val']): E {
127
- return new MapEdge(src, dest, weight, val) as E;
128
- }
129
- }