data-structure-typed 1.17.4 → 1.18.5

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 (293) hide show
  1. package/README.md +193 -66
  2. package/backup/recursive-type/src/assets/complexities-diff.jpg +0 -0
  3. package/backup/recursive-type/src/assets/data-structure-complexities.jpg +0 -0
  4. package/backup/recursive-type/src/assets/logo.png +0 -0
  5. package/backup/recursive-type/src/assets/overview-diagram-of-data-structures.png +0 -0
  6. package/backup/recursive-type/src/data-structures/binary-tree/aa-tree.ts +3 -0
  7. package/backup/recursive-type/src/data-structures/binary-tree/avl-tree.ts +288 -0
  8. package/backup/recursive-type/src/data-structures/binary-tree/b-tree.ts +3 -0
  9. package/backup/recursive-type/src/data-structures/binary-tree/binary-indexed-tree.ts +78 -0
  10. package/backup/recursive-type/src/data-structures/binary-tree/binary-tree.ts +1502 -0
  11. package/backup/recursive-type/src/data-structures/binary-tree/bst.ts +503 -0
  12. package/backup/recursive-type/src/data-structures/binary-tree/diagrams/avl-tree-inserting.gif +0 -0
  13. package/backup/recursive-type/src/data-structures/binary-tree/diagrams/bst-rotation.gif +0 -0
  14. package/backup/recursive-type/src/data-structures/binary-tree/diagrams/segment-tree.png +0 -0
  15. package/backup/recursive-type/src/data-structures/binary-tree/index.ts +11 -0
  16. package/backup/recursive-type/src/data-structures/binary-tree/rb-tree.ts +110 -0
  17. package/backup/recursive-type/src/data-structures/binary-tree/segment-tree.ts +243 -0
  18. package/backup/recursive-type/src/data-structures/binary-tree/splay-tree.ts +3 -0
  19. package/backup/recursive-type/src/data-structures/binary-tree/tree-multiset.ts +55 -0
  20. package/backup/recursive-type/src/data-structures/binary-tree/two-three-tree.ts +3 -0
  21. package/backup/recursive-type/src/data-structures/diagrams/README.md +5 -0
  22. package/backup/recursive-type/src/data-structures/graph/abstract-graph.ts +985 -0
  23. package/backup/recursive-type/src/data-structures/graph/diagrams/adjacency-list-pros-cons.jpg +0 -0
  24. package/backup/recursive-type/src/data-structures/graph/diagrams/adjacency-list.jpg +0 -0
  25. package/backup/recursive-type/src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.jpg +0 -0
  26. package/backup/recursive-type/src/data-structures/graph/diagrams/adjacency-matrix.jpg +0 -0
  27. package/backup/recursive-type/src/data-structures/graph/diagrams/dfs-can-do.jpg +0 -0
  28. package/backup/recursive-type/src/data-structures/graph/diagrams/edge-list-pros-cons.jpg +0 -0
  29. package/backup/recursive-type/src/data-structures/graph/diagrams/edge-list.jpg +0 -0
  30. package/backup/recursive-type/src/data-structures/graph/diagrams/max-flow.jpg +0 -0
  31. package/backup/recursive-type/src/data-structures/graph/diagrams/mst.jpg +0 -0
  32. package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan-articulation-point-bridge.png +0 -0
  33. package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan-complicate-simple.png +0 -0
  34. package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan-strongly-connected-component.png +0 -0
  35. package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan.mp4 +0 -0
  36. package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan.webp +0 -0
  37. package/backup/recursive-type/src/data-structures/graph/directed-graph.ts +478 -0
  38. package/backup/recursive-type/src/data-structures/graph/index.ts +3 -0
  39. package/backup/recursive-type/src/data-structures/graph/undirected-graph.ts +293 -0
  40. package/backup/recursive-type/src/data-structures/hash/coordinate-map.ts +67 -0
  41. package/backup/recursive-type/src/data-structures/hash/coordinate-set.ts +56 -0
  42. package/backup/recursive-type/src/data-structures/hash/hash-table.ts +3 -0
  43. package/backup/recursive-type/src/data-structures/hash/index.ts +6 -0
  44. package/backup/recursive-type/src/data-structures/hash/pair.ts +3 -0
  45. package/backup/recursive-type/src/data-structures/hash/tree-map.ts +3 -0
  46. package/backup/recursive-type/src/data-structures/hash/tree-set.ts +3 -0
  47. package/backup/recursive-type/src/data-structures/heap/heap.ts +176 -0
  48. package/backup/recursive-type/src/data-structures/heap/index.ts +3 -0
  49. package/backup/recursive-type/src/data-structures/heap/max-heap.ts +31 -0
  50. package/backup/recursive-type/src/data-structures/heap/min-heap.ts +34 -0
  51. package/backup/recursive-type/src/data-structures/index.ts +15 -0
  52. package/backup/recursive-type/src/data-structures/interfaces/abstract-graph.ts +42 -0
  53. package/backup/recursive-type/src/data-structures/interfaces/avl-tree.ts +1 -0
  54. package/backup/recursive-type/src/data-structures/interfaces/binary-tree.ts +56 -0
  55. package/backup/recursive-type/src/data-structures/interfaces/bst.ts +1 -0
  56. package/backup/recursive-type/src/data-structures/interfaces/directed-graph.ts +15 -0
  57. package/backup/recursive-type/src/data-structures/interfaces/doubly-linked-list.ts +1 -0
  58. package/backup/recursive-type/src/data-structures/interfaces/heap.ts +1 -0
  59. package/backup/recursive-type/src/data-structures/interfaces/index.ts +13 -0
  60. package/backup/recursive-type/src/data-structures/interfaces/navigator.ts +1 -0
  61. package/backup/recursive-type/src/data-structures/interfaces/priority-queue.ts +1 -0
  62. package/backup/recursive-type/src/data-structures/interfaces/segment-tree.ts +1 -0
  63. package/backup/recursive-type/src/data-structures/interfaces/singly-linked-list.ts +1 -0
  64. package/backup/recursive-type/src/data-structures/interfaces/tree-multiset.ts +1 -0
  65. package/backup/recursive-type/src/data-structures/interfaces/undirected-graph.ts +3 -0
  66. package/backup/recursive-type/src/data-structures/linked-list/doubly-linked-list.ts +573 -0
  67. package/backup/recursive-type/src/data-structures/linked-list/index.ts +3 -0
  68. package/backup/recursive-type/src/data-structures/linked-list/singly-linked-list.ts +490 -0
  69. package/backup/recursive-type/src/data-structures/linked-list/skip-linked-list.ts +3 -0
  70. package/backup/recursive-type/src/data-structures/matrix/index.ts +4 -0
  71. package/backup/recursive-type/src/data-structures/matrix/matrix.ts +27 -0
  72. package/backup/recursive-type/src/data-structures/matrix/matrix2d.ts +208 -0
  73. package/backup/recursive-type/src/data-structures/matrix/navigator.ts +122 -0
  74. package/backup/recursive-type/src/data-structures/matrix/vector2d.ts +316 -0
  75. package/backup/recursive-type/src/data-structures/priority-queue/index.ts +3 -0
  76. package/backup/recursive-type/src/data-structures/priority-queue/max-priority-queue.ts +49 -0
  77. package/backup/recursive-type/src/data-structures/priority-queue/min-priority-queue.ts +50 -0
  78. package/backup/recursive-type/src/data-structures/priority-queue/priority-queue.ts +354 -0
  79. package/backup/recursive-type/src/data-structures/queue/deque.ts +251 -0
  80. package/backup/recursive-type/src/data-structures/queue/index.ts +2 -0
  81. package/backup/recursive-type/src/data-structures/queue/queue.ts +120 -0
  82. package/backup/recursive-type/src/data-structures/stack/index.ts +1 -0
  83. package/backup/recursive-type/src/data-structures/stack/stack.ts +98 -0
  84. package/backup/recursive-type/src/data-structures/tree/index.ts +1 -0
  85. package/backup/recursive-type/src/data-structures/tree/tree.ts +80 -0
  86. package/backup/recursive-type/src/data-structures/trie/index.ts +1 -0
  87. package/backup/recursive-type/src/data-structures/trie/trie.ts +227 -0
  88. package/backup/recursive-type/src/data-structures/types/abstract-graph.ts +5 -0
  89. package/backup/recursive-type/src/data-structures/types/avl-tree.ts +8 -0
  90. package/backup/recursive-type/src/data-structures/types/binary-tree.ts +10 -0
  91. package/backup/recursive-type/src/data-structures/types/bst.ts +6 -0
  92. package/backup/recursive-type/src/data-structures/types/directed-graph.ts +8 -0
  93. package/backup/recursive-type/src/data-structures/types/doubly-linked-list.ts +1 -0
  94. package/backup/recursive-type/src/data-structures/types/heap.ts +5 -0
  95. package/backup/recursive-type/src/data-structures/types/index.ts +12 -0
  96. package/backup/recursive-type/src/data-structures/types/navigator.ts +13 -0
  97. package/backup/recursive-type/src/data-structures/types/priority-queue.ts +9 -0
  98. package/backup/recursive-type/src/data-structures/types/segment-tree.ts +1 -0
  99. package/backup/recursive-type/src/data-structures/types/singly-linked-list.ts +1 -0
  100. package/backup/recursive-type/src/data-structures/types/tree-multiset.ts +1 -0
  101. package/backup/recursive-type/src/index.ts +1 -0
  102. package/backup/recursive-type/src/utils/index.ts +2 -0
  103. package/backup/recursive-type/src/utils/types/index.ts +1 -0
  104. package/backup/recursive-type/src/utils/types/utils.ts +6 -0
  105. package/backup/recursive-type/src/utils/utils.ts +78 -0
  106. package/dist/data-structures/binary-tree/avl-tree.d.ts +19 -25
  107. package/dist/data-structures/binary-tree/avl-tree.js +12 -20
  108. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +3 -1
  109. package/dist/data-structures/binary-tree/binary-indexed-tree.js +10 -0
  110. package/dist/data-structures/binary-tree/binary-tree.d.ts +135 -161
  111. package/dist/data-structures/binary-tree/binary-tree.js +192 -164
  112. package/dist/data-structures/binary-tree/bst.d.ts +21 -21
  113. package/dist/data-structures/binary-tree/bst.js +33 -36
  114. package/dist/data-structures/binary-tree/rb-tree.d.ts +1 -2
  115. package/dist/data-structures/binary-tree/rb-tree.js +68 -5
  116. package/dist/data-structures/binary-tree/segment-tree.d.ts +17 -39
  117. package/dist/data-structures/binary-tree/segment-tree.js +34 -47
  118. package/dist/data-structures/binary-tree/tree-multiset.d.ts +9 -8
  119. package/dist/data-structures/binary-tree/tree-multiset.js +7 -6
  120. package/dist/data-structures/graph/abstract-graph.d.ts +56 -71
  121. package/dist/data-structures/graph/abstract-graph.js +87 -92
  122. package/dist/data-structures/graph/directed-graph.d.ts +128 -105
  123. package/dist/data-structures/graph/directed-graph.js +161 -121
  124. package/dist/data-structures/graph/undirected-graph.d.ts +81 -62
  125. package/dist/data-structures/graph/undirected-graph.js +99 -78
  126. package/dist/data-structures/hash/coordinate-map.d.ts +1 -5
  127. package/dist/data-structures/hash/coordinate-map.js +3 -9
  128. package/dist/data-structures/hash/coordinate-set.d.ts +2 -6
  129. package/dist/data-structures/hash/coordinate-set.js +3 -9
  130. package/dist/data-structures/hash/hash-table.d.ts +2 -1
  131. package/dist/data-structures/hash/hash-table.js +7 -0
  132. package/dist/data-structures/hash/pair.d.ts +2 -1
  133. package/dist/data-structures/hash/pair.js +7 -0
  134. package/dist/data-structures/hash/tree-map.d.ts +2 -1
  135. package/dist/data-structures/hash/tree-map.js +7 -0
  136. package/dist/data-structures/hash/tree-set.d.ts +2 -1
  137. package/dist/data-structures/hash/tree-set.js +7 -0
  138. package/dist/data-structures/heap/heap.d.ts +0 -14
  139. package/dist/data-structures/heap/heap.js +3 -27
  140. package/dist/data-structures/index.d.ts +1 -0
  141. package/dist/data-structures/index.js +1 -0
  142. package/dist/data-structures/interfaces/abstract-graph.d.ts +22 -0
  143. package/dist/data-structures/interfaces/abstract-graph.js +2 -0
  144. package/dist/data-structures/interfaces/avl-tree.d.ts +1 -0
  145. package/dist/data-structures/interfaces/avl-tree.js +2 -0
  146. package/dist/data-structures/interfaces/binary-tree.d.ts +27 -0
  147. package/dist/data-structures/interfaces/binary-tree.js +2 -0
  148. package/dist/data-structures/interfaces/bst.d.ts +1 -0
  149. package/dist/data-structures/interfaces/bst.js +2 -0
  150. package/dist/data-structures/interfaces/directed-graph.d.ts +9 -0
  151. package/dist/data-structures/interfaces/directed-graph.js +2 -0
  152. package/dist/data-structures/interfaces/doubly-linked-list.d.ts +1 -0
  153. package/dist/data-structures/interfaces/doubly-linked-list.js +2 -0
  154. package/dist/data-structures/interfaces/heap.d.ts +1 -0
  155. package/dist/data-structures/interfaces/heap.js +2 -0
  156. package/dist/data-structures/interfaces/index.d.ts +13 -0
  157. package/dist/data-structures/interfaces/index.js +29 -0
  158. package/dist/data-structures/interfaces/navigator.d.ts +1 -0
  159. package/dist/data-structures/interfaces/navigator.js +2 -0
  160. package/dist/data-structures/interfaces/priority-queue.d.ts +1 -0
  161. package/dist/data-structures/interfaces/priority-queue.js +2 -0
  162. package/dist/data-structures/interfaces/segment-tree.d.ts +1 -0
  163. package/dist/data-structures/interfaces/segment-tree.js +2 -0
  164. package/dist/data-structures/interfaces/singly-linked-list.d.ts +1 -0
  165. package/dist/data-structures/interfaces/singly-linked-list.js +2 -0
  166. package/dist/data-structures/interfaces/tree-multiset.d.ts +1 -0
  167. package/dist/data-structures/interfaces/tree-multiset.js +2 -0
  168. package/dist/data-structures/interfaces/undirected-graph.d.ts +2 -0
  169. package/dist/data-structures/interfaces/undirected-graph.js +2 -0
  170. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +1 -3
  171. package/dist/data-structures/linked-list/doubly-linked-list.js +12 -18
  172. package/dist/data-structures/linked-list/singly-linked-list.d.ts +1 -2
  173. package/dist/data-structures/linked-list/singly-linked-list.js +12 -15
  174. package/dist/data-structures/priority-queue/priority-queue.d.ts +1 -1
  175. package/dist/data-structures/priority-queue/priority-queue.js +4 -4
  176. package/dist/data-structures/queue/deque.d.ts +5 -5
  177. package/dist/data-structures/queue/deque.js +6 -6
  178. package/dist/data-structures/queue/queue.d.ts +1 -1
  179. package/dist/data-structures/stack/stack.d.ts +1 -1
  180. package/dist/data-structures/tree/tree.d.ts +12 -4
  181. package/dist/data-structures/tree/tree.js +44 -12
  182. package/dist/data-structures/trie/trie.d.ts +3 -3
  183. package/dist/data-structures/trie/trie.js +10 -10
  184. package/dist/data-structures/types/abstract-graph.d.ts +1 -20
  185. package/dist/data-structures/types/avl-tree.d.ts +5 -4
  186. package/dist/data-structures/types/binary-tree.d.ts +6 -5
  187. package/dist/data-structures/types/bst.d.ts +4 -3
  188. package/dist/data-structures/types/directed-graph.d.ts +5 -9
  189. package/dist/data-structures/types/directed-graph.js +7 -0
  190. package/dist/data-structures/types/doubly-linked-list.d.ts +1 -1
  191. package/dist/data-structures/types/heap.d.ts +2 -2
  192. package/dist/data-structures/types/index.d.ts +0 -1
  193. package/dist/data-structures/types/index.js +0 -1
  194. package/dist/data-structures/types/navigator.d.ts +2 -2
  195. package/dist/data-structures/types/priority-queue.d.ts +2 -2
  196. package/dist/data-structures/types/tree-multiset.d.ts +3 -4
  197. package/docs/assets/search.js +1 -1
  198. package/docs/classes/AVLTree.html +552 -405
  199. package/docs/classes/AVLTreeNode.html +107 -242
  200. package/docs/classes/AaTree.html +18 -13
  201. package/docs/classes/AbstractEdge.html +77 -68
  202. package/docs/classes/AbstractGraph.html +223 -115
  203. package/docs/classes/AbstractVertex.html +71 -45
  204. package/docs/classes/ArrayDeque.html +31 -26
  205. package/docs/classes/BST.html +543 -391
  206. package/docs/classes/BSTNode.html +107 -236
  207. package/docs/classes/BTree.html +18 -13
  208. package/docs/classes/BinaryIndexedTree.html +56 -21
  209. package/docs/classes/BinaryTree.html +564 -355
  210. package/docs/classes/BinaryTreeNode.html +146 -199
  211. package/docs/classes/Character.html +21 -16
  212. package/docs/classes/CoordinateMap.html +49 -52
  213. package/docs/classes/CoordinateSet.html +50 -53
  214. package/docs/classes/Deque.html +51 -68
  215. package/docs/classes/DirectedEdge.html +98 -103
  216. package/docs/classes/DirectedGraph.html +449 -210
  217. package/docs/classes/DirectedVertex.html +63 -52
  218. package/docs/classes/DoublyLinkedList.html +56 -71
  219. package/docs/classes/DoublyLinkedListNode.html +28 -23
  220. package/docs/classes/HashTable.html +155 -0
  221. package/docs/classes/Heap.html +33 -109
  222. package/docs/classes/HeapItem.html +25 -20
  223. package/docs/classes/Matrix2D.html +33 -28
  224. package/docs/classes/MatrixNTI2D.html +21 -16
  225. package/docs/classes/MaxHeap.html +33 -114
  226. package/docs/classes/MaxPriorityQueue.html +71 -61
  227. package/docs/classes/MinHeap.html +33 -114
  228. package/docs/classes/MinPriorityQueue.html +71 -61
  229. package/docs/classes/Navigator.html +28 -23
  230. package/docs/classes/ObjectDeque.html +66 -51
  231. package/docs/classes/{RBTree.html → Pair.html} +25 -20
  232. package/docs/classes/PriorityQueue.html +66 -56
  233. package/docs/classes/Queue.html +33 -28
  234. package/docs/classes/SegmentTree.html +129 -57
  235. package/docs/classes/SegmentTreeNode.html +62 -140
  236. package/docs/classes/SinglyLinkedList.html +53 -58
  237. package/docs/classes/SinglyLinkedListNode.html +25 -20
  238. package/docs/classes/SkipLinkedList.html +18 -13
  239. package/docs/classes/SplayTree.html +18 -13
  240. package/docs/classes/Stack.html +31 -26
  241. package/docs/classes/TreeMap.html +155 -0
  242. package/docs/classes/TreeMultiSet.html +541 -388
  243. package/docs/classes/TreeNode.html +125 -35
  244. package/docs/classes/TreeSet.html +155 -0
  245. package/docs/classes/Trie.html +30 -25
  246. package/docs/classes/TrieNode.html +33 -28
  247. package/docs/classes/TwoThreeTree.html +18 -13
  248. package/docs/classes/UndirectedEdge.html +87 -80
  249. package/docs/classes/UndirectedGraph.html +356 -178
  250. package/docs/classes/UndirectedVertex.html +63 -52
  251. package/docs/classes/Vector2D.html +45 -40
  252. package/docs/enums/CP.html +21 -16
  253. package/docs/enums/FamilyPosition.html +21 -16
  254. package/docs/enums/LoopType.html +20 -15
  255. package/docs/{interfaces/AVLTreeDeleted.html → enums/TopologicalProperty.html} +47 -44
  256. package/docs/index.html +203 -69
  257. package/docs/interfaces/{PriorityQueueOptions.html → IBinaryTree.html} +49 -40
  258. package/docs/interfaces/IBinaryTreeNode.html +383 -0
  259. package/docs/interfaces/IDirectedGraph.html +24 -19
  260. package/docs/interfaces/IGraph.html +122 -89
  261. package/docs/interfaces/{HeapOptions.html → IUNDirectedGraph.html} +26 -53
  262. package/docs/modules.html +33 -23
  263. package/docs/types/{ToThunkFn.html → AVLTreeDeleted.html} +31 -22
  264. package/docs/types/BSTComparator.html +18 -13
  265. package/docs/types/BSTDeletedResult.html +23 -18
  266. package/docs/types/BinaryTreeDeleted.html +23 -18
  267. package/docs/types/BinaryTreeNodeId.html +18 -13
  268. package/docs/types/BinaryTreeNodePropertyName.html +18 -13
  269. package/docs/types/DFSOrderPattern.html +18 -13
  270. package/docs/types/DijkstraResult.html +18 -13
  271. package/docs/types/Direction.html +18 -13
  272. package/docs/types/{DoublyLinkedListGetBy.html → EdgeId.html} +22 -17
  273. package/docs/types/{TrlFn.html → HeapOptions.html} +33 -20
  274. package/docs/types/{TrlAsyncFn.html → NavigatorParams.html} +46 -20
  275. package/docs/types/NodeOrPropertyName.html +18 -13
  276. package/docs/types/PriorityQueueComparator.html +18 -13
  277. package/docs/types/PriorityQueueDFSOrderPattern.html +18 -13
  278. package/docs/types/{SpecifyOptional.html → PriorityQueueOptions.html} +32 -20
  279. package/docs/types/RecursiveAVLTreeNode.html +135 -0
  280. package/docs/types/RecursiveBSTNode.html +135 -0
  281. package/docs/types/RecursiveBinaryTreeNode.html +135 -0
  282. package/docs/types/ResultByProperty.html +21 -16
  283. package/docs/types/ResultsByProperty.html +21 -16
  284. package/docs/types/SegmentTreeNodeVal.html +18 -13
  285. package/docs/types/TopologicalStatus.html +18 -13
  286. package/docs/types/TreeMultiSetDeletedResult.html +23 -18
  287. package/docs/types/Turning.html +18 -13
  288. package/docs/types/VertexId.html +18 -13
  289. package/notes/note.md +12 -1
  290. package/package.json +11 -3
  291. package/tsconfig.json +2 -2
  292. package/docs/interfaces/NavigatorParams.html +0 -197
  293. package/docs/types/Thunk.html +0 -133
@@ -1,111 +1,130 @@
1
1
  import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';
2
2
  import type { VertexId } from '../types';
3
- export declare class UndirectedVertex extends AbstractVertex {
3
+ export declare class UndirectedVertex<T = number> extends AbstractVertex<T> {
4
4
  /**
5
- * The constructor function initializes an object with a given id.
6
- * @param {VertexId} id - The `id` parameter is the identifier for the vertex. It is used to uniquely identify the
7
- * vertex within a graph or network.
5
+ * The constructor function initializes a vertex with an optional value.
6
+ * @param {VertexId} id - The `id` parameter is the identifier for the vertex. It is of type `VertexId`, which is
7
+ * typically a unique identifier for each vertex in a graph.
8
+ * @param {T} [val] - The "val" parameter is an optional parameter of type T. It is used to initialize the value of the
9
+ * vertex. If no value is provided, the vertex will be initialized with a default value.
8
10
  */
9
- constructor(id: VertexId);
11
+ constructor(id: VertexId, val?: T);
10
12
  }
11
- export declare class UndirectedEdge extends AbstractEdge {
13
+ export declare class UndirectedEdge<T = number> extends AbstractEdge<T> {
12
14
  /**
13
- * The constructor function initializes an instance of a class with two vertex IDs and an optional weight.
15
+ * The constructor function initializes an instance of a class with two vertex IDs, an optional weight, and an optional
16
+ * value.
14
17
  * @param {VertexId} v1 - The parameter `v1` is of type `VertexId` and represents the first vertex in the edge.
15
18
  * @param {VertexId} v2 - The parameter `v2` is a `VertexId`, which represents the identifier of the second vertex in a
16
- * graph.
17
- * @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the edge
18
- * between two vertices.
19
+ * graph edge.
20
+ * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
21
+ * @param {T} [val] - The "val" parameter is an optional parameter of type T. It represents the value associated with
22
+ * the edge.
19
23
  */
20
- constructor(v1: VertexId, v2: VertexId, weight?: number);
24
+ constructor(v1: VertexId, v2: VertexId, weight?: number, val?: T);
21
25
  private _vertices;
22
26
  get vertices(): [VertexId, VertexId];
23
27
  set vertices(v: [VertexId, VertexId]);
24
- /**
25
- * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
26
- */
27
- getVertices(): [VertexId, VertexId];
28
28
  }
29
- export declare class UndirectedGraph<V extends UndirectedVertex, E extends UndirectedEdge> extends AbstractGraph<V, E> {
30
- constructor();
29
+ export declare class UndirectedGraph<V extends UndirectedVertex<any>, E extends UndirectedEdge<any>> extends AbstractGraph<V, E> {
30
+ private readonly _vertexConstructor;
31
+ private readonly _edgeConstructor;
32
+ constructor(vertexConstructor: new (id: VertexId, val?: V['val']) => V, edgeConstructor: new (src: VertexId, dest: VertexId, weight?: number, val?: E['val']) => E);
31
33
  protected _edges: Map<V, E[]>;
32
34
  get edges(): Map<V, E[]>;
33
- protected set edges(v: Map<V, E[]>);
34
35
  /**
35
- * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
36
+ * 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.
37
+ * 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.
38
+ * @param id
39
+ * @param val
40
+ */
41
+ _createVertex(id: VertexId, val?: V['val']): V;
42
+ /**
43
+ * 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.
44
+ * 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.
45
+ * @param src
46
+ * @param dest
47
+ * @param weight
48
+ * @param val
36
49
  */
37
- getEdges(): Map<V, E[]>;
50
+ _createEdge(src: VertexId, dest: VertexId, weight?: number, val?: E['val']): E;
38
51
  /**
39
- * The function `getEdge` returns the first edge that connects two vertices, or null if no such edge exists.
40
- * @param {V | null | VertexId} v1 - The parameter `v1` represents either a vertex object (`V`) or a vertex ID
41
- * (`VertexId`). It can also be `null`.
42
- * @param {V | null | VertexId} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `V` (vertex
43
- * object), `null`, or `VertexId` (vertex ID).
44
- * @returns an edge (E) or null.
52
+ * The function `getEdge` returns the first undirected edge that connects two given vertices, or null if no such edge
53
+ * exists.
54
+ * @param {V | null | VertexId} v1 - The parameter `v1` represents either an `V`
55
+ * object, `null`, or a `VertexId`. It is used to specify one of the vertices of the edge.
56
+ * @param {V | null | VertexId} v2 - The parameter `v2` represents either an `UndirectedVertex`
57
+ * object or a `VertexId` (identifier) of an undirected vertex.
58
+ * @returns an instance of `E` or `null`.
45
59
  */
46
60
  getEdge(v1: V | null | VertexId, v2: V | null | VertexId): E | null;
47
61
  /**
48
- * The function adds an edge to a graph by connecting two vertices.
49
- * @param {E} edge - The `edge` parameter is an object of type `E`, which represents an edge in a graph.
62
+ * The function adds an undirected edge to a graph by updating the adjacency list.
63
+ * @param edge - An object representing an undirected edge in a graph. It has a property called "vertices" which is an
64
+ * array of two vertices connected by the edge.
50
65
  * @returns a boolean value.
51
66
  */
52
67
  addEdge(edge: E): boolean;
53
68
  /**
54
- * The function removes an edge between two vertices in a graph and returns the removed edge, or null if either of the
55
- * vertices does not exist.
56
- * @param {V | VertexId} v1 - The parameter `v1` represents either a vertex object (`V`) or a vertex ID (`VertexId`).
57
- * @param {V | VertexId} v2 - V | VertexId: The second vertex or vertex ID of the edge to be removed.
58
- * @returns the removed edge (E) if it exists, or null if either of the vertices (v1 or v2) does not exist.
69
+ * The function removes an edge between two vertices in an undirected graph.
70
+ * @param {V | VertexId} v1 - The parameter `v1` represents either an `V` object or
71
+ * a `VertexId`. It is used to specify one of the vertices of the edge that needs to be removed.
72
+ * @param {V | VertexId} v2 - The parameter `v2` represents either an instance of the
73
+ * `UndirectedVertex` class or a `VertexId`. It is used to identify the second vertex of the edge that needs to be
74
+ * removed.
75
+ * @returns The function `removeEdgeBetween` returns an `E` object if an edge is successfully removed
76
+ * between the two vertices `v1` and `v2`. If either `v1` or `v2` is not found in the graph, or if there is no edge
77
+ * between them, the function returns `null`.
59
78
  */
60
79
  removeEdgeBetween(v1: V | VertexId, v2: V | VertexId): E | null;
61
80
  /**
62
- * The removeEdge function removes an edge between two vertices in a graph.
63
- * @param {E} edge - The parameter "edge" is of type E, which represents an edge in a graph.
64
- * @returns The method is returning either the removed edge (of type E) or null if the edge was not found.
81
+ * The removeEdge function removes an edge between two vertices in an undirected graph.
82
+ * @param edge - An object representing an undirected edge. It has a property called "vertices" which is an array
83
+ * containing the two vertices connected by the edge.
84
+ * @returns The method is returning an UndirectedEdge object or null.
65
85
  */
66
86
  removeEdge(edge: E): E | null;
67
87
  /**
68
- * The function `degreeOf` returns the degree of a vertex in a graph, which is the number of edges connected to that
69
- * vertex.
70
- * @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a `V`.
71
- * @returns The function `degreeOf` returns the degree of a vertex in a graph. The degree of a vertex is the number of
72
- * edges that are incident to that vertex.
88
+ * The function "degreeOf" returns the degree of a given vertex in an undirected graph.
89
+ * @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or an
90
+ * `V`.
91
+ * @returns the degree of the vertex.
73
92
  */
74
93
  degreeOf(vertexOrId: VertexId | V): number;
75
94
  /**
76
- * The function "edgesOf" returns an array of edges connected to a given vertex.
77
- * @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a `V`.
78
- * @returns an array of edges connected to the specified vertex. If the vertex exists in the graph, the function
79
- * returns the array of edges connected to that vertex. If the vertex does not exist in the graph, the function returns
80
- * an empty array.
95
+ * The function "edgesOf" returns an array of undirected edges connected to a given vertex or vertex ID.
96
+ * @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or an
97
+ * `V`.
98
+ * @returns an array of UndirectedEdge objects.
81
99
  */
82
100
  edgesOf(vertexOrId: VertexId | V): E[];
83
101
  /**
84
- * The function "edgeSet" returns an array of unique edges from a set of edges.
85
- * @returns The method `edgeSet()` returns an array of type `E[]`.
102
+ * The function "edgeSet" returns an array of unique undirected edges from a set of edges.
103
+ * @returns The method `edgeSet()` returns an array of `E` objects.
86
104
  */
87
105
  edgeSet(): E[];
88
106
  /**
89
- * The function "getEdgesOf" returns an array of edges connected to a given vertex or vertex ID.
90
- * @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can accept either a vertex object (`V`) or a vertex ID
91
- * (`VertexId`).
92
- * @returns an array of edges (E[]) that are connected to the specified vertex or vertex ID.
107
+ * The function "getEdgesOf" returns an array of undirected edges connected to a given vertex or vertex ID.
108
+ * @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can be either an
109
+ * `V` object or a `VertexId`.
110
+ * @returns The function `getEdgesOf` returns an array of `E` objects.
93
111
  */
94
112
  getEdgesOf(vertexOrId: V | VertexId): E[];
95
113
  /**
96
- * The function "getNeighbors" returns an array of neighboring vertices of a given vertex.
97
- * @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can be either a vertex object (`V`) or a vertex ID
98
- * (`VertexId`).
99
- * @returns an array of vertices (V[]).
114
+ * The function `getNeighbors` returns an array of neighboring vertices of a given vertex in an undirected graph.
115
+ * @param {V | VertexId} vertexOrId - The `vertexOrId` parameter can be either an
116
+ * `V` object or a `VertexId`. It represents the vertex for which we want to find the neighbors.
117
+ * @returns an array of UndirectedVertex objects.
100
118
  */
101
119
  getNeighbors(vertexOrId: V | VertexId): V[];
102
120
  /**
103
- * The function "getEndsOfEdge" returns the vertices at the ends of a given edge, or null if the edge does not exist in
104
- * the graph.
105
- * @param {E} edge - The parameter "edge" is of type E, which represents an edge in a graph.
106
- * @returns The function `getEndsOfEdge` returns an array containing two vertices `[V, V]` if the edge exists in the
107
- * graph and both vertices are found. If the edge does not exist or one or both vertices are not found, it returns
108
- * `null`.
121
+ * The function "getEndsOfEdge" returns the two vertices that form the ends of a given undirected edge, or null if the
122
+ * edge does not exist in the graph.
123
+ * @param edge - An object representing an undirected edge in a graph. It has a property called "vertices" which is an
124
+ * array containing two vertices that the edge connects.
125
+ * @returns The function `getEndsOfEdge` returns an array containing the two ends of the given `edge` if the edge
126
+ * exists in the graph. If the edge does not exist, it returns `null`.
109
127
  */
110
128
  getEndsOfEdge(edge: E): [V, V] | null;
129
+ protected _setEdges(v: Map<V, E[]>): void;
111
130
  }
@@ -64,12 +64,14 @@ var abstract_graph_1 = require("./abstract-graph");
64
64
  var UndirectedVertex = /** @class */ (function (_super) {
65
65
  __extends(UndirectedVertex, _super);
66
66
  /**
67
- * The constructor function initializes an object with a given id.
68
- * @param {VertexId} id - The `id` parameter is the identifier for the vertex. It is used to uniquely identify the
69
- * vertex within a graph or network.
67
+ * The constructor function initializes a vertex with an optional value.
68
+ * @param {VertexId} id - The `id` parameter is the identifier for the vertex. It is of type `VertexId`, which is
69
+ * typically a unique identifier for each vertex in a graph.
70
+ * @param {T} [val] - The "val" parameter is an optional parameter of type T. It is used to initialize the value of the
71
+ * vertex. If no value is provided, the vertex will be initialized with a default value.
70
72
  */
71
- function UndirectedVertex(id) {
72
- return _super.call(this, id) || this;
73
+ function UndirectedVertex(id, val) {
74
+ return _super.call(this, id, val) || this;
73
75
  }
74
76
  return UndirectedVertex;
75
77
  }(abstract_graph_1.AbstractVertex));
@@ -77,15 +79,17 @@ exports.UndirectedVertex = UndirectedVertex;
77
79
  var UndirectedEdge = /** @class */ (function (_super) {
78
80
  __extends(UndirectedEdge, _super);
79
81
  /**
80
- * The constructor function initializes an instance of a class with two vertex IDs and an optional weight.
82
+ * The constructor function initializes an instance of a class with two vertex IDs, an optional weight, and an optional
83
+ * value.
81
84
  * @param {VertexId} v1 - The parameter `v1` is of type `VertexId` and represents the first vertex in the edge.
82
85
  * @param {VertexId} v2 - The parameter `v2` is a `VertexId`, which represents the identifier of the second vertex in a
83
- * graph.
84
- * @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the edge
85
- * between two vertices.
86
+ * graph edge.
87
+ * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
88
+ * @param {T} [val] - The "val" parameter is an optional parameter of type T. It represents the value associated with
89
+ * the edge.
86
90
  */
87
- function UndirectedEdge(v1, v2, weight) {
88
- var _this = _super.call(this, weight) || this;
91
+ function UndirectedEdge(v1, v2, weight, val) {
92
+ var _this = _super.call(this, weight, val) || this;
89
93
  _this._vertices = [v1, v2];
90
94
  return _this;
91
95
  }
@@ -99,19 +103,15 @@ var UndirectedEdge = /** @class */ (function (_super) {
99
103
  enumerable: false,
100
104
  configurable: true
101
105
  });
102
- /**
103
- * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
104
- */
105
- UndirectedEdge.prototype.getVertices = function () {
106
- return this._vertices;
107
- };
108
106
  return UndirectedEdge;
109
107
  }(abstract_graph_1.AbstractEdge));
110
108
  exports.UndirectedEdge = UndirectedEdge;
111
109
  var UndirectedGraph = /** @class */ (function (_super) {
112
110
  __extends(UndirectedGraph, _super);
113
- function UndirectedGraph() {
111
+ function UndirectedGraph(vertexConstructor, edgeConstructor) {
114
112
  var _this = _super.call(this) || this;
113
+ _this._vertexConstructor = vertexConstructor;
114
+ _this._edgeConstructor = edgeConstructor;
115
115
  _this._edges = new Map();
116
116
  return _this;
117
117
  }
@@ -119,32 +119,46 @@ var UndirectedGraph = /** @class */ (function (_super) {
119
119
  get: function () {
120
120
  return this._edges;
121
121
  },
122
- set: function (v) {
123
- this._edges = v;
124
- },
125
122
  enumerable: false,
126
123
  configurable: true
127
124
  });
128
125
  /**
129
- * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
126
+ * 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.
127
+ * 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.
128
+ * @param id
129
+ * @param val
130
130
  */
131
- UndirectedGraph.prototype.getEdges = function () {
132
- return this._edges;
131
+ UndirectedGraph.prototype._createVertex = function (id, val) {
132
+ return new this._vertexConstructor(id, val);
133
133
  };
134
134
  /**
135
- * The function `getEdge` returns the first edge that connects two vertices, or null if no such edge exists.
136
- * @param {V | null | VertexId} v1 - The parameter `v1` represents either a vertex object (`V`) or a vertex ID
137
- * (`VertexId`). It can also be `null`.
138
- * @param {V | null | VertexId} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `V` (vertex
139
- * object), `null`, or `VertexId` (vertex ID).
140
- * @returns an edge (E) or null.
135
+ * 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.
136
+ * 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.
137
+ * @param src
138
+ * @param dest
139
+ * @param weight
140
+ * @param val
141
+ */
142
+ UndirectedGraph.prototype._createEdge = function (src, dest, weight, val) {
143
+ if (weight === undefined || weight === null)
144
+ weight = 1;
145
+ return new this._edgeConstructor(src, dest, weight, val);
146
+ };
147
+ /**
148
+ * The function `getEdge` returns the first undirected edge that connects two given vertices, or null if no such edge
149
+ * exists.
150
+ * @param {V | null | VertexId} v1 - The parameter `v1` represents either an `V`
151
+ * object, `null`, or a `VertexId`. It is used to specify one of the vertices of the edge.
152
+ * @param {V | null | VertexId} v2 - The parameter `v2` represents either an `UndirectedVertex`
153
+ * object or a `VertexId` (identifier) of an undirected vertex.
154
+ * @returns an instance of `E` or `null`.
141
155
  */
142
156
  UndirectedGraph.prototype.getEdge = function (v1, v2) {
143
157
  var _a;
144
158
  var edges = [];
145
159
  if (v1 !== null && v2 !== null) {
146
- var vertex1 = this.getVertex(v1);
147
- var vertex2_1 = this.getVertex(v2);
160
+ var vertex1 = this._getVertex(v1);
161
+ var vertex2_1 = this._getVertex(v2);
148
162
  if (vertex1 && vertex2_1) {
149
163
  edges = (_a = this._edges.get(vertex1)) === null || _a === void 0 ? void 0 : _a.filter(function (e) { return e.vertices.includes(vertex2_1.id); });
150
164
  }
@@ -152,8 +166,9 @@ var UndirectedGraph = /** @class */ (function (_super) {
152
166
  return edges ? edges[0] || null : null;
153
167
  };
154
168
  /**
155
- * The function adds an edge to a graph by connecting two vertices.
156
- * @param {E} edge - The `edge` parameter is an object of type `E`, which represents an edge in a graph.
169
+ * The function adds an undirected edge to a graph by updating the adjacency list.
170
+ * @param edge - An object representing an undirected edge in a graph. It has a property called "vertices" which is an
171
+ * array of two vertices connected by the edge.
157
172
  * @returns a boolean value.
158
173
  */
159
174
  UndirectedGraph.prototype.addEdge = function (edge) {
@@ -161,7 +176,7 @@ var UndirectedGraph = /** @class */ (function (_super) {
161
176
  try {
162
177
  for (var _b = __values(edge.vertices), _c = _b.next(); !_c.done; _c = _b.next()) {
163
178
  var end = _c.value;
164
- var endVertex = this.getVertex(end);
179
+ var endVertex = this._getVertex(end);
165
180
  if (endVertex === null)
166
181
  return false;
167
182
  if (endVertex) {
@@ -185,15 +200,19 @@ var UndirectedGraph = /** @class */ (function (_super) {
185
200
  return true;
186
201
  };
187
202
  /**
188
- * The function removes an edge between two vertices in a graph and returns the removed edge, or null if either of the
189
- * vertices does not exist.
190
- * @param {V | VertexId} v1 - The parameter `v1` represents either a vertex object (`V`) or a vertex ID (`VertexId`).
191
- * @param {V | VertexId} v2 - V | VertexId: The second vertex or vertex ID of the edge to be removed.
192
- * @returns the removed edge (E) if it exists, or null if either of the vertices (v1 or v2) does not exist.
203
+ * The function removes an edge between two vertices in an undirected graph.
204
+ * @param {V | VertexId} v1 - The parameter `v1` represents either an `V` object or
205
+ * a `VertexId`. It is used to specify one of the vertices of the edge that needs to be removed.
206
+ * @param {V | VertexId} v2 - The parameter `v2` represents either an instance of the
207
+ * `UndirectedVertex` class or a `VertexId`. It is used to identify the second vertex of the edge that needs to be
208
+ * removed.
209
+ * @returns The function `removeEdgeBetween` returns an `E` object if an edge is successfully removed
210
+ * between the two vertices `v1` and `v2`. If either `v1` or `v2` is not found in the graph, or if there is no edge
211
+ * between them, the function returns `null`.
193
212
  */
194
213
  UndirectedGraph.prototype.removeEdgeBetween = function (v1, v2) {
195
- var vertex1 = this.getVertex(v1);
196
- var vertex2 = this.getVertex(v2);
214
+ var vertex1 = this._getVertex(v1);
215
+ var vertex2 = this._getVertex(v2);
197
216
  if (!vertex1 || !vertex2) {
198
217
  return null;
199
218
  }
@@ -209,23 +228,23 @@ var UndirectedGraph = /** @class */ (function (_super) {
209
228
  return removed;
210
229
  };
211
230
  /**
212
- * The removeEdge function removes an edge between two vertices in a graph.
213
- * @param {E} edge - The parameter "edge" is of type E, which represents an edge in a graph.
214
- * @returns The method is returning either the removed edge (of type E) or null if the edge was not found.
231
+ * The removeEdge function removes an edge between two vertices in an undirected graph.
232
+ * @param edge - An object representing an undirected edge. It has a property called "vertices" which is an array
233
+ * containing the two vertices connected by the edge.
234
+ * @returns The method is returning an UndirectedEdge object or null.
215
235
  */
216
236
  UndirectedGraph.prototype.removeEdge = function (edge) {
217
237
  return this.removeEdgeBetween(edge.vertices[0], edge.vertices[1]);
218
238
  };
219
239
  /**
220
- * The function `degreeOf` returns the degree of a vertex in a graph, which is the number of edges connected to that
221
- * vertex.
222
- * @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a `V`.
223
- * @returns The function `degreeOf` returns the degree of a vertex in a graph. The degree of a vertex is the number of
224
- * edges that are incident to that vertex.
240
+ * The function "degreeOf" returns the degree of a given vertex in an undirected graph.
241
+ * @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or an
242
+ * `V`.
243
+ * @returns the degree of the vertex.
225
244
  */
226
245
  UndirectedGraph.prototype.degreeOf = function (vertexOrId) {
227
246
  var _a;
228
- var vertex = this.getVertex(vertexOrId);
247
+ var vertex = this._getVertex(vertexOrId);
229
248
  if (vertex) {
230
249
  return ((_a = this._edges.get(vertex)) === null || _a === void 0 ? void 0 : _a.length) || 0;
231
250
  }
@@ -234,14 +253,13 @@ var UndirectedGraph = /** @class */ (function (_super) {
234
253
  }
235
254
  };
236
255
  /**
237
- * The function "edgesOf" returns an array of edges connected to a given vertex.
238
- * @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a `V`.
239
- * @returns an array of edges connected to the specified vertex. If the vertex exists in the graph, the function
240
- * returns the array of edges connected to that vertex. If the vertex does not exist in the graph, the function returns
241
- * an empty array.
256
+ * The function "edgesOf" returns an array of undirected edges connected to a given vertex or vertex ID.
257
+ * @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or an
258
+ * `V`.
259
+ * @returns an array of UndirectedEdge objects.
242
260
  */
243
261
  UndirectedGraph.prototype.edgesOf = function (vertexOrId) {
244
- var vertex = this.getVertex(vertexOrId);
262
+ var vertex = this._getVertex(vertexOrId);
245
263
  if (vertex) {
246
264
  return this._edges.get(vertex) || [];
247
265
  }
@@ -250,8 +268,8 @@ var UndirectedGraph = /** @class */ (function (_super) {
250
268
  }
251
269
  };
252
270
  /**
253
- * The function "edgeSet" returns an array of unique edges from a set of edges.
254
- * @returns The method `edgeSet()` returns an array of type `E[]`.
271
+ * The function "edgeSet" returns an array of unique undirected edges from a set of edges.
272
+ * @returns The method `edgeSet()` returns an array of `E` objects.
255
273
  */
256
274
  UndirectedGraph.prototype.edgeSet = function () {
257
275
  var edgeSet = new Set();
@@ -263,34 +281,34 @@ var UndirectedGraph = /** @class */ (function (_super) {
263
281
  return __spreadArray([], __read(edgeSet), false);
264
282
  };
265
283
  /**
266
- * The function "getEdgesOf" returns an array of edges connected to a given vertex or vertex ID.
267
- * @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can accept either a vertex object (`V`) or a vertex ID
268
- * (`VertexId`).
269
- * @returns an array of edges (E[]) that are connected to the specified vertex or vertex ID.
284
+ * The function "getEdgesOf" returns an array of undirected edges connected to a given vertex or vertex ID.
285
+ * @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can be either an
286
+ * `V` object or a `VertexId`.
287
+ * @returns The function `getEdgesOf` returns an array of `E` objects.
270
288
  */
271
289
  UndirectedGraph.prototype.getEdgesOf = function (vertexOrId) {
272
- var vertex = this.getVertex(vertexOrId);
290
+ var vertex = this._getVertex(vertexOrId);
273
291
  if (!vertex) {
274
292
  return [];
275
293
  }
276
294
  return this._edges.get(vertex) || [];
277
295
  };
278
296
  /**
279
- * The function "getNeighbors" returns an array of neighboring vertices of a given vertex.
280
- * @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can be either a vertex object (`V`) or a vertex ID
281
- * (`VertexId`).
282
- * @returns an array of vertices (V[]).
297
+ * The function `getNeighbors` returns an array of neighboring vertices of a given vertex in an undirected graph.
298
+ * @param {V | VertexId} vertexOrId - The `vertexOrId` parameter can be either an
299
+ * `V` object or a `VertexId`. It represents the vertex for which we want to find the neighbors.
300
+ * @returns an array of UndirectedVertex objects.
283
301
  */
284
302
  UndirectedGraph.prototype.getNeighbors = function (vertexOrId) {
285
303
  var e_2, _a;
286
304
  var neighbors = [];
287
- var vertex = this.getVertex(vertexOrId);
305
+ var vertex = this._getVertex(vertexOrId);
288
306
  if (vertex) {
289
307
  var neighborEdges = this.getEdgesOf(vertex);
290
308
  try {
291
309
  for (var neighborEdges_1 = __values(neighborEdges), neighborEdges_1_1 = neighborEdges_1.next(); !neighborEdges_1_1.done; neighborEdges_1_1 = neighborEdges_1.next()) {
292
310
  var edge = neighborEdges_1_1.value;
293
- var neighbor = this.getVertex(edge.vertices.filter(function (e) { return e !== vertex.id; })[0]);
311
+ var neighbor = this._getVertex(edge.vertices.filter(function (e) { return e !== vertex.id; })[0]);
294
312
  if (neighbor) {
295
313
  neighbors.push(neighbor);
296
314
  }
@@ -307,19 +325,19 @@ var UndirectedGraph = /** @class */ (function (_super) {
307
325
  return neighbors;
308
326
  };
309
327
  /**
310
- * The function "getEndsOfEdge" returns the vertices at the ends of a given edge, or null if the edge does not exist in
311
- * the graph.
312
- * @param {E} edge - The parameter "edge" is of type E, which represents an edge in a graph.
313
- * @returns The function `getEndsOfEdge` returns an array containing two vertices `[V, V]` if the edge exists in the
314
- * graph and both vertices are found. If the edge does not exist or one or both vertices are not found, it returns
315
- * `null`.
328
+ * The function "getEndsOfEdge" returns the two vertices that form the ends of a given undirected edge, or null if the
329
+ * edge does not exist in the graph.
330
+ * @param edge - An object representing an undirected edge in a graph. It has a property called "vertices" which is an
331
+ * array containing two vertices that the edge connects.
332
+ * @returns The function `getEndsOfEdge` returns an array containing the two ends of the given `edge` if the edge
333
+ * exists in the graph. If the edge does not exist, it returns `null`.
316
334
  */
317
335
  UndirectedGraph.prototype.getEndsOfEdge = function (edge) {
318
336
  if (!this.hasEdge(edge.vertices[0], edge.vertices[1])) {
319
337
  return null;
320
338
  }
321
- var v1 = this.getVertex(edge.vertices[0]);
322
- var v2 = this.getVertex(edge.vertices[1]);
339
+ var v1 = this._getVertex(edge.vertices[0]);
340
+ var v2 = this._getVertex(edge.vertices[1]);
323
341
  if (v1 && v2) {
324
342
  return [v1, v2];
325
343
  }
@@ -327,6 +345,9 @@ var UndirectedGraph = /** @class */ (function (_super) {
327
345
  return null;
328
346
  }
329
347
  };
348
+ UndirectedGraph.prototype._setEdges = function (v) {
349
+ this._edges = v;
350
+ };
330
351
  return UndirectedGraph;
331
352
  }(abstract_graph_1.AbstractGraph));
332
353
  exports.UndirectedGraph = UndirectedGraph;
@@ -9,11 +9,6 @@ export declare class CoordinateMap<V> extends Map<any, V> {
9
9
  constructor(joint?: string);
10
10
  protected _joint: string;
11
11
  get joint(): string;
12
- protected set joint(v: string);
13
- /**
14
- * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
15
- */
16
- getJoint(): string;
17
12
  /**
18
13
  * The "has" function overrides the base class's "has" function and checks if a key exists in the map by joining the
19
14
  * key array with a specified delimiter.
@@ -46,4 +41,5 @@ export declare class CoordinateMap<V> extends Map<any, V> {
46
41
  * `key` array joined together using the `_joint` property.
47
42
  */
48
43
  delete(key: number[]): boolean;
44
+ protected _setJoint(v: string): void;
49
45
  }
@@ -36,18 +36,9 @@ var CoordinateMap = /** @class */ (function (_super) {
36
36
  get: function () {
37
37
  return this._joint;
38
38
  },
39
- set: function (v) {
40
- this._joint = v;
41
- },
42
39
  enumerable: false,
43
40
  configurable: true
44
41
  });
45
- /**
46
- * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
47
- */
48
- CoordinateMap.prototype.getJoint = function () {
49
- return this._joint;
50
- };
51
42
  /**
52
43
  * The "has" function overrides the base class's "has" function and checks if a key exists in the map by joining the
53
44
  * key array with a specified delimiter.
@@ -88,6 +79,9 @@ var CoordinateMap = /** @class */ (function (_super) {
88
79
  CoordinateMap.prototype.delete = function (key) {
89
80
  return _super.prototype.delete.call(this, key.join(this._joint));
90
81
  };
82
+ CoordinateMap.prototype._setJoint = function (v) {
83
+ this._joint = v;
84
+ };
91
85
  return CoordinateMap;
92
86
  }(Map));
93
87
  exports.CoordinateMap = CoordinateMap;
@@ -5,15 +5,10 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- export declare class CoordinateSet extends Set {
8
+ export declare class CoordinateSet extends Set<any> {
9
9
  constructor(joint?: string);
10
10
  protected _joint: string;
11
11
  get joint(): string;
12
- protected set joint(v: string);
13
- /**
14
- * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
15
- */
16
- getJoint(): string;
17
12
  /**
18
13
  * The "has" function overrides the "has" method of the superclass and checks if a value exists in an array after
19
14
  * joining its elements with a specified separator.
@@ -38,4 +33,5 @@ export declare class CoordinateSet extends Set {
38
33
  * `value` array joined together using the `_joint` property.
39
34
  */
40
35
  delete(value: number[]): boolean;
36
+ protected _setJoint(v: string): void;
41
37
  }
@@ -36,18 +36,9 @@ var CoordinateSet = /** @class */ (function (_super) {
36
36
  get: function () {
37
37
  return this._joint;
38
38
  },
39
- set: function (v) {
40
- this._joint = v;
41
- },
42
39
  enumerable: false,
43
40
  configurable: true
44
41
  });
45
- /**
46
- * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
47
- */
48
- CoordinateSet.prototype.getJoint = function () {
49
- return this._joint;
50
- };
51
42
  /**
52
43
  * The "has" function overrides the "has" method of the superclass and checks if a value exists in an array after
53
44
  * joining its elements with a specified separator.
@@ -78,6 +69,9 @@ var CoordinateSet = /** @class */ (function (_super) {
78
69
  CoordinateSet.prototype.delete = function (value) {
79
70
  return _super.prototype.delete.call(this, value.join(this._joint));
80
71
  };
72
+ CoordinateSet.prototype._setJoint = function (v) {
73
+ this._joint = v;
74
+ };
81
75
  return CoordinateSet;
82
76
  }(Set));
83
77
  exports.CoordinateSet = CoordinateSet;