linked-list-typed 1.38.0 → 1.38.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.
Files changed (334) hide show
  1. package/dist/data-structures/binary-tree/avl-tree.d.ts +100 -0
  2. package/dist/data-structures/binary-tree/avl-tree.js +341 -0
  3. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +144 -0
  4. package/dist/data-structures/binary-tree/binary-indexed-tree.js +261 -0
  5. package/dist/data-structures/binary-tree/binary-tree.d.ts +409 -0
  6. package/dist/data-structures/binary-tree/binary-tree.js +1065 -0
  7. package/dist/data-structures/binary-tree/bst.d.ts +167 -0
  8. package/dist/data-structures/binary-tree/bst.js +512 -0
  9. package/dist/data-structures/binary-tree/index.d.ts +7 -0
  10. package/dist/data-structures/binary-tree/index.js +23 -0
  11. package/dist/data-structures/binary-tree/rb-tree.d.ts +13 -0
  12. package/dist/data-structures/binary-tree/rb-tree.js +27 -0
  13. package/dist/data-structures/binary-tree/segment-tree.d.ts +83 -0
  14. package/dist/data-structures/binary-tree/segment-tree.js +228 -0
  15. package/dist/data-structures/binary-tree/tree-multiset.d.ts +122 -0
  16. package/dist/data-structures/binary-tree/tree-multiset.js +351 -0
  17. package/dist/data-structures/graph/abstract-graph.d.ts +332 -0
  18. package/dist/data-structures/graph/abstract-graph.js +923 -0
  19. package/dist/data-structures/graph/directed-graph.d.ts +200 -0
  20. package/dist/data-structures/graph/directed-graph.js +422 -0
  21. package/dist/data-structures/graph/index.d.ts +4 -0
  22. package/dist/data-structures/graph/index.js +20 -0
  23. package/dist/data-structures/graph/map-graph.d.ts +79 -0
  24. package/dist/data-structures/graph/map-graph.js +111 -0
  25. package/dist/data-structures/graph/undirected-graph.d.ts +127 -0
  26. package/dist/data-structures/graph/undirected-graph.js +252 -0
  27. package/dist/data-structures/hash/coordinate-map.d.ts +45 -0
  28. package/dist/data-structures/hash/coordinate-map.js +65 -0
  29. package/dist/data-structures/hash/coordinate-set.d.ts +37 -0
  30. package/dist/data-structures/hash/coordinate-set.js +55 -0
  31. package/dist/data-structures/hash/hash-map.d.ts +56 -0
  32. package/dist/data-structures/hash/hash-map.js +171 -0
  33. package/dist/data-structures/hash/hash-table.d.ts +106 -0
  34. package/dist/data-structures/hash/hash-table.js +245 -0
  35. package/dist/data-structures/hash/index.d.ts +6 -0
  36. package/dist/data-structures/hash/index.js +22 -0
  37. package/dist/data-structures/hash/tree-map.d.ts +2 -0
  38. package/dist/data-structures/hash/tree-map.js +6 -0
  39. package/dist/data-structures/hash/tree-set.d.ts +2 -0
  40. package/dist/data-structures/hash/tree-set.js +6 -0
  41. package/dist/data-structures/heap/heap.d.ts +224 -0
  42. package/dist/data-structures/heap/heap.js +497 -0
  43. package/dist/data-structures/heap/index.d.ts +3 -0
  44. package/dist/data-structures/heap/index.js +19 -0
  45. package/dist/data-structures/heap/max-heap.d.ts +12 -0
  46. package/dist/data-structures/heap/max-heap.js +24 -0
  47. package/dist/data-structures/heap/min-heap.d.ts +12 -0
  48. package/dist/data-structures/heap/min-heap.js +24 -0
  49. package/dist/data-structures/index.d.ts +11 -0
  50. package/dist/data-structures/index.js +27 -0
  51. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +234 -0
  52. package/dist/data-structures/linked-list/doubly-linked-list.js +583 -0
  53. package/dist/data-structures/linked-list/index.d.ts +3 -0
  54. package/dist/data-structures/linked-list/index.js +19 -0
  55. package/dist/data-structures/linked-list/singly-linked-list.d.ts +157 -0
  56. package/dist/data-structures/linked-list/singly-linked-list.js +448 -0
  57. package/dist/data-structures/linked-list/skip-linked-list.d.ts +61 -0
  58. package/dist/data-structures/linked-list/skip-linked-list.js +142 -0
  59. package/dist/data-structures/matrix/index.d.ts +4 -0
  60. package/dist/data-structures/matrix/index.js +20 -0
  61. package/dist/data-structures/matrix/matrix.d.ts +21 -0
  62. package/dist/data-structures/matrix/matrix.js +28 -0
  63. package/dist/data-structures/matrix/matrix2d.d.ts +108 -0
  64. package/dist/data-structures/matrix/matrix2d.js +203 -0
  65. package/dist/data-structures/matrix/navigator.d.ts +52 -0
  66. package/dist/data-structures/matrix/navigator.js +106 -0
  67. package/dist/data-structures/matrix/vector2d.d.ts +201 -0
  68. package/dist/data-structures/matrix/vector2d.js +291 -0
  69. package/dist/data-structures/priority-queue/index.d.ts +3 -0
  70. package/dist/data-structures/priority-queue/index.js +19 -0
  71. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +12 -0
  72. package/dist/data-structures/priority-queue/max-priority-queue.js +24 -0
  73. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +12 -0
  74. package/dist/data-structures/priority-queue/min-priority-queue.js +24 -0
  75. package/dist/data-structures/priority-queue/priority-queue.d.ts +12 -0
  76. package/dist/data-structures/priority-queue/priority-queue.js +17 -0
  77. package/dist/data-structures/queue/deque.d.ts +165 -0
  78. package/dist/data-structures/queue/deque.js +276 -0
  79. package/dist/data-structures/queue/index.d.ts +2 -0
  80. package/dist/data-structures/queue/index.js +18 -0
  81. package/dist/data-structures/queue/queue.d.ts +107 -0
  82. package/dist/data-structures/queue/queue.js +170 -0
  83. package/dist/data-structures/stack/index.d.ts +1 -0
  84. package/dist/data-structures/stack/index.js +17 -0
  85. package/dist/data-structures/stack/stack.d.ts +63 -0
  86. package/dist/data-structures/stack/stack.js +91 -0
  87. package/dist/data-structures/tree/index.d.ts +1 -0
  88. package/dist/data-structures/tree/index.js +17 -0
  89. package/dist/data-structures/tree/tree.d.ts +14 -0
  90. package/dist/data-structures/tree/tree.js +58 -0
  91. package/dist/data-structures/trie/index.d.ts +1 -0
  92. package/dist/data-structures/trie/index.js +17 -0
  93. package/dist/data-structures/trie/trie.d.ts +84 -0
  94. package/dist/data-structures/trie/trie.js +268 -0
  95. package/dist/index.d.ts +3 -3
  96. package/dist/index.js +3 -3
  97. package/dist/interfaces/binary-tree.d.ts +7 -0
  98. package/dist/interfaces/binary-tree.js +2 -0
  99. package/dist/interfaces/doubly-linked-list.d.ts +1 -0
  100. package/dist/interfaces/doubly-linked-list.js +2 -0
  101. package/dist/interfaces/graph.d.ts +5 -0
  102. package/dist/interfaces/graph.js +2 -0
  103. package/dist/interfaces/heap.d.ts +1 -0
  104. package/dist/interfaces/heap.js +2 -0
  105. package/dist/interfaces/index.d.ts +8 -0
  106. package/dist/interfaces/index.js +24 -0
  107. package/dist/interfaces/navigator.d.ts +1 -0
  108. package/dist/interfaces/navigator.js +2 -0
  109. package/dist/interfaces/priority-queue.d.ts +1 -0
  110. package/dist/interfaces/priority-queue.js +2 -0
  111. package/dist/interfaces/segment-tree.d.ts +1 -0
  112. package/dist/interfaces/segment-tree.js +2 -0
  113. package/dist/interfaces/singly-linked-list.d.ts +1 -0
  114. package/dist/interfaces/singly-linked-list.js +2 -0
  115. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +4 -0
  116. package/dist/types/data-structures/binary-tree/avl-tree.js +2 -0
  117. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +1 -0
  118. package/dist/types/data-structures/binary-tree/binary-indexed-tree.js +2 -0
  119. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +31 -0
  120. package/dist/types/data-structures/binary-tree/binary-tree.js +24 -0
  121. package/dist/types/data-structures/binary-tree/bst.d.ts +7 -0
  122. package/dist/types/data-structures/binary-tree/bst.js +2 -0
  123. package/dist/types/data-structures/binary-tree/index.d.ts +6 -0
  124. package/dist/types/data-structures/binary-tree/index.js +22 -0
  125. package/dist/types/data-structures/binary-tree/rb-tree.d.ts +8 -0
  126. package/dist/types/data-structures/binary-tree/rb-tree.js +8 -0
  127. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +1 -0
  128. package/dist/types/data-structures/binary-tree/segment-tree.js +2 -0
  129. package/dist/types/data-structures/binary-tree/tree-multiset.d.ts +4 -0
  130. package/dist/types/data-structures/binary-tree/tree-multiset.js +2 -0
  131. package/dist/types/data-structures/graph/abstract-graph.d.ts +10 -0
  132. package/dist/types/data-structures/graph/abstract-graph.js +2 -0
  133. package/dist/types/data-structures/graph/directed-graph.d.ts +6 -0
  134. package/dist/types/data-structures/graph/directed-graph.js +9 -0
  135. package/dist/types/data-structures/graph/index.d.ts +3 -0
  136. package/dist/types/data-structures/graph/index.js +19 -0
  137. package/dist/types/data-structures/graph/map-graph.d.ts +1 -0
  138. package/dist/types/data-structures/graph/map-graph.js +2 -0
  139. package/dist/types/data-structures/graph/undirected-graph.d.ts +1 -0
  140. package/dist/types/data-structures/graph/undirected-graph.js +2 -0
  141. package/dist/types/data-structures/hash/coordinate-map.d.ts +1 -0
  142. package/dist/types/data-structures/hash/coordinate-map.js +2 -0
  143. package/dist/types/data-structures/hash/coordinate-set.d.ts +1 -0
  144. package/dist/types/data-structures/hash/coordinate-set.js +2 -0
  145. package/dist/types/data-structures/hash/hash-map.d.ts +1 -0
  146. package/dist/types/data-structures/hash/hash-map.js +2 -0
  147. package/dist/types/data-structures/hash/hash-table.d.ts +1 -0
  148. package/dist/types/data-structures/hash/hash-table.js +2 -0
  149. package/dist/types/data-structures/hash/index.d.ts +1 -0
  150. package/dist/types/data-structures/hash/index.js +2 -0
  151. package/dist/types/data-structures/hash/tree-map.d.ts +1 -0
  152. package/dist/types/data-structures/hash/tree-map.js +2 -0
  153. package/dist/types/data-structures/hash/tree-set.d.ts +1 -0
  154. package/dist/types/data-structures/hash/tree-set.js +2 -0
  155. package/dist/types/data-structures/heap/heap.d.ts +1 -0
  156. package/dist/types/data-structures/heap/heap.js +2 -0
  157. package/dist/types/data-structures/heap/index.d.ts +1 -0
  158. package/dist/types/data-structures/heap/index.js +17 -0
  159. package/dist/types/data-structures/heap/max-heap.d.ts +1 -0
  160. package/dist/types/data-structures/heap/max-heap.js +2 -0
  161. package/dist/types/data-structures/heap/min-heap.d.ts +1 -0
  162. package/dist/types/data-structures/heap/min-heap.js +2 -0
  163. package/dist/types/data-structures/index.d.ts +11 -0
  164. package/dist/types/data-structures/index.js +27 -0
  165. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +1 -0
  166. package/dist/types/data-structures/linked-list/doubly-linked-list.js +2 -0
  167. package/dist/types/data-structures/linked-list/index.d.ts +2 -0
  168. package/dist/types/data-structures/linked-list/index.js +18 -0
  169. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +1 -0
  170. package/dist/types/data-structures/linked-list/singly-linked-list.js +2 -0
  171. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +1 -0
  172. package/dist/types/data-structures/linked-list/skip-linked-list.js +2 -0
  173. package/dist/types/data-structures/matrix/index.d.ts +1 -0
  174. package/dist/types/data-structures/matrix/index.js +17 -0
  175. package/dist/types/data-structures/matrix/matrix.d.ts +1 -0
  176. package/dist/types/data-structures/matrix/matrix.js +2 -0
  177. package/dist/types/data-structures/matrix/matrix2d.d.ts +1 -0
  178. package/dist/types/data-structures/matrix/matrix2d.js +2 -0
  179. package/dist/types/data-structures/matrix/navigator.d.ts +14 -0
  180. package/dist/types/data-structures/matrix/navigator.js +2 -0
  181. package/dist/types/data-structures/matrix/vector2d.d.ts +1 -0
  182. package/dist/types/data-structures/matrix/vector2d.js +2 -0
  183. package/dist/types/data-structures/priority-queue/index.d.ts +3 -0
  184. package/dist/types/data-structures/priority-queue/index.js +19 -0
  185. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -0
  186. package/dist/types/data-structures/priority-queue/max-priority-queue.js +2 -0
  187. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +1 -0
  188. package/dist/types/data-structures/priority-queue/min-priority-queue.js +2 -0
  189. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
  190. package/dist/types/data-structures/priority-queue/priority-queue.js +2 -0
  191. package/dist/types/data-structures/queue/deque.d.ts +1 -0
  192. package/dist/types/data-structures/queue/deque.js +2 -0
  193. package/dist/types/data-structures/queue/index.d.ts +2 -0
  194. package/dist/types/data-structures/queue/index.js +18 -0
  195. package/dist/types/data-structures/queue/queue.d.ts +1 -0
  196. package/dist/types/data-structures/queue/queue.js +2 -0
  197. package/dist/types/data-structures/stack/index.d.ts +1 -0
  198. package/dist/types/data-structures/stack/index.js +17 -0
  199. package/dist/types/data-structures/stack/stack.d.ts +1 -0
  200. package/dist/types/data-structures/stack/stack.js +2 -0
  201. package/dist/types/data-structures/tree/index.d.ts +1 -0
  202. package/dist/types/data-structures/tree/index.js +17 -0
  203. package/dist/types/data-structures/tree/tree.d.ts +1 -0
  204. package/dist/types/data-structures/tree/tree.js +2 -0
  205. package/dist/types/data-structures/trie/index.d.ts +1 -0
  206. package/dist/types/data-structures/trie/index.js +17 -0
  207. package/dist/types/data-structures/trie/trie.d.ts +1 -0
  208. package/dist/types/data-structures/trie/trie.js +2 -0
  209. package/dist/types/helpers.d.ts +9 -0
  210. package/dist/types/helpers.js +9 -0
  211. package/dist/types/index.d.ts +3 -0
  212. package/dist/types/index.js +19 -0
  213. package/dist/types/utils/index.d.ts +2 -0
  214. package/dist/types/utils/index.js +18 -0
  215. package/dist/types/utils/utils.d.ts +7 -0
  216. package/dist/types/utils/utils.js +2 -0
  217. package/dist/types/utils/validate-type.d.ts +19 -0
  218. package/dist/types/utils/validate-type.js +2 -0
  219. package/dist/utils/index.d.ts +1 -0
  220. package/dist/utils/index.js +17 -0
  221. package/dist/utils/utils.d.ts +20 -0
  222. package/dist/utils/utils.js +73 -0
  223. package/package.json +1 -4
  224. package/src/data-structures/binary-tree/avl-tree.ts +342 -0
  225. package/src/data-structures/binary-tree/binary-indexed-tree.ts +298 -0
  226. package/src/data-structures/binary-tree/binary-tree.ts +1141 -0
  227. package/src/data-structures/binary-tree/bst.ts +529 -0
  228. package/src/data-structures/binary-tree/index.ts +7 -0
  229. package/src/data-structures/binary-tree/rb-tree.ts +366 -0
  230. package/src/data-structures/binary-tree/segment-tree.ts +257 -0
  231. package/src/data-structures/binary-tree/tree-multiset.ts +374 -0
  232. package/src/data-structures/graph/abstract-graph.ts +1043 -0
  233. package/src/data-structures/graph/directed-graph.ts +469 -0
  234. package/src/data-structures/graph/index.ts +4 -0
  235. package/src/data-structures/graph/map-graph.ts +134 -0
  236. package/src/data-structures/graph/undirected-graph.ts +273 -0
  237. package/src/data-structures/hash/coordinate-map.ts +67 -0
  238. package/src/data-structures/hash/coordinate-set.ts +56 -0
  239. package/src/data-structures/hash/hash-map.ts +209 -0
  240. package/src/data-structures/hash/hash-table.ts +280 -0
  241. package/src/data-structures/hash/index.ts +6 -0
  242. package/src/data-structures/hash/tree-map.ts +2 -0
  243. package/src/data-structures/hash/tree-set.ts +2 -0
  244. package/src/data-structures/heap/heap.ts +561 -0
  245. package/src/data-structures/heap/index.ts +3 -0
  246. package/src/data-structures/heap/max-heap.ts +24 -0
  247. package/src/data-structures/heap/min-heap.ts +24 -0
  248. package/src/data-structures/index.ts +11 -0
  249. package/src/data-structures/linked-list/doubly-linked-list.ts +636 -0
  250. package/src/data-structures/linked-list/index.ts +3 -0
  251. package/src/data-structures/linked-list/singly-linked-list.ts +501 -0
  252. package/src/data-structures/linked-list/skip-linked-list.ts +173 -0
  253. package/src/data-structures/matrix/index.ts +4 -0
  254. package/src/data-structures/matrix/matrix.ts +27 -0
  255. package/src/data-structures/matrix/matrix2d.ts +213 -0
  256. package/src/data-structures/matrix/navigator.ts +121 -0
  257. package/src/data-structures/matrix/vector2d.ts +317 -0
  258. package/src/data-structures/priority-queue/index.ts +3 -0
  259. package/src/data-structures/priority-queue/max-priority-queue.ts +23 -0
  260. package/src/data-structures/priority-queue/min-priority-queue.ts +23 -0
  261. package/src/data-structures/priority-queue/priority-queue.ts +16 -0
  262. package/src/data-structures/queue/deque.ts +298 -0
  263. package/src/data-structures/queue/index.ts +2 -0
  264. package/src/data-structures/queue/queue.ts +191 -0
  265. package/src/data-structures/stack/index.ts +1 -0
  266. package/src/data-structures/stack/stack.ts +98 -0
  267. package/src/data-structures/tree/index.ts +1 -0
  268. package/src/data-structures/tree/tree.ts +67 -0
  269. package/src/data-structures/trie/index.ts +1 -0
  270. package/src/data-structures/trie/trie.ts +286 -0
  271. package/src/index.ts +3 -3
  272. package/src/interfaces/binary-tree.ts +10 -0
  273. package/src/interfaces/doubly-linked-list.ts +1 -0
  274. package/src/interfaces/graph.ts +7 -0
  275. package/src/interfaces/heap.ts +1 -0
  276. package/src/interfaces/index.ts +8 -0
  277. package/src/interfaces/navigator.ts +1 -0
  278. package/src/interfaces/priority-queue.ts +1 -0
  279. package/src/interfaces/segment-tree.ts +1 -0
  280. package/src/interfaces/singly-linked-list.ts +1 -0
  281. package/src/types/data-structures/binary-tree/avl-tree.ts +5 -0
  282. package/src/types/data-structures/binary-tree/binary-indexed-tree.ts +1 -0
  283. package/src/types/data-structures/binary-tree/binary-tree.ts +35 -0
  284. package/src/types/data-structures/binary-tree/bst.ts +11 -0
  285. package/src/types/data-structures/binary-tree/index.ts +6 -0
  286. package/src/types/data-structures/binary-tree/rb-tree.ts +8 -0
  287. package/src/types/data-structures/binary-tree/segment-tree.ts +1 -0
  288. package/src/types/data-structures/binary-tree/tree-multiset.ts +6 -0
  289. package/src/types/data-structures/graph/abstract-graph.ts +11 -0
  290. package/src/types/data-structures/graph/directed-graph.ts +8 -0
  291. package/src/types/data-structures/graph/index.ts +3 -0
  292. package/src/types/data-structures/graph/map-graph.ts +1 -0
  293. package/src/types/data-structures/graph/undirected-graph.ts +1 -0
  294. package/src/types/data-structures/hash/coordinate-map.ts +1 -0
  295. package/src/types/data-structures/hash/coordinate-set.ts +1 -0
  296. package/src/types/data-structures/hash/hash-map.ts +1 -0
  297. package/src/types/data-structures/hash/hash-table.ts +1 -0
  298. package/src/types/data-structures/hash/index.ts +1 -0
  299. package/src/types/data-structures/hash/tree-map.ts +1 -0
  300. package/src/types/data-structures/hash/tree-set.ts +1 -0
  301. package/src/types/data-structures/heap/heap.ts +1 -0
  302. package/src/types/data-structures/heap/index.ts +1 -0
  303. package/src/types/data-structures/heap/max-heap.ts +1 -0
  304. package/src/types/data-structures/heap/min-heap.ts +1 -0
  305. package/src/types/data-structures/index.ts +11 -0
  306. package/src/types/data-structures/linked-list/doubly-linked-list.ts +1 -0
  307. package/src/types/data-structures/linked-list/index.ts +2 -0
  308. package/src/types/data-structures/linked-list/singly-linked-list.ts +1 -0
  309. package/src/types/data-structures/linked-list/skip-linked-list.ts +1 -0
  310. package/src/types/data-structures/matrix/index.ts +1 -0
  311. package/src/types/data-structures/matrix/matrix.ts +1 -0
  312. package/src/types/data-structures/matrix/matrix2d.ts +1 -0
  313. package/src/types/data-structures/matrix/navigator.ts +14 -0
  314. package/src/types/data-structures/matrix/vector2d.ts +1 -0
  315. package/src/types/data-structures/priority-queue/index.ts +3 -0
  316. package/src/types/data-structures/priority-queue/max-priority-queue.ts +1 -0
  317. package/src/types/data-structures/priority-queue/min-priority-queue.ts +1 -0
  318. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
  319. package/src/types/data-structures/queue/deque.ts +1 -0
  320. package/src/types/data-structures/queue/index.ts +2 -0
  321. package/src/types/data-structures/queue/queue.ts +1 -0
  322. package/src/types/data-structures/stack/index.ts +1 -0
  323. package/src/types/data-structures/stack/stack.ts +1 -0
  324. package/src/types/data-structures/tree/index.ts +1 -0
  325. package/src/types/data-structures/tree/tree.ts +1 -0
  326. package/src/types/data-structures/trie/index.ts +1 -0
  327. package/src/types/data-structures/trie/trie.ts +1 -0
  328. package/src/types/helpers.ts +13 -0
  329. package/src/types/index.ts +3 -0
  330. package/src/types/utils/index.ts +2 -0
  331. package/src/types/utils/utils.ts +6 -0
  332. package/src/types/utils/validate-type.ts +35 -0
  333. package/src/utils/index.ts +1 -0
  334. package/src/utils/utils.ts +86 -0
@@ -0,0 +1,332 @@
1
+ import type { DijkstraResult, VertexKey } from '../../types';
2
+ import { IGraph } from '../../interfaces';
3
+ export declare abstract class AbstractVertex<V = any> {
4
+ /**
5
+ * The function is a protected constructor that takes an key and an optional value as parameters.
6
+ * @param {VertexKey} key - The `key` parameter is of type `VertexKey` and represents the identifier of the vertex. It is
7
+ * used to uniquely identify the vertex object.
8
+ * @param {V} [val] - The parameter "val" is an optional parameter of type V. It is used to assign a value to the
9
+ * vertex. If no value is provided, it will be set to undefined.
10
+ */
11
+ protected constructor(key: VertexKey, val?: V);
12
+ private _key;
13
+ get key(): VertexKey;
14
+ set key(v: VertexKey);
15
+ private _val;
16
+ get val(): V | undefined;
17
+ set val(value: V | undefined);
18
+ }
19
+ export declare abstract class AbstractEdge<V = any> {
20
+ /**
21
+ * The above function is a protected constructor that initializes the weight, value, and hash code properties of an
22
+ * object.
23
+ * @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the object. If
24
+ * a value is provided, it will be assigned to the `_weight` property. If no value is provided, the default value of 1
25
+ * will be assigned.
26
+ * @param {V} [val] - The `val` parameter is of type `V`, which means it can be any type. It is an optional parameter,
27
+ * meaning it can be omitted when creating an instance of the class.
28
+ */
29
+ protected constructor(weight?: number, val?: V);
30
+ private _val;
31
+ get val(): V | undefined;
32
+ set val(value: V | undefined);
33
+ private _weight;
34
+ get weight(): number;
35
+ set weight(v: number);
36
+ protected _hashCode: string;
37
+ get hashCode(): string;
38
+ /**
39
+ * 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.
40
+ * 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.
41
+ */
42
+ /**
43
+ * The function sets the value of the _hashCode property to the provided string.
44
+ * @param {string} v - The parameter "v" is of type string and represents the value that will be assigned to the
45
+ * "_hashCode" property.
46
+ */
47
+ protected _setHashCode(v: string): void;
48
+ }
49
+ export declare abstract class AbstractGraph<V extends AbstractVertex<any> = AbstractVertex<any>, E extends AbstractEdge<any> = AbstractEdge<any>> implements IGraph<V, E> {
50
+ private _vertices;
51
+ get vertices(): Map<VertexKey, V>;
52
+ /**
53
+ * 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.
54
+ * 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.
55
+ * @param key
56
+ * @param val
57
+ */
58
+ abstract createVertex(key: VertexKey, val?: V): V;
59
+ /**
60
+ * 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.
61
+ * 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.
62
+ * @param srcOrV1
63
+ * @param destOrV2
64
+ * @param weight
65
+ * @param val
66
+ */
67
+ abstract createEdge(srcOrV1: VertexKey | string, destOrV2: VertexKey | string, weight?: number, val?: E): E;
68
+ abstract removeEdge(edge: E): E | null;
69
+ abstract getEdge(srcOrKey: V | VertexKey, destOrKey: V | VertexKey): E | null;
70
+ abstract degreeOf(vertexOrKey: V | VertexKey): number;
71
+ abstract edgeSet(): E[];
72
+ abstract edgesOf(vertexOrKey: V | VertexKey): E[];
73
+ abstract getNeighbors(vertexOrKey: V | VertexKey): V[];
74
+ abstract getEndsOfEdge(edge: E): [V, V] | null;
75
+ /**
76
+ * The function "getVertex" returns the vertex with the specified ID or null if it doesn't exist.
77
+ * @param {VertexKey} vertexKey - The `vertexKey` parameter is the identifier of the vertex that you want to retrieve from
78
+ * the `_vertices` map.
79
+ * @returns The method `getVertex` returns the vertex with the specified `vertexKey` if it exists in the `_vertices`
80
+ * map. If the vertex does not exist, it returns `null`.
81
+ */
82
+ getVertex(vertexKey: VertexKey): V | null;
83
+ /**
84
+ * The function checks if a vertex exists in a graph.
85
+ * @param {V | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`V`) or a vertex ID
86
+ * (`VertexKey`).
87
+ * @returns a boolean value.
88
+ */
89
+ hasVertex(vertexOrKey: V | VertexKey): boolean;
90
+ addVertex(vertex: V): boolean;
91
+ addVertex(key: VertexKey, val?: V['val']): boolean;
92
+ /**
93
+ * The `removeVertex` function removes a vertex from a graph by its ID or by the vertex object itself.
94
+ * @param {V | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`V`) or a vertex ID
95
+ * (`VertexKey`).
96
+ * @returns The method is returning a boolean value.
97
+ */
98
+ removeVertex(vertexOrKey: V | VertexKey): boolean;
99
+ /**
100
+ * The function removes all vertices from a graph and returns a boolean indicating if any vertices were removed.
101
+ * @param {V[] | VertexKey[]} vertices - The `vertices` parameter can be either an array of vertices (`V[]`) or an array
102
+ * of vertex IDs (`VertexKey[]`).
103
+ * @returns a boolean value. It returns true if at least one vertex was successfully removed, and false if no vertices
104
+ * were removed.
105
+ */
106
+ removeAllVertices(vertices: V[] | VertexKey[]): boolean;
107
+ /**
108
+ * The function checks if there is an edge between two vertices and returns a boolean value indicating the result.
109
+ * @param {VertexKey | V} v1 - The parameter v1 can be either a VertexKey or a V. A VertexKey represents the unique
110
+ * identifier of a vertex in a graph, while V represents the type of the vertex object itself.
111
+ * @param {VertexKey | V} v2 - The parameter `v2` represents the second vertex in the edge. It can be either a
112
+ * `VertexKey` or a `V` type, which represents the type of the vertex.
113
+ * @returns A boolean value is being returned.
114
+ */
115
+ hasEdge(v1: VertexKey | V, v2: VertexKey | V): boolean;
116
+ addEdge(edge: E): boolean;
117
+ addEdge(src: V | VertexKey, dest: V | VertexKey, weight?: number, val?: E['val']): boolean;
118
+ /**
119
+ * The function sets the weight of an edge between two vertices in a graph.
120
+ * @param {VertexKey | V} srcOrKey - The `srcOrKey` parameter can be either a `VertexKey` or a `V` object. It represents
121
+ * the source vertex of the edge.
122
+ * @param {VertexKey | V} destOrKey - The `destOrKey` parameter represents the destination vertex of the edge. It can be
123
+ * either a `VertexKey` or a vertex object `V`.
124
+ * @param {number} weight - The weight parameter represents the weight of the edge between the source vertex (srcOrKey)
125
+ * and the destination vertex (destOrKey).
126
+ * @returns a boolean value. If the edge exists between the source and destination vertices, the function will update
127
+ * the weight of the edge and return true. If the edge does not exist, the function will return false.
128
+ */
129
+ setEdgeWeight(srcOrKey: VertexKey | V, destOrKey: VertexKey | V, weight: number): boolean;
130
+ /**
131
+ * The function `getAllPathsBetween` finds all paths between two vertices in a graph using depth-first search.
132
+ * @param {V | VertexKey} v1 - The parameter `v1` represents either a vertex object (`V`) or a vertex ID (`VertexKey`).
133
+ * It is the starting vertex for finding paths.
134
+ * @param {V | VertexKey} v2 - The parameter `v2` represents either a vertex object (`V`) or a vertex ID (`VertexKey`).
135
+ * @returns The function `getAllPathsBetween` returns an array of arrays of vertices (`V[][]`).
136
+ */
137
+ getAllPathsBetween(v1: V | VertexKey, v2: V | VertexKey): V[][];
138
+ /**
139
+ * The function calculates the sum of weights along a given path.
140
+ * @param {V[]} path - An array of vertices (V) representing a path in a graph.
141
+ * @returns The function `getPathSumWeight` returns the sum of the weights of the edges in the given path.
142
+ */
143
+ getPathSumWeight(path: V[]): number;
144
+ /**
145
+ * The function `getMinCostBetween` calculates the minimum cost between two vertices in a graph, either based on edge
146
+ * weights or using a breadth-first search algorithm.
147
+ * @param {V | VertexKey} v1 - The parameter `v1` represents the starting vertex or its ID.
148
+ * @param {V | VertexKey} v2 - The parameter `v2` represents the destination vertex or its ID. It is the vertex to which
149
+ * you want to find the minimum cost or weight from the source vertex `v1`.
150
+ * @param {boolean} [isWeight] - isWeight is an optional parameter that indicates whether the graph edges have weights.
151
+ * If isWeight is set to true, the function will calculate the minimum cost between v1 and v2 based on the weights of
152
+ * the edges. If isWeight is set to false or not provided, the function will calculate the
153
+ * @returns The function `getMinCostBetween` returns a number representing the minimum cost between two vertices (`v1`
154
+ * and `v2`). If the `isWeight` parameter is `true`, it calculates the minimum weight among all paths between the
155
+ * vertices. If `isWeight` is `false` or not provided, it uses a breadth-first search (BFS) algorithm to calculate the
156
+ * minimum number of
157
+ */
158
+ getMinCostBetween(v1: V | VertexKey, v2: V | VertexKey, isWeight?: boolean): number | null;
159
+ /**
160
+ * The function `getMinPathBetween` returns the minimum path between two vertices in a graph, either based on weight or
161
+ * using a breadth-first search algorithm.
162
+ * @param {V | VertexKey} v1 - The parameter `v1` represents the starting vertex of the path. It can be either a vertex
163
+ * object (`V`) or a vertex ID (`VertexKey`).
164
+ * @param {V | VertexKey} v2 - V | VertexKey - The second vertex or vertex ID between which we want to find the minimum
165
+ * path.
166
+ * @param {boolean} [isWeight] - A boolean flag indicating whether to consider the weight of edges in finding the
167
+ * minimum path. If set to true, the function will use Dijkstra's algorithm to find the minimum weighted path. If set
168
+ * to false, the function will use breadth-first search (BFS) to find the minimum path.
169
+ * @returns The function `getMinPathBetween` returns an array of vertices (`V[]`) representing the minimum path between
170
+ * two vertices (`v1` and `v2`). If there is no path between the vertices, it returns `null`.
171
+ */
172
+ getMinPathBetween(v1: V | VertexKey, v2: V | VertexKey, isWeight?: boolean): V[] | null;
173
+ /**
174
+ * Dijkstra algorithm time: O(VE) space: O(V + E)
175
+ * /
176
+
177
+ /**
178
+ * Dijkstra algorithm time: O(VE) space: O(V + E)
179
+ * The function `dijkstraWithoutHeap` implements Dijkstra's algorithm to find the shortest path between two vertices in
180
+ * a graph without using a heap data structure.
181
+ * @param {V | VertexKey} src - The source vertex from which to start the Dijkstra's algorithm. It can be either a
182
+ * vertex object or a vertex ID.
183
+ * @param {V | VertexKey | null} [dest] - The `dest` parameter in the `dijkstraWithoutHeap` function is an optional
184
+ * parameter that specifies the destination vertex for the Dijkstra algorithm. It can be either a vertex object or its
185
+ * identifier. If no destination is provided, the value is set to `null`.
186
+ * @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum
187
+ * distance from the source vertex to the destination vertex should be calculated and returned in the result. If
188
+ * `getMinDist` is set to `true`, the `minDist` property in the result will contain the minimum distance
189
+ * @param {boolean} [genPaths] - The `genPaths` parameter is a boolean flag that determines whether or not to generate
190
+ * paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
191
+ * shortest paths from the source vertex to all other vertices in the graph. If `genPaths
192
+ * @returns The function `dijkstraWithoutHeap` returns an object of type `DijkstraResult<V>`.
193
+ */
194
+ dijkstraWithoutHeap(src: V | VertexKey, dest?: V | VertexKey | null, getMinDist?: boolean, genPaths?: boolean): DijkstraResult<V>;
195
+ /**
196
+ * Dijkstra algorithm time: O(logVE) space: O(V + E)
197
+ *
198
+ * Dijkstra's algorithm only solves the single-source shortest path problem, while the Bellman-Ford algorithm and Floyd-Warshall algorithm can address shortest paths between all pairs of nodes.
199
+ * Dijkstra's algorithm is suitable for graphs with non-negative edge weights, whereas the Bellman-Ford algorithm and Floyd-Warshall algorithm can handle negative-weight edges.
200
+ * The time complexity of Dijkstra's algorithm and the Bellman-Ford algorithm depends on the size of the graph, while the time complexity of the Floyd-Warshall algorithm is O(V^3), where V is the number of nodes. For dense graphs, Floyd-Warshall might become slower.
201
+ *
202
+ * /
203
+
204
+ /**
205
+ * Dijkstra's algorithm is used to find the shortest paths from a source node to all other nodes in a graph. Its basic idea is to repeatedly choose the node closest to the source node and update the distances of other nodes using this node as an intermediary. Dijkstra's algorithm requires that the edge weights in the graph are non-negative.
206
+ * The `dijkstra` function implements Dijkstra's algorithm to find the shortest path between a source vertex and an
207
+ * optional destination vertex, and optionally returns the minimum distance, the paths, and other information.
208
+ * @param {V | VertexKey} src - The `src` parameter represents the source vertex from which the Dijkstra algorithm will
209
+ * start. It can be either a vertex object or a vertex ID.
210
+ * @param {V | VertexKey | null} [dest] - The `dest` parameter is the destination vertex or vertex ID. It specifies the
211
+ * vertex to which the shortest path is calculated from the source vertex. If no destination is provided, the algorithm
212
+ * will calculate the shortest paths to all other vertices from the source vertex.
213
+ * @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum
214
+ * distance from the source vertex to the destination vertex should be calculated and returned in the result. If
215
+ * `getMinDist` is set to `true`, the `minDist` property in the result will contain the minimum distance
216
+ * @param {boolean} [genPaths] - The `genPaths` parameter is a boolean flag that determines whether or not to generate
217
+ * paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
218
+ * shortest paths from the source vertex to all other vertices in the graph. If `genPaths
219
+ * @returns The function `dijkstra` returns an object of type `DijkstraResult<V>`.
220
+ */
221
+ dijkstra(src: V | VertexKey, dest?: V | VertexKey | null, getMinDist?: boolean, genPaths?: boolean): DijkstraResult<V>;
222
+ /**
223
+ * BellmanFord time:O(VE) space:O(V)
224
+ * one to rest pairs
225
+ * /
226
+
227
+ /**
228
+ * BellmanFord time:O(VE) space:O(V)
229
+ * one to rest pairs
230
+ * The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edges for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edges, the Bellman-Ford algorithm is more flexible in some scenarios.
231
+ * The `bellmanFord` function implements the Bellman-Ford algorithm to find the shortest path from a source vertex to
232
+ * all other vertices in a graph, and optionally detects negative cycles and generates the minimum path.
233
+ * @param {V | VertexKey} src - The `src` parameter is the source vertex from which the Bellman-Ford algorithm will
234
+ * start calculating the shortest paths. It can be either a vertex object or a vertex ID.
235
+ * @param {boolean} [scanNegativeCycle] - A boolean flag indicating whether to scan for negative cycles in the graph.
236
+ * @param {boolean} [getMin] - The `getMin` parameter is a boolean flag that determines whether the algorithm should
237
+ * calculate the minimum distance from the source vertex to all other vertices in the graph. If `getMin` is set to
238
+ * `true`, the algorithm will find the minimum distance and update the `min` variable with the minimum
239
+ * @param {boolean} [genPath] - A boolean flag indicating whether to generate paths for all vertices from the source
240
+ * vertex.
241
+ * @returns The function `bellmanFord` returns an object with the following properties:
242
+ */
243
+ bellmanFord(src: V | VertexKey, scanNegativeCycle?: boolean, getMin?: boolean, genPath?: boolean): {
244
+ hasNegativeCycle: boolean | undefined;
245
+ distMap: Map<V, number>;
246
+ preMap: Map<V, V>;
247
+ paths: V[][];
248
+ min: number;
249
+ minPath: V[];
250
+ };
251
+ /**
252
+ * Dijkstra algorithm time: O(logVE) space: O(V + E)
253
+ * /
254
+
255
+ /**
256
+ * Dijkstra algorithm time: O(logVE) space: O(V + E)
257
+ * Dijkstra's algorithm is used to find the shortest paths from a source node to all other nodes in a graph. Its basic idea is to repeatedly choose the node closest to the source node and update the distances of other nodes using this node as an intermediary. Dijkstra's algorithm requires that the edge weights in the graph are non-negative.
258
+ */
259
+ /**
260
+ * BellmanFord time:O(VE) space:O(V)
261
+ * one to rest pairs
262
+ * The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edges for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edges, the Bellman-Ford algorithm is more flexible in some scenarios.
263
+ * The `bellmanFord` function implements the Bellman-Ford algorithm to find the shortest path from a source vertex to
264
+ */
265
+ /**
266
+ * Floyd algorithm time: O(V^3) space: O(V^2), not support graph with negative weight cycle
267
+ * all pairs
268
+ * The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edges, and it can simultaneously compute shortest paths between any two nodes.
269
+ */
270
+ /**
271
+ * Floyd algorithm time: O(V^3) space: O(V^2), not support graph with negative weight cycle
272
+ * all pairs
273
+ * /
274
+
275
+ /**
276
+ * Floyd algorithm time: O(V^3) space: O(V^2), not support graph with negative weight cycle
277
+ * all pairs
278
+ * The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edges, and it can simultaneously compute shortest paths between any two nodes.
279
+ * The function implements the Floyd-Warshall algorithm to find the shortest path between all pairs of vertices in a
280
+ * graph.
281
+ * @returns The function `floyd()` returns an object with two properties: `costs` and `predecessor`. The `costs`
282
+ * property is a 2D array of numbers representing the shortest path costs between vertices in a graph. The
283
+ * `predecessor` property is a 2D array of vertices (or `null`) representing the predecessor vertices in the shortest
284
+ * path between vertices in the
285
+ */
286
+ floyd(): {
287
+ costs: number[][];
288
+ predecessor: (V | null)[][];
289
+ };
290
+ /**
291
+ * Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
292
+ * Tarjan can find cycles in directed or undirected graph
293
+ * Tarjan can find the articulation points and bridges(critical edges) of undirected graphs in linear time,
294
+ * Tarjan solve the bi-connected components of undirected graphs;
295
+ * Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs.
296
+ * /
297
+
298
+ /**
299
+ * Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
300
+ * Tarjan can find cycles in directed or undirected graph
301
+ * Tarjan can find the articulation points and bridges(critical edges) of undirected graphs in linear time,
302
+ * Tarjan solve the bi-connected components of undirected graphs;
303
+ * Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs.
304
+ * The `tarjan` function is used to perform various graph analysis tasks such as finding articulation points, bridges,
305
+ * strongly connected components (SCCs), and cycles in a graph.
306
+ * @param {boolean} [needArticulationPoints] - A boolean value indicating whether or not to calculate and return the
307
+ * articulation points in the graph. Articulation points are the vertices in a graph whose removal would increase the
308
+ * number of connected components in the graph.
309
+ * @param {boolean} [needBridges] - A boolean flag indicating whether the algorithm should find and return the bridges
310
+ * (edges whose removal would increase the number of connected components in the graph).
311
+ * @param {boolean} [needSCCs] - A boolean value indicating whether the Strongly Connected Components (SCCs) of the
312
+ * graph are needed. If set to true, the function will calculate and return the SCCs of the graph. If set to false, the
313
+ * SCCs will not be calculated or returned.
314
+ * @param {boolean} [needCycles] - A boolean flag indicating whether the algorithm should find cycles in the graph. If
315
+ * set to true, the algorithm will return a map of cycles, where the keys are the low values of the SCCs and the values
316
+ * are arrays of vertices that form cycles within the SCCs.
317
+ * @returns The function `tarjan` returns an object with the following properties:
318
+ */
319
+ tarjan(needArticulationPoints?: boolean, needBridges?: boolean, needSCCs?: boolean, needCycles?: boolean): {
320
+ dfnMap: Map<V, number>;
321
+ lowMap: Map<V, number>;
322
+ bridges: E[];
323
+ articulationPoints: V[];
324
+ SCCs: Map<number, V[]>;
325
+ cycles: Map<number, V[]>;
326
+ };
327
+ protected abstract _addEdgeOnly(edge: E): boolean;
328
+ protected _addVertexOnly(newVertex: V): boolean;
329
+ protected _getVertex(vertexOrKey: VertexKey | V): V | null;
330
+ protected _getVertexKey(vertexOrKey: V | VertexKey): VertexKey;
331
+ protected _setVertices(value: Map<VertexKey, V>): void;
332
+ }