data-structure-typed 0.9.16 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +665 -172
  3. package/dist/bundle.js +2 -0
  4. package/dist/bundle.js.LICENSE.txt +13 -0
  5. package/dist/data-structures/binary-tree/aa-tree.js +2 -5
  6. package/dist/data-structures/binary-tree/abstract-binary-tree.d.ts +364 -0
  7. package/dist/data-structures/binary-tree/abstract-binary-tree.js +1308 -0
  8. package/dist/data-structures/binary-tree/avl-tree.d.ts +85 -14
  9. package/dist/data-structures/binary-tree/avl-tree.js +142 -116
  10. package/dist/data-structures/binary-tree/b-tree.js +2 -5
  11. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +39 -1
  12. package/dist/data-structures/binary-tree/binary-indexed-tree.js +54 -13
  13. package/dist/data-structures/binary-tree/binary-tree.d.ts +29 -126
  14. package/dist/data-structures/binary-tree/binary-tree.js +31 -1093
  15. package/dist/data-structures/binary-tree/bst.d.ts +117 -23
  16. package/dist/data-structures/binary-tree/bst.js +233 -240
  17. package/dist/data-structures/binary-tree/index.d.ts +1 -0
  18. package/dist/data-structures/binary-tree/index.js +1 -0
  19. package/dist/data-structures/binary-tree/rb-tree.d.ts +18 -1
  20. package/dist/data-structures/binary-tree/rb-tree.js +40 -5
  21. package/dist/data-structures/binary-tree/segment-tree.d.ts +61 -11
  22. package/dist/data-structures/binary-tree/segment-tree.js +126 -93
  23. package/dist/data-structures/binary-tree/splay-tree.js +2 -5
  24. package/dist/data-structures/binary-tree/tree-multiset.d.ts +213 -6
  25. package/dist/data-structures/binary-tree/tree-multiset.js +687 -34
  26. package/dist/data-structures/binary-tree/two-three-tree.js +2 -5
  27. package/dist/data-structures/graph/abstract-graph.d.ts +270 -36
  28. package/dist/data-structures/graph/abstract-graph.js +610 -572
  29. package/dist/data-structures/graph/directed-graph.d.ts +173 -16
  30. package/dist/data-structures/graph/directed-graph.js +345 -313
  31. package/dist/data-structures/graph/index.d.ts +1 -0
  32. package/dist/data-structures/graph/index.js +1 -0
  33. package/dist/data-structures/graph/map-graph.d.ts +79 -0
  34. package/dist/data-structures/graph/map-graph.js +111 -0
  35. package/dist/data-structures/graph/undirected-graph.d.ts +111 -9
  36. package/dist/data-structures/graph/undirected-graph.js +203 -178
  37. package/dist/data-structures/hash/coordinate-map.d.ts +38 -1
  38. package/dist/data-structures/hash/coordinate-map.js +59 -36
  39. package/dist/data-structures/hash/coordinate-set.d.ts +32 -2
  40. package/dist/data-structures/hash/coordinate-set.js +49 -33
  41. package/dist/data-structures/hash/hash-table.d.ts +2 -1
  42. package/dist/data-structures/hash/hash-table.js +4 -0
  43. package/dist/data-structures/hash/pair.d.ts +2 -1
  44. package/dist/data-structures/hash/pair.js +4 -0
  45. package/dist/data-structures/hash/tree-map.d.ts +2 -1
  46. package/dist/data-structures/hash/tree-map.js +4 -0
  47. package/dist/data-structures/hash/tree-set.d.ts +2 -1
  48. package/dist/data-structures/hash/tree-set.js +4 -0
  49. package/dist/data-structures/heap/heap.d.ts +62 -45
  50. package/dist/data-structures/heap/heap.js +124 -86
  51. package/dist/data-structures/heap/max-heap.d.ts +13 -5
  52. package/dist/data-structures/heap/max-heap.js +18 -28
  53. package/dist/data-structures/heap/min-heap.d.ts +14 -5
  54. package/dist/data-structures/heap/min-heap.js +19 -28
  55. package/dist/data-structures/index.d.ts +1 -1
  56. package/dist/data-structures/index.js +1 -1
  57. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +193 -56
  58. package/dist/data-structures/linked-list/doubly-linked-list.js +484 -220
  59. package/dist/data-structures/linked-list/index.d.ts +1 -0
  60. package/dist/data-structures/linked-list/index.js +1 -0
  61. package/dist/data-structures/linked-list/singly-linked-list.d.ts +117 -315
  62. package/dist/data-structures/linked-list/singly-linked-list.js +374 -727
  63. package/dist/data-structures/linked-list/skip-linked-list.d.ts +2 -1
  64. package/dist/data-structures/linked-list/skip-linked-list.js +4 -0
  65. package/dist/data-structures/matrix/matrix.d.ts +12 -0
  66. package/dist/data-structures/matrix/matrix.js +21 -8
  67. package/dist/data-structures/matrix/matrix2d.d.ts +85 -2
  68. package/dist/data-structures/matrix/matrix2d.js +146 -80
  69. package/dist/data-structures/matrix/navigator.d.ts +36 -1
  70. package/dist/data-structures/matrix/navigator.js +46 -37
  71. package/dist/data-structures/matrix/vector2d.d.ts +142 -15
  72. package/dist/data-structures/matrix/vector2d.js +215 -109
  73. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +12 -2
  74. package/dist/data-structures/priority-queue/max-priority-queue.js +33 -26
  75. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +12 -2
  76. package/dist/data-structures/priority-queue/min-priority-queue.js +34 -26
  77. package/dist/data-structures/priority-queue/priority-queue.d.ts +153 -3
  78. package/dist/data-structures/priority-queue/priority-queue.js +244 -143
  79. package/dist/data-structures/queue/deque.d.ts +141 -13
  80. package/dist/data-structures/queue/deque.js +200 -82
  81. package/dist/data-structures/queue/queue.d.ts +65 -38
  82. package/dist/data-structures/queue/queue.js +110 -66
  83. package/dist/data-structures/stack/stack.d.ts +27 -32
  84. package/dist/data-structures/stack/stack.js +47 -53
  85. package/dist/data-structures/tree/index.d.ts +1 -0
  86. package/dist/data-structures/tree/index.js +17 -0
  87. package/dist/data-structures/tree/tree.d.ts +14 -0
  88. package/dist/data-structures/tree/tree.js +60 -0
  89. package/dist/data-structures/trie/trie.d.ts +33 -10
  90. package/dist/data-structures/trie/trie.js +123 -208
  91. package/dist/index.d.ts +3 -0
  92. package/dist/index.js +3 -0
  93. package/dist/interfaces/abstract-binary-tree.d.ts +90 -0
  94. package/dist/interfaces/abstract-graph.d.ts +17 -0
  95. package/dist/interfaces/avl-tree.d.ts +9 -0
  96. package/dist/interfaces/binary-tree.d.ts +6 -0
  97. package/dist/interfaces/bst.d.ts +17 -0
  98. package/dist/interfaces/directed-graph.d.ts +12 -0
  99. package/{src/data-structures/types/index.ts → dist/interfaces/index.d.ts} +10 -8
  100. package/dist/interfaces/index.js +31 -0
  101. package/{src/data-structures/hash/hash-table.ts → dist/interfaces/priority-queue.d.ts} +1 -1
  102. package/dist/interfaces/rb-tree.d.ts +8 -0
  103. package/dist/interfaces/segment-tree.d.ts +1 -0
  104. package/dist/interfaces/singly-linked-list.d.ts +1 -0
  105. package/dist/interfaces/singly-linked-list.js +2 -0
  106. package/dist/interfaces/tree-multiset.d.ts +7 -0
  107. package/dist/interfaces/tree-multiset.js +2 -0
  108. package/dist/interfaces/undirected-graph.d.ts +5 -0
  109. package/dist/interfaces/undirected-graph.js +2 -0
  110. package/dist/types/data-structures/abstract-binary-tree.d.ts +34 -0
  111. package/dist/types/data-structures/abstract-binary-tree.js +25 -0
  112. package/dist/types/data-structures/abstract-graph.d.ts +11 -0
  113. package/dist/types/data-structures/abstract-graph.js +2 -0
  114. package/dist/types/data-structures/avl-tree.d.ts +4 -0
  115. package/dist/types/data-structures/avl-tree.js +2 -0
  116. package/dist/types/data-structures/binary-tree.d.ts +4 -0
  117. package/dist/types/data-structures/binary-tree.js +2 -0
  118. package/dist/types/data-structures/bst.d.ts +13 -0
  119. package/dist/types/data-structures/bst.js +9 -0
  120. package/dist/types/data-structures/directed-graph.d.ts +6 -0
  121. package/dist/types/data-structures/directed-graph.js +9 -0
  122. package/dist/types/data-structures/doubly-linked-list.d.ts +1 -0
  123. package/dist/types/data-structures/doubly-linked-list.js +2 -0
  124. package/dist/types/data-structures/heap.d.ts +3 -0
  125. package/dist/types/data-structures/heap.js +2 -0
  126. package/dist/{data-structures/types → types/data-structures}/index.d.ts +3 -1
  127. package/dist/{data-structures/types → types/data-structures}/index.js +3 -1
  128. package/dist/types/data-structures/map-graph.d.ts +1 -0
  129. package/dist/types/data-structures/map-graph.js +2 -0
  130. package/dist/{data-structures/types → types/data-structures}/navigator.d.ts +2 -2
  131. package/dist/types/data-structures/navigator.js +2 -0
  132. package/dist/{data-structures/types → types/data-structures}/priority-queue.d.ts +2 -2
  133. package/dist/types/data-structures/priority-queue.js +2 -0
  134. package/dist/types/data-structures/rb-tree.d.ts +8 -0
  135. package/dist/types/data-structures/rb-tree.js +8 -0
  136. package/dist/types/data-structures/segment-tree.js +2 -0
  137. package/dist/types/data-structures/singly-linked-list.d.ts +1 -0
  138. package/dist/types/data-structures/singly-linked-list.js +2 -0
  139. package/dist/types/data-structures/tree-multiset.d.ts +4 -0
  140. package/dist/types/data-structures/tree-multiset.js +2 -0
  141. package/dist/types/helpers.d.ts +1 -0
  142. package/dist/types/helpers.js +2 -0
  143. package/dist/types/index.d.ts +3 -0
  144. package/dist/types/index.js +19 -0
  145. package/dist/types/utils/index.d.ts +2 -0
  146. package/dist/types/utils/index.js +18 -0
  147. package/dist/types/utils/utils.d.ts +7 -0
  148. package/dist/types/utils/utils.js +2 -0
  149. package/dist/types/utils/validate-type.d.ts +19 -0
  150. package/dist/types/utils/validate-type.js +2 -0
  151. package/dist/utils/utils.d.ts +17 -103
  152. package/dist/utils/utils.js +40 -625
  153. package/package.json +96 -23
  154. package/.idea/data-structure-typed.iml +0 -12
  155. package/.idea/modules.xml +0 -8
  156. package/.idea/vcs.xml +0 -6
  157. package/dist/data-structures/trampoline.d.ts +0 -16
  158. package/dist/data-structures/trampoline.js +0 -130
  159. package/dist/data-structures/types/abstract-graph.d.ts +0 -29
  160. package/dist/data-structures/types/avl-tree.d.ts +0 -5
  161. package/dist/data-structures/types/binary-tree.d.ts +0 -16
  162. package/dist/data-structures/types/bst.d.ts +0 -7
  163. package/dist/data-structures/types/directed-graph.d.ts +0 -10
  164. package/dist/data-structures/types/doubly-linked-list.d.ts +0 -1
  165. package/dist/data-structures/types/heap.d.ts +0 -7
  166. package/dist/data-structures/types/singly-linked-list.d.ts +0 -5
  167. package/dist/data-structures/types/tree-multiset.d.ts +0 -5
  168. package/dist/data-structures/types/utils.d.ts +0 -52
  169. package/dist/data-structures/types/utils.js +0 -54
  170. package/src/data-structures/binary-tree/aa-tree.ts +0 -3
  171. package/src/data-structures/binary-tree/avl-tree.ts +0 -227
  172. package/src/data-structures/binary-tree/b-tree.ts +0 -3
  173. package/src/data-structures/binary-tree/binary-indexed-tree.ts +0 -33
  174. package/src/data-structures/binary-tree/binary-tree.ts +0 -1133
  175. package/src/data-structures/binary-tree/bst.ts +0 -395
  176. package/src/data-structures/binary-tree/diagrams/avl-tree-inserting.gif +0 -0
  177. package/src/data-structures/binary-tree/diagrams/bst-rotation.gif +0 -0
  178. package/src/data-structures/binary-tree/diagrams/segment-tree.png +0 -0
  179. package/src/data-structures/binary-tree/index.ts +0 -11
  180. package/src/data-structures/binary-tree/rb-tree.ts +0 -3
  181. package/src/data-structures/binary-tree/segment-tree.ts +0 -172
  182. package/src/data-structures/binary-tree/splay-tree.ts +0 -3
  183. package/src/data-structures/binary-tree/tree-multiset.ts +0 -18
  184. package/src/data-structures/binary-tree/two-three-tree.ts +0 -3
  185. package/src/data-structures/diagrams/README.md +0 -7
  186. package/src/data-structures/graph/abstract-graph.ts +0 -753
  187. package/src/data-structures/graph/diagrams/adjacency-list-pros-cons.png +0 -0
  188. package/src/data-structures/graph/diagrams/adjacency-list.png +0 -0
  189. package/src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.png +0 -0
  190. package/src/data-structures/graph/diagrams/adjacency-matrix.png +0 -0
  191. package/src/data-structures/graph/diagrams/dfs-can-do.png +0 -0
  192. package/src/data-structures/graph/diagrams/edge-list-pros-cons.png +0 -0
  193. package/src/data-structures/graph/diagrams/edge-list.png +0 -0
  194. package/src/data-structures/graph/diagrams/max-flow.png +0 -0
  195. package/src/data-structures/graph/diagrams/mst.png +0 -0
  196. package/src/data-structures/graph/diagrams/tarjan-articulation-point-bridge.png +0 -0
  197. package/src/data-structures/graph/diagrams/tarjan-complicate-simple.png +0 -0
  198. package/src/data-structures/graph/diagrams/tarjan-strongly-connected-component.png +0 -0
  199. package/src/data-structures/graph/diagrams/tarjan.mp4 +0 -0
  200. package/src/data-structures/graph/directed-graph.ts +0 -306
  201. package/src/data-structures/graph/index.ts +0 -3
  202. package/src/data-structures/graph/undirected-graph.ts +0 -155
  203. package/src/data-structures/hash/coordinate-map.ts +0 -24
  204. package/src/data-structures/hash/coordinate-set.ts +0 -20
  205. package/src/data-structures/hash/index.ts +0 -6
  206. package/src/data-structures/heap/heap.ts +0 -127
  207. package/src/data-structures/heap/index.ts +0 -3
  208. package/src/data-structures/heap/max-heap.ts +0 -23
  209. package/src/data-structures/heap/min-heap.ts +0 -25
  210. package/src/data-structures/index.ts +0 -12
  211. package/src/data-structures/linked-list/doubly-linked-list.ts +0 -250
  212. package/src/data-structures/linked-list/index.ts +0 -2
  213. package/src/data-structures/linked-list/singly-linked-list.ts +0 -736
  214. package/src/data-structures/linked-list/skip-linked-list.ts +0 -1
  215. package/src/data-structures/matrix/index.ts +0 -4
  216. package/src/data-structures/matrix/matrix.ts +0 -13
  217. package/src/data-structures/matrix/matrix2d.ts +0 -125
  218. package/src/data-structures/matrix/navigator.ts +0 -87
  219. package/src/data-structures/matrix/vector2d.ts +0 -189
  220. package/src/data-structures/priority-queue/index.ts +0 -3
  221. package/src/data-structures/priority-queue/max-priority-queue.ts +0 -13
  222. package/src/data-structures/priority-queue/min-priority-queue.ts +0 -13
  223. package/src/data-structures/priority-queue/priority-queue.ts +0 -200
  224. package/src/data-structures/queue/deque.ts +0 -139
  225. package/src/data-structures/queue/index.ts +0 -2
  226. package/src/data-structures/queue/queue.ts +0 -122
  227. package/src/data-structures/stack/index.ts +0 -1
  228. package/src/data-structures/stack/stack.ts +0 -103
  229. package/src/data-structures/trampoline.ts +0 -51
  230. package/src/data-structures/trie/index.ts +0 -1
  231. package/src/data-structures/trie/trie.ts +0 -203
  232. package/src/data-structures/types/abstract-graph.ts +0 -51
  233. package/src/data-structures/types/avl-tree.ts +0 -6
  234. package/src/data-structures/types/binary-tree.ts +0 -15
  235. package/src/data-structures/types/bst.ts +0 -5
  236. package/src/data-structures/types/directed-graph.ts +0 -18
  237. package/src/data-structures/types/doubly-linked-list.ts +0 -1
  238. package/src/data-structures/types/heap.ts +0 -8
  239. package/src/data-structures/types/navigator.ts +0 -12
  240. package/src/data-structures/types/priority-queue.ts +0 -9
  241. package/src/data-structures/types/segment-tree.ts +0 -1
  242. package/src/data-structures/types/singly-linked-list.ts +0 -15
  243. package/src/data-structures/types/tree-multiset.ts +0 -3
  244. package/src/data-structures/types/utils.ts +0 -173
  245. package/src/index.ts +0 -1
  246. package/src/utils/index.ts +0 -1
  247. package/src/utils/utils.ts +0 -505
  248. package/tsconfig.json +0 -56
  249. /package/dist/{data-structures/types/abstract-graph.js → interfaces/abstract-binary-tree.js} +0 -0
  250. /package/dist/{data-structures/types/avl-tree.js → interfaces/abstract-graph.js} +0 -0
  251. /package/dist/{data-structures/types/binary-tree.js → interfaces/avl-tree.js} +0 -0
  252. /package/dist/{data-structures/types/bst.js → interfaces/binary-tree.js} +0 -0
  253. /package/dist/{data-structures/types/directed-graph.js → interfaces/bst.js} +0 -0
  254. /package/dist/{data-structures/types/doubly-linked-list.js → interfaces/directed-graph.js} +0 -0
  255. /package/{src/data-structures/hash/pair.ts → dist/interfaces/doubly-linked-list.d.ts} +0 -0
  256. /package/dist/{data-structures/types/heap.js → interfaces/doubly-linked-list.js} +0 -0
  257. /package/{src/data-structures/hash/tree-map.ts → dist/interfaces/heap.d.ts} +0 -0
  258. /package/dist/{data-structures/types/navigator.js → interfaces/heap.js} +0 -0
  259. /package/{src/data-structures/hash/tree-set.ts → dist/interfaces/navigator.d.ts} +0 -0
  260. /package/dist/{data-structures/types/priority-queue.js → interfaces/navigator.js} +0 -0
  261. /package/dist/{data-structures/types/segment-tree.js → interfaces/priority-queue.js} +0 -0
  262. /package/dist/{data-structures/types/singly-linked-list.js → interfaces/rb-tree.js} +0 -0
  263. /package/dist/{data-structures/types/tree-multiset.js → interfaces/segment-tree.js} +0 -0
  264. /package/dist/{data-structures/types → types/data-structures}/segment-tree.d.ts +0 -0
@@ -1,3 +1,4 @@
1
1
  export * from './abstract-graph';
2
2
  export * from './directed-graph';
3
3
  export * from './undirected-graph';
4
+ export * from './map-graph';
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./abstract-graph"), exports);
18
18
  __exportStar(require("./directed-graph"), exports);
19
19
  __exportStar(require("./undirected-graph"), exports);
20
+ __exportStar(require("./map-graph"), exports);
@@ -0,0 +1,79 @@
1
+ import { MapGraphCoordinate, VertexId } from '../../types';
2
+ import { DirectedEdge, DirectedGraph, DirectedVertex } from './directed-graph';
3
+ export declare class MapVertex<T = any> extends DirectedVertex<T> {
4
+ /**
5
+ * The constructor function initializes an object with an id, latitude, longitude, and an optional value.
6
+ * @param {VertexId} id - The `id` parameter is of type `VertexId` and represents the identifier of the vertex.
7
+ * @param {number} lat - The "lat" parameter represents the latitude of a vertex. Latitude is a geographic coordinate
8
+ * that specifies the north-south position of a point on the Earth's surface. It is measured in degrees, with positive
9
+ * values representing points north of the equator and negative values representing points south of the equator.
10
+ * @param {number} long - The "long" parameter represents the longitude of a location. Longitude is a geographic
11
+ * coordinate that specifies the east-west position of a point on the Earth's surface. It is measured in degrees, with
12
+ * values ranging from -180 to 180.
13
+ * @param {T} [val] - The "val" parameter is an optional value of type T. It is not required to be provided when
14
+ * creating an instance of the class.
15
+ */
16
+ constructor(id: VertexId, lat: number, long: number, val?: T);
17
+ private _lat;
18
+ get lat(): number;
19
+ set lat(value: number);
20
+ private _long;
21
+ get long(): number;
22
+ set long(value: number);
23
+ }
24
+ export declare class MapEdge<T = any> extends DirectedEdge<T> {
25
+ /**
26
+ * The constructor function initializes a new instance of a class with the given source, destination, weight, and
27
+ * value.
28
+ * @param {VertexId} src - The `src` parameter is the source vertex ID. It represents the starting point of an edge in
29
+ * a graph.
30
+ * @param {VertexId} dest - The `dest` parameter is the identifier of the destination vertex for an edge.
31
+ * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
32
+ * @param {T} [val] - The "val" parameter is an optional parameter of type T. It is used to store additional
33
+ * information or data associated with the edge.
34
+ */
35
+ constructor(src: VertexId, dest: VertexId, weight?: number, val?: T);
36
+ }
37
+ export declare class MapGraph<V extends MapVertex<V['val']> = MapVertex, E extends MapEdge = MapEdge> extends DirectedGraph<V, E> {
38
+ /**
39
+ * The constructor function initializes the origin and bottomRight properties of a MapGraphCoordinate object.
40
+ * @param {MapGraphCoordinate} origin - The `origin` parameter is a `MapGraphCoordinate` object that represents the
41
+ * starting point or reference point of the map graph. It defines the coordinates of the top-left corner of the map
42
+ * graph.
43
+ * @param {MapGraphCoordinate} [bottomRight] - The `bottomRight` parameter is an optional parameter of type
44
+ * `MapGraphCoordinate`. It represents the bottom right coordinate of a map graph. If this parameter is not provided,
45
+ * it will default to `undefined`.
46
+ */
47
+ constructor(origin: MapGraphCoordinate, bottomRight?: MapGraphCoordinate);
48
+ private _origin;
49
+ get origin(): MapGraphCoordinate;
50
+ set origin(value: MapGraphCoordinate);
51
+ private _bottomRight;
52
+ get bottomRight(): MapGraphCoordinate | undefined;
53
+ set bottomRight(value: MapGraphCoordinate | undefined);
54
+ /**
55
+ * The function creates a new vertex with the given id, value, latitude, and longitude.
56
+ * @param {VertexId} id - The id parameter is the unique identifier for the vertex. It is of type VertexId, which could
57
+ * be a string or a number depending on how you define it in your code.
58
+ * @param [val] - The `val` parameter is an optional value that can be assigned to the `val` property of the vertex. It
59
+ * is of type `V['val']`, which means it should be of the same type as the `val` property of the vertex class `V`.
60
+ * @param {number} lat - The `lat` parameter represents the latitude of the vertex. It is a number that specifies the
61
+ * position of the vertex on the Earth's surface in the north-south direction.
62
+ * @param {number} long - The `long` parameter represents the longitude coordinate of the vertex.
63
+ * @returns The method is returning a new instance of the `MapVertex` class, casted as type `V`.
64
+ */
65
+ createVertex(id: VertexId, val?: V['val'], lat?: number, long?: number): V;
66
+ /**
67
+ * The function creates a new instance of a MapEdge with the given source, destination, weight, and value.
68
+ * @param {VertexId} src - The source vertex ID of the edge. It represents the starting point of the edge.
69
+ * @param {VertexId} dest - The `dest` parameter is the identifier of the destination vertex for the edge being
70
+ * created.
71
+ * @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the edge. It
72
+ * is used to assign a numerical value to the edge, which can be used in algorithms such as shortest path algorithms.
73
+ * If the weight is not provided, it can be set to a default value or left undefined.
74
+ * @param [val] - The `val` parameter is an optional value that can be assigned to the edge. It can be of any type,
75
+ * depending on the specific implementation of the `MapEdge` class.
76
+ * @returns a new instance of the `MapEdge` class, casted as type `E`.
77
+ */
78
+ createEdge(src: VertexId, dest: VertexId, weight?: number, val?: E['val']): E;
79
+ }
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MapGraph = exports.MapEdge = exports.MapVertex = void 0;
4
+ const directed_graph_1 = require("./directed-graph");
5
+ class MapVertex extends directed_graph_1.DirectedVertex {
6
+ /**
7
+ * The constructor function initializes an object with an id, latitude, longitude, and an optional value.
8
+ * @param {VertexId} id - The `id` parameter is of type `VertexId` and represents the identifier of the vertex.
9
+ * @param {number} lat - The "lat" parameter represents the latitude of a vertex. Latitude is a geographic coordinate
10
+ * that specifies the north-south position of a point on the Earth's surface. It is measured in degrees, with positive
11
+ * values representing points north of the equator and negative values representing points south of the equator.
12
+ * @param {number} long - The "long" parameter represents the longitude of a location. Longitude is a geographic
13
+ * coordinate that specifies the east-west position of a point on the Earth's surface. It is measured in degrees, with
14
+ * values ranging from -180 to 180.
15
+ * @param {T} [val] - The "val" parameter is an optional value of type T. It is not required to be provided when
16
+ * creating an instance of the class.
17
+ */
18
+ constructor(id, lat, long, val) {
19
+ super(id, val);
20
+ this._lat = lat;
21
+ this._long = long;
22
+ }
23
+ get lat() {
24
+ return this._lat;
25
+ }
26
+ set lat(value) {
27
+ this._lat = value;
28
+ }
29
+ get long() {
30
+ return this._long;
31
+ }
32
+ set long(value) {
33
+ this._long = value;
34
+ }
35
+ }
36
+ exports.MapVertex = MapVertex;
37
+ class MapEdge extends directed_graph_1.DirectedEdge {
38
+ /**
39
+ * The constructor function initializes a new instance of a class with the given source, destination, weight, and
40
+ * value.
41
+ * @param {VertexId} src - The `src` parameter is the source vertex ID. It represents the starting point of an edge in
42
+ * a graph.
43
+ * @param {VertexId} dest - The `dest` parameter is the identifier of the destination vertex for an edge.
44
+ * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
45
+ * @param {T} [val] - The "val" parameter is an optional parameter of type T. It is used to store additional
46
+ * information or data associated with the edge.
47
+ */
48
+ constructor(src, dest, weight, val) {
49
+ super(src, dest, weight, val);
50
+ }
51
+ }
52
+ exports.MapEdge = MapEdge;
53
+ class MapGraph extends directed_graph_1.DirectedGraph {
54
+ /**
55
+ * The constructor function initializes the origin and bottomRight properties of a MapGraphCoordinate object.
56
+ * @param {MapGraphCoordinate} origin - The `origin` parameter is a `MapGraphCoordinate` object that represents the
57
+ * starting point or reference point of the map graph. It defines the coordinates of the top-left corner of the map
58
+ * graph.
59
+ * @param {MapGraphCoordinate} [bottomRight] - The `bottomRight` parameter is an optional parameter of type
60
+ * `MapGraphCoordinate`. It represents the bottom right coordinate of a map graph. If this parameter is not provided,
61
+ * it will default to `undefined`.
62
+ */
63
+ constructor(origin, bottomRight) {
64
+ super();
65
+ this._origin = [0, 0];
66
+ this._origin = origin;
67
+ this._bottomRight = bottomRight;
68
+ }
69
+ get origin() {
70
+ return this._origin;
71
+ }
72
+ set origin(value) {
73
+ this._origin = value;
74
+ }
75
+ get bottomRight() {
76
+ return this._bottomRight;
77
+ }
78
+ set bottomRight(value) {
79
+ this._bottomRight = value;
80
+ }
81
+ /**
82
+ * The function creates a new vertex with the given id, value, latitude, and longitude.
83
+ * @param {VertexId} id - The id parameter is the unique identifier for the vertex. It is of type VertexId, which could
84
+ * be a string or a number depending on how you define it in your code.
85
+ * @param [val] - The `val` parameter is an optional value that can be assigned to the `val` property of the vertex. It
86
+ * is of type `V['val']`, which means it should be of the same type as the `val` property of the vertex class `V`.
87
+ * @param {number} lat - The `lat` parameter represents the latitude of the vertex. It is a number that specifies the
88
+ * position of the vertex on the Earth's surface in the north-south direction.
89
+ * @param {number} long - The `long` parameter represents the longitude coordinate of the vertex.
90
+ * @returns The method is returning a new instance of the `MapVertex` class, casted as type `V`.
91
+ */
92
+ createVertex(id, val, lat = this.origin[0], long = this.origin[1]) {
93
+ return new MapVertex(id, lat, long, val);
94
+ }
95
+ /**
96
+ * The function creates a new instance of a MapEdge with the given source, destination, weight, and value.
97
+ * @param {VertexId} src - The source vertex ID of the edge. It represents the starting point of the edge.
98
+ * @param {VertexId} dest - The `dest` parameter is the identifier of the destination vertex for the edge being
99
+ * created.
100
+ * @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the edge. It
101
+ * is used to assign a numerical value to the edge, which can be used in algorithms such as shortest path algorithms.
102
+ * If the weight is not provided, it can be set to a default value or left undefined.
103
+ * @param [val] - The `val` parameter is an optional value that can be assigned to the edge. It can be of any type,
104
+ * depending on the specific implementation of the `MapEdge` class.
105
+ * @returns a new instance of the `MapEdge` class, casted as type `E`.
106
+ */
107
+ createEdge(src, dest, weight, val) {
108
+ return new MapEdge(src, dest, weight, val);
109
+ }
110
+ }
111
+ exports.MapGraph = MapGraph;
@@ -1,25 +1,127 @@
1
1
  import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';
2
- import type { VertexId } from '../types';
3
- export declare class UndirectedVertex extends AbstractVertex {
4
- constructor(id: VertexId);
2
+ import type { VertexId } from '../../types';
3
+ import { IUNDirectedGraph } from '../../interfaces';
4
+ export declare class UndirectedVertex<T = number> extends AbstractVertex<T> {
5
+ /**
6
+ * The constructor function initializes a vertex with an optional value.
7
+ * @param {VertexId} id - The `id` parameter is of type `VertexId` and represents the identifier of the vertex. It is
8
+ * used to uniquely identify the vertex within a graph or network.
9
+ * @param {T} [val] - The "val" parameter is an optional parameter of type T. It is used to initialize the value of the
10
+ * vertex. If no value is provided, the vertex will be initialized with a default value.
11
+ */
12
+ constructor(id: VertexId, val?: T);
5
13
  }
6
- export declare class UndirectedEdge extends AbstractEdge {
7
- constructor(v1: VertexId, v2: VertexId, weight?: number);
14
+ export declare class UndirectedEdge<T = number> extends AbstractEdge<T> {
15
+ /**
16
+ * The constructor function creates an instance of a class with two vertex IDs, an optional weight, and an optional
17
+ * value.
18
+ * @param {VertexId} v1 - The first vertex ID of the edge.
19
+ * @param {VertexId} v2 - The parameter `v2` is a `VertexId`, which represents the identifier of the second vertex in a
20
+ * graph edge.
21
+ * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
22
+ * @param {T} [val] - The "val" parameter is an optional parameter of type T. It is used to store a value associated
23
+ * with the edge.
24
+ */
25
+ constructor(v1: VertexId, v2: VertexId, weight?: number, val?: T);
8
26
  private _vertices;
9
27
  get vertices(): [VertexId, VertexId];
10
28
  set vertices(v: [VertexId, VertexId]);
11
29
  }
12
- export declare class UndirectedGraph<V extends UndirectedVertex, E extends UndirectedEdge> extends AbstractGraph<V, E> {
13
- protected _edges: Map<V, E[]>;
30
+ export declare class UndirectedGraph<V extends UndirectedVertex<any> = UndirectedVertex, E extends UndirectedEdge<any> = UndirectedEdge> extends AbstractGraph<V, E> implements IUNDirectedGraph<V, E> {
31
+ /**
32
+ * The constructor initializes a new Map object to store edges.
33
+ */
14
34
  constructor();
35
+ protected _edges: Map<V, E[]>;
36
+ get edges(): Map<V, E[]>;
37
+ /**
38
+ * The function creates a new vertex with an optional value and returns it.
39
+ * @param {VertexId} id - The `id` parameter is the unique identifier for the vertex. It is used to distinguish one
40
+ * vertex from another in the graph.
41
+ * @param [val] - The `val` parameter is an optional value that can be assigned to the vertex. If a value is provided,
42
+ * it will be used as the value of the vertex. If no value is provided, the `id` parameter will be used as the value of
43
+ * the vertex.
44
+ * @returns The method is returning a new instance of the `UndirectedVertex` class, casted as type `V`.
45
+ */
46
+ createVertex(id: VertexId, val?: V['val']): V;
47
+ /**
48
+ * The function creates an undirected edge between two vertices with an optional weight and value.
49
+ * @param {VertexId} v1 - The parameter `v1` represents the first vertex of the edge.
50
+ * @param {VertexId} v2 - The parameter `v2` represents the second vertex of the edge.
51
+ * @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the edge. If
52
+ * no weight is provided, it defaults to 1.
53
+ * @param [val] - The `val` parameter is an optional value that can be assigned to the edge. It can be of any type and
54
+ * is used to store additional information or data associated with the edge.
55
+ * @returns a new instance of the `UndirectedEdge` class, which is casted as type `E`.
56
+ */
57
+ createEdge(v1: VertexId, v2: VertexId, weight?: number, val?: E['val']): E;
58
+ /**
59
+ * The function `getEdge` returns the first edge that connects two vertices, or null if no such edge exists.
60
+ * @param {V | null | VertexId} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `V` (vertex
61
+ * object), `null`, or `VertexId` (a string or number representing the ID of a vertex).
62
+ * @param {V | null | VertexId} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `V` (vertex
63
+ * object), `null`, or `VertexId` (vertex ID).
64
+ * @returns an edge (E) or null.
65
+ */
15
66
  getEdge(v1: V | null | VertexId, v2: V | null | VertexId): E | null;
16
- addEdge(edge: E): boolean;
67
+ /**
68
+ * The function removes an edge between two vertices in a graph and returns the removed edge.
69
+ * @param {V | VertexId} v1 - The parameter `v1` represents either a vertex object (`V`) or a vertex ID (`VertexId`).
70
+ * @param {V | VertexId} v2 - V | VertexId - This parameter can be either a vertex object (V) or a vertex ID
71
+ * (VertexId). It represents the second vertex of the edge that needs to be removed.
72
+ * @returns the removed edge (E) if it exists, or null if either of the vertices (V) does not exist.
73
+ */
17
74
  removeEdgeBetween(v1: V | VertexId, v2: V | VertexId): E | null;
75
+ /**
76
+ * The removeEdge function removes an edge between two vertices in a graph.
77
+ * @param {E} edge - The parameter "edge" is of type E, which represents an edge in a graph.
78
+ * @returns The method is returning either the removed edge (of type E) or null if the edge was not found.
79
+ */
18
80
  removeEdge(edge: E): E | null;
81
+ /**
82
+ * The function `degreeOf` returns the degree of a vertex in a graph, which is the number of edges connected to that
83
+ * vertex.
84
+ * @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a `V`.
85
+ * @returns The function `degreeOf` returns the degree of a vertex in a graph. The degree of a vertex is the number of
86
+ * edges connected to that vertex.
87
+ */
19
88
  degreeOf(vertexOrId: VertexId | V): number;
89
+ /**
90
+ * The function returns the edges of a given vertex or vertex ID.
91
+ * @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a `V`. A `VertexId` is a
92
+ * unique identifier for a vertex in a graph, while `V` represents the type of the vertex.
93
+ * @returns an array of edges.
94
+ */
20
95
  edgesOf(vertexOrId: VertexId | V): E[];
96
+ /**
97
+ * The function "edgeSet" returns an array of unique edges from a set of edges.
98
+ * @returns The method `edgeSet()` returns an array of type `E[]`.
99
+ */
21
100
  edgeSet(): E[];
22
- getEdgesOf(vertexOrId: V | VertexId): E[];
101
+ /**
102
+ * The function "getNeighbors" returns an array of neighboring vertices for a given vertex or vertex ID.
103
+ * @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can be either a vertex object (`V`) or a vertex ID
104
+ * (`VertexId`).
105
+ * @returns an array of vertices (V[]).
106
+ */
23
107
  getNeighbors(vertexOrId: V | VertexId): V[];
108
+ /**
109
+ * The function "getEndsOfEdge" returns the vertices at the ends of an edge if the edge exists in the graph, otherwise
110
+ * it returns null.
111
+ * @param {E} edge - The parameter "edge" is of type E, which represents an edge in a graph.
112
+ * @returns The function `getEndsOfEdge` returns an array containing two vertices `[V, V]` if the edge exists in the
113
+ * graph. If the edge does not exist, it returns `null`.
114
+ */
24
115
  getEndsOfEdge(edge: E): [V, V] | null;
116
+ /**
117
+ * The function adds an edge to the graph by updating the adjacency list with the vertices of the edge.
118
+ * @param {E} edge - The parameter "edge" is of type E, which represents an edge in a graph.
119
+ * @returns a boolean value.
120
+ */
121
+ protected _addEdgeOnly(edge: E): boolean;
122
+ /**
123
+ * The function sets the edges of a graph.
124
+ * @param v - A map where the keys are of type V and the values are arrays of type E.
125
+ */
126
+ protected _setEdges(v: Map<V, E[]>): void;
25
127
  }