data-structure-typed 1.39.3 → 1.39.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 (66) hide show
  1. package/CHANGELOG.md +2 -1
  2. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +1 -1
  3. package/dist/cjs/data-structures/binary-tree/avl-tree.js +4 -2
  4. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  5. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +5 -13
  6. package/dist/cjs/data-structures/binary-tree/binary-tree.js +17 -25
  7. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  8. package/dist/cjs/data-structures/binary-tree/bst.d.ts +1 -1
  9. package/dist/cjs/data-structures/binary-tree/bst.js +6 -6
  10. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  11. package/dist/cjs/data-structures/binary-tree/tree-multiset.d.ts +1 -1
  12. package/dist/cjs/data-structures/binary-tree/tree-multiset.js +2 -2
  13. package/dist/cjs/data-structures/binary-tree/tree-multiset.js.map +1 -1
  14. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +88 -88
  15. package/dist/cjs/data-structures/graph/abstract-graph.js +41 -41
  16. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  17. package/dist/cjs/data-structures/graph/directed-graph.d.ts +63 -63
  18. package/dist/cjs/data-structures/graph/directed-graph.js +36 -36
  19. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  20. package/dist/cjs/data-structures/graph/map-graph.d.ts +10 -10
  21. package/dist/cjs/data-structures/graph/map-graph.js +7 -7
  22. package/dist/cjs/data-structures/graph/map-graph.js.map +1 -1
  23. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +38 -38
  24. package/dist/cjs/data-structures/graph/undirected-graph.js +21 -21
  25. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  26. package/dist/cjs/data-structures/queue/queue.d.ts +1 -1
  27. package/dist/cjs/data-structures/queue/queue.js +3 -3
  28. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  29. package/dist/cjs/interfaces/graph.d.ts +3 -3
  30. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +1 -1
  31. package/dist/mjs/data-structures/binary-tree/avl-tree.js +4 -2
  32. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +5 -13
  33. package/dist/mjs/data-structures/binary-tree/binary-tree.js +17 -25
  34. package/dist/mjs/data-structures/binary-tree/bst.d.ts +1 -1
  35. package/dist/mjs/data-structures/binary-tree/bst.js +6 -6
  36. package/dist/mjs/data-structures/binary-tree/tree-multiset.d.ts +1 -1
  37. package/dist/mjs/data-structures/binary-tree/tree-multiset.js +2 -2
  38. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +88 -88
  39. package/dist/mjs/data-structures/graph/abstract-graph.js +41 -41
  40. package/dist/mjs/data-structures/graph/directed-graph.d.ts +63 -63
  41. package/dist/mjs/data-structures/graph/directed-graph.js +36 -36
  42. package/dist/mjs/data-structures/graph/map-graph.d.ts +10 -10
  43. package/dist/mjs/data-structures/graph/map-graph.js +7 -7
  44. package/dist/mjs/data-structures/graph/undirected-graph.d.ts +38 -38
  45. package/dist/mjs/data-structures/graph/undirected-graph.js +21 -21
  46. package/dist/mjs/data-structures/queue/queue.d.ts +1 -1
  47. package/dist/mjs/data-structures/queue/queue.js +3 -3
  48. package/dist/mjs/interfaces/graph.d.ts +3 -3
  49. package/dist/umd/data-structure-typed.min.js +1 -1
  50. package/dist/umd/data-structure-typed.min.js.map +1 -1
  51. package/package.json +5 -5
  52. package/src/data-structures/binary-tree/avl-tree.ts +3 -2
  53. package/src/data-structures/binary-tree/binary-tree.ts +19 -28
  54. package/src/data-structures/binary-tree/bst.ts +6 -6
  55. package/src/data-structures/binary-tree/tree-multiset.ts +2 -2
  56. package/src/data-structures/graph/abstract-graph.ts +135 -133
  57. package/src/data-structures/graph/directed-graph.ts +92 -87
  58. package/src/data-structures/graph/map-graph.ts +17 -20
  59. package/src/data-structures/graph/undirected-graph.ts +56 -54
  60. package/src/data-structures/queue/queue.ts +1 -1
  61. package/src/interfaces/graph.ts +3 -3
  62. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +0 -1
  63. package/test/unit/data-structures/graph/directed-graph.test.ts +20 -15
  64. package/test/unit/data-structures/graph/map-graph.test.ts +23 -23
  65. package/test/unit/data-structures/graph/undirected-graph.test.ts +2 -2
  66. package/test/unit/data-structures/queue/queue.test.ts +8 -8
@@ -11,7 +11,7 @@ export declare class DirectedVertex<V = any> extends AbstractVertex<V> {
11
11
  */
12
12
  constructor(key: VertexKey, val?: V);
13
13
  }
14
- export declare class DirectedEdge<V = any> extends AbstractEdge<V> {
14
+ export declare class DirectedEdge<E = any> extends AbstractEdge<E> {
15
15
  /**
16
16
  * The constructor function initializes the source and destination vertices of an edge, along with an optional weight
17
17
  * and value.
@@ -20,10 +20,10 @@ export declare class DirectedEdge<V = any> extends AbstractEdge<V> {
20
20
  * @param {VertexKey} dest - The `dest` parameter represents the destination vertex of an edge. It is of type
21
21
  * `VertexKey`, which is likely a unique identifier for a vertex in a graph.
22
22
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
23
- * @param {V} [val] - The `val` parameter is an optional parameter of type `V`. It represents the value associated with
23
+ * @param {E} [val] - The `val` parameter is an optional parameter of type `E`. It represents the value associated with
24
24
  * the edge.
25
25
  */
26
- constructor(src: VertexKey, dest: VertexKey, weight?: number, val?: V);
26
+ constructor(src: VertexKey, dest: VertexKey, weight?: number, val?: E);
27
27
  private _src;
28
28
  get src(): VertexKey;
29
29
  set src(v: VertexKey);
@@ -31,15 +31,15 @@ export declare class DirectedEdge<V = any> extends AbstractEdge<V> {
31
31
  get dest(): VertexKey;
32
32
  set dest(v: VertexKey);
33
33
  }
34
- export declare class DirectedGraph<V extends DirectedVertex<any> = DirectedVertex, E extends DirectedEdge<any> = DirectedEdge> extends AbstractGraph<V, E> implements IGraph<V, E> {
34
+ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V> = DirectedVertex<V>, EO extends DirectedEdge<E> = DirectedEdge<E>> extends AbstractGraph<V, E, VO, EO> implements IGraph<V, E, VO, EO> {
35
35
  /**
36
36
  * The constructor function initializes an instance of a class.
37
37
  */
38
38
  constructor();
39
39
  private _outEdgeMap;
40
- get outEdgeMap(): Map<V, E[]>;
40
+ get outEdgeMap(): Map<VO, EO[]>;
41
41
  private _inEdgeMap;
42
- get inEdgeMap(): Map<V, E[]>;
42
+ get inEdgeMap(): Map<VO, EO[]>;
43
43
  /**
44
44
  * 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.
45
45
  * 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.
@@ -51,9 +51,9 @@ export declare class DirectedGraph<V extends DirectedVertex<any> = DirectedVerte
51
51
  * @param [val] - The 'val' parameter is an optional value that can be assigned to the vertex. If a value is provided,
52
52
  * it will be assigned to the 'val' property of the vertex. If no value is provided, the 'val' property will be
53
53
  * assigned the same value as the 'key' parameter
54
- * @returns a new instance of a DirectedVertex object, casted as type V.
54
+ * @returns a new instance of a DirectedVertex object, casted as type VO.
55
55
  */
56
- createVertex(key: VertexKey, val?: V['val']): V;
56
+ createVertex(key: VertexKey, val?: V): VO;
57
57
  /**
58
58
  * 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.
59
59
  * 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.
@@ -66,98 +66,98 @@ export declare class DirectedGraph<V extends DirectedVertex<any> = DirectedVerte
66
66
  * weight is provided, it defaults to 1.
67
67
  * @param [val] - The 'val' parameter is an optional value that can be assigned to the edge. It can be of any type and
68
68
  * is used to store additional information or data associated with the edge.
69
- * @returns a new instance of a DirectedEdge object, casted as type E.
69
+ * @returns a new instance of a DirectedEdge object, casted as type EO.
70
70
  */
71
- createEdge(src: VertexKey, dest: VertexKey, weight?: number, val?: E['val']): E;
71
+ createEdge(src: VertexKey, dest: VertexKey, weight?: number, val?: E): EO;
72
72
  /**
73
73
  * The `getEdge` function retrieves an edge between two vertices based on their source and destination IDs.
74
- * @param {V | null | VertexKey} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
75
- * @param {V | null | VertexKey} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
76
- * destination vertex of the edge. It can be either a vertex object (`V`), a vertex ID (`VertexKey`), or `null` if the
74
+ * @param {VO | null | VertexKey} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
75
+ * @param {VO | null | VertexKey} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
76
+ * destination vertex of the edge. It can be either a vertex object (`VO`), a vertex ID (`VertexKey`), or `null` if the
77
77
  * destination is not specified.
78
78
  * @returns the first edge found between the source and destination vertices, or null if no such edge is found.
79
79
  */
80
- getEdge(srcOrKey: V | null | VertexKey, destOrKey: V | null | VertexKey): E | null;
80
+ getEdge(srcOrKey: VO | null | VertexKey, destOrKey: VO | null | VertexKey): EO | null;
81
81
  /**
82
82
  * The function removes an edge between two vertices in a graph and returns the removed edge.
83
- * @param {V | VertexKey} srcOrKey - The source vertex or its ID.
84
- * @param {V | VertexKey} destOrKey - The `destOrKey` parameter represents the destination vertex or its ID.
85
- * @returns the removed edge (E) if it exists, or null if either the source or destination vertex does not exist.
83
+ * @param {VO | VertexKey} srcOrKey - The source vertex or its ID.
84
+ * @param {VO | VertexKey} destOrKey - The `destOrKey` parameter represents the destination vertex or its ID.
85
+ * @returns the removed edge (EO) if it exists, or null if either the source or destination vertex does not exist.
86
86
  */
87
- deleteEdgeSrcToDest(srcOrKey: V | VertexKey, destOrKey: V | VertexKey): E | null;
87
+ deleteEdgeSrcToDest(srcOrKey: VO | VertexKey, destOrKey: VO | VertexKey): EO | null;
88
88
  /**
89
89
  * The function removes an edge from a graph and returns the removed edge, or null if the edge was not found.
90
- * @param {E} edge - The `edge` parameter is an object that represents an edge in a graph. It has two properties: `src`
90
+ * @param {EO} edge - The `edge` parameter is an object that represents an edge in a graph. It has two properties: `src`
91
91
  * and `dest`, which represent the source and destination vertices of the edge, respectively.
92
- * @returns The method `deleteEdge` returns the removed edge (`E`) if it exists, or `null` if the edge does not exist.
92
+ * @returns The method `deleteEdge` returns the removed edge (`EO`) if it exists, or `null` if the edge does not exist.
93
93
  */
94
- deleteEdge(edge: E): E | null;
94
+ deleteEdge(edge: EO): EO | null;
95
95
  /**
96
96
  * The function removes edges between two vertices and returns the removed edges.
97
- * @param {VertexKey | V} v1 - The parameter `v1` can be either a `VertexKey` or a `V`. A `VertexKey` represents the
98
- * unique identifier of a vertex in a graph, while `V` represents the actual vertex object.
99
- * @param {VertexKey | V} v2 - The parameter `v2` represents either a `VertexKey` or a `V` object. It is used to specify
97
+ * @param {VertexKey | VO} v1 - The parameter `v1` can be either a `VertexKey` or a `VO`. A `VertexKey` represents the
98
+ * unique identifier of a vertex in a graph, while `VO` represents the actual vertex object.
99
+ * @param {VertexKey | VO} v2 - The parameter `v2` represents either a `VertexKey` or a `VO` object. It is used to specify
100
100
  * the second vertex in the edge that needs to be removed.
101
- * @returns an array of removed edges (E[]).
101
+ * @returns an array of removed edges (EO[]).
102
102
  */
103
- deleteEdgesBetween(v1: VertexKey | V, v2: VertexKey | V): E[];
103
+ deleteEdgesBetween(v1: VertexKey | VO, v2: VertexKey | VO): EO[];
104
104
  /**
105
105
  * The function `incomingEdgesOf` returns an array of incoming edges for a given vertex or vertex ID.
106
- * @param {V | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`V`) or a vertex ID
106
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
107
107
  * (`VertexKey`).
108
- * @returns The method `incomingEdgesOf` returns an array of edges (`E[]`).
108
+ * @returns The method `incomingEdgesOf` returns an array of edges (`EO[]`).
109
109
  */
110
- incomingEdgesOf(vertexOrKey: V | VertexKey): E[];
110
+ incomingEdgesOf(vertexOrKey: VO | VertexKey): EO[];
111
111
  /**
112
112
  * The function `outgoingEdgesOf` returns an array of outgoing edges from a given vertex or vertex ID.
113
- * @param {V | VertexKey} vertexOrKey - The parameter `vertexOrKey` can accept either a vertex object (`V`) or a vertex ID
113
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can accept either a vertex object (`VO`) or a vertex ID
114
114
  * (`VertexKey`).
115
- * @returns The method `outgoingEdgesOf` returns an array of edges (`E[]`).
115
+ * @returns The method `outgoingEdgesOf` returns an array of edges (`EO[]`).
116
116
  */
117
- outgoingEdgesOf(vertexOrKey: V | VertexKey): E[];
117
+ outgoingEdgesOf(vertexOrKey: VO | VertexKey): EO[];
118
118
  /**
119
119
  * The function "degreeOf" returns the total degree of a vertex, which is the sum of its out-degree and in-degree.
120
- * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`.
120
+ * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
121
121
  * @returns The sum of the out-degree and in-degree of the specified vertex or vertex ID.
122
122
  */
123
- degreeOf(vertexOrKey: VertexKey | V): number;
123
+ degreeOf(vertexOrKey: VertexKey | VO): number;
124
124
  /**
125
125
  * The function "inDegreeOf" returns the number of incoming edges for a given vertex.
126
- * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`.
126
+ * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
127
127
  * @returns The number of incoming edges of the specified vertex or vertex ID.
128
128
  */
129
- inDegreeOf(vertexOrKey: VertexKey | V): number;
129
+ inDegreeOf(vertexOrKey: VertexKey | VO): number;
130
130
  /**
131
131
  * The function `outDegreeOf` returns the number of outgoing edges from a given vertex.
132
- * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`.
132
+ * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
133
133
  * @returns The number of outgoing edges from the specified vertex or vertex ID.
134
134
  */
135
- outDegreeOf(vertexOrKey: VertexKey | V): number;
135
+ outDegreeOf(vertexOrKey: VertexKey | VO): number;
136
136
  /**
137
137
  * The function "edgesOf" returns an array of both outgoing and incoming edges of a given vertex or vertex ID.
138
- * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`.
138
+ * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
139
139
  * @returns The function `edgesOf` returns an array of edges.
140
140
  */
141
- edgesOf(vertexOrKey: VertexKey | V): E[];
141
+ edgesOf(vertexOrKey: VertexKey | VO): EO[];
142
142
  /**
143
143
  * The function "getEdgeSrc" returns the source vertex of an edge, or null if the edge does not exist.
144
- * @param {E} e - The parameter "e" is of type E, which represents an edge in a graph.
145
- * @returns either a vertex object (V) or null.
144
+ * @param {EO} e - The parameter "e" is of type EO, which represents an edge in a graph.
145
+ * @returns either a vertex object (VO) or null.
146
146
  */
147
- getEdgeSrc(e: E): V | null;
147
+ getEdgeSrc(e: EO): VO | null;
148
148
  /**
149
149
  * The function "getEdgeDest" returns the destination vertex of an edge.
150
- * @param {E} e - The parameter "e" is of type "E", which represents an edge in a graph.
151
- * @returns either a vertex object of type V or null.
150
+ * @param {EO} e - The parameter "e" is of type "EO", which represents an edge in a graph.
151
+ * @returns either a vertex object of type VO or null.
152
152
  */
153
- getEdgeDest(e: E): V | null;
153
+ getEdgeDest(e: EO): VO | null;
154
154
  /**
155
155
  * The function `getDestinations` returns an array of destination vertices connected to a given vertex.
156
- * @param {V | VertexKey | null} vertex - The `vertex` parameter represents the starting vertex from which we want to
157
- * find the destinations. It can be either a `V` object, a `VertexKey` value, or `null`.
158
- * @returns an array of vertices (V[]).
156
+ * @param {VO | VertexKey | null} vertex - The `vertex` parameter represents the starting vertex from which we want to
157
+ * find the destinations. It can be either a `VO` object, a `VertexKey` value, or `null`.
158
+ * @returns an array of vertices (VO[]).
159
159
  */
160
- getDestinations(vertex: V | VertexKey | null): V[];
160
+ getDestinations(vertex: VO | VertexKey | null): VO[];
161
161
  /**
162
162
  * The `topologicalSort` function performs a topological sort on a graph and returns an array of vertices or vertex IDs
163
163
  * in the sorted order, or null if the graph contains a cycle.
@@ -166,35 +166,35 @@ export declare class DirectedGraph<V extends DirectedVertex<any> = DirectedVerte
166
166
  * specified, the vertices themselves will be used for sorting. If 'key' is specified, the ids of
167
167
  * @returns an array of vertices or vertex IDs in topological order. If there is a cycle in the graph, it returns null.
168
168
  */
169
- topologicalSort(propertyName?: 'vertex' | 'key'): Array<V | VertexKey> | null;
169
+ topologicalSort(propertyName?: 'vertex' | 'key'): Array<VO | VertexKey> | null;
170
170
  /**
171
171
  * The `edgeSet` function returns an array of all the edges in the graph.
172
- * @returns The `edgeSet()` method returns an array of edges (`E[]`).
172
+ * @returns The `edgeSet()` method returns an array of edges (`EO[]`).
173
173
  */
174
- edgeSet(): E[];
174
+ edgeSet(): EO[];
175
175
  /**
176
176
  * The function `getNeighbors` returns an array of neighboring vertices of a given vertex or vertex ID in a graph.
177
- * @param {V | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`V`) or a vertex ID
177
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
178
178
  * (`VertexKey`).
179
- * @returns an array of vertices (V[]).
179
+ * @returns an array of vertices (VO[]).
180
180
  */
181
- getNeighbors(vertexOrKey: V | VertexKey): V[];
181
+ getNeighbors(vertexOrKey: VO | VertexKey): VO[];
182
182
  /**
183
183
  * The function "getEndsOfEdge" returns the source and destination vertices of an edge if it exists in the graph,
184
184
  * otherwise it returns null.
185
- * @param {E} edge - The parameter `edge` is of type `E`, which represents an edge in a graph.
186
- * @returns The function `getEndsOfEdge` returns an array containing two vertices `[V, V]` if the edge exists in the
185
+ * @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph.
186
+ * @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
187
187
  * graph. If the edge does not exist, it returns `null`.
188
188
  */
189
- getEndsOfEdge(edge: E): [V, V] | null;
189
+ getEndsOfEdge(edge: EO): [VO, VO] | null;
190
190
  /**
191
191
  * The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertices exist.
192
- * @param {E} edge - The parameter `edge` is of type `E`, which represents an edge in a graph. It is the edge that
192
+ * @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph. It is the edge that
193
193
  * needs to be added to the graph.
194
194
  * @returns a boolean value. It returns true if the edge was successfully added to the graph, and false if either the
195
195
  * source or destination vertex does not exist in the graph.
196
196
  */
197
- protected _addEdgeOnly(edge: E): boolean;
198
- protected _setOutEdgeMap(value: Map<V, E[]>): void;
199
- protected _setInEdgeMap(value: Map<V, E[]>): void;
197
+ protected _addEdgeOnly(edge: EO): boolean;
198
+ protected _setOutEdgeMap(value: Map<VO, EO[]>): void;
199
+ protected _setInEdgeMap(value: Map<VO, EO[]>): void;
200
200
  }
@@ -32,7 +32,7 @@ class DirectedEdge extends abstract_graph_1.AbstractEdge {
32
32
  * @param {VertexKey} dest - The `dest` parameter represents the destination vertex of an edge. It is of type
33
33
  * `VertexKey`, which is likely a unique identifier for a vertex in a graph.
34
34
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
35
- * @param {V} [val] - The `val` parameter is an optional parameter of type `V`. It represents the value associated with
35
+ * @param {E} [val] - The `val` parameter is an optional parameter of type `E`. It represents the value associated with
36
36
  * the edge.
37
37
  */
38
38
  constructor(src, dest, weight, val) {
@@ -82,7 +82,7 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
82
82
  * @param [val] - The 'val' parameter is an optional value that can be assigned to the vertex. If a value is provided,
83
83
  * it will be assigned to the 'val' property of the vertex. If no value is provided, the 'val' property will be
84
84
  * assigned the same value as the 'key' parameter
85
- * @returns a new instance of a DirectedVertex object, casted as type V.
85
+ * @returns a new instance of a DirectedVertex object, casted as type VO.
86
86
  */
87
87
  createVertex(key, val) {
88
88
  return new DirectedVertex(key, val ?? key);
@@ -99,16 +99,16 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
99
99
  * weight is provided, it defaults to 1.
100
100
  * @param [val] - The 'val' parameter is an optional value that can be assigned to the edge. It can be of any type and
101
101
  * is used to store additional information or data associated with the edge.
102
- * @returns a new instance of a DirectedEdge object, casted as type E.
102
+ * @returns a new instance of a DirectedEdge object, casted as type EO.
103
103
  */
104
104
  createEdge(src, dest, weight, val) {
105
105
  return new DirectedEdge(src, dest, weight ?? 1, val);
106
106
  }
107
107
  /**
108
108
  * The `getEdge` function retrieves an edge between two vertices based on their source and destination IDs.
109
- * @param {V | null | VertexKey} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
110
- * @param {V | null | VertexKey} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
111
- * destination vertex of the edge. It can be either a vertex object (`V`), a vertex ID (`VertexKey`), or `null` if the
109
+ * @param {VO | null | VertexKey} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
110
+ * @param {VO | null | VertexKey} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
111
+ * destination vertex of the edge. It can be either a vertex object (`VO`), a vertex ID (`VertexKey`), or `null` if the
112
112
  * destination is not specified.
113
113
  * @returns the first edge found between the source and destination vertices, or null if no such edge is found.
114
114
  */
@@ -128,9 +128,9 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
128
128
  }
129
129
  /**
130
130
  * The function removes an edge between two vertices in a graph and returns the removed edge.
131
- * @param {V | VertexKey} srcOrKey - The source vertex or its ID.
132
- * @param {V | VertexKey} destOrKey - The `destOrKey` parameter represents the destination vertex or its ID.
133
- * @returns the removed edge (E) if it exists, or null if either the source or destination vertex does not exist.
131
+ * @param {VO | VertexKey} srcOrKey - The source vertex or its ID.
132
+ * @param {VO | VertexKey} destOrKey - The `destOrKey` parameter represents the destination vertex or its ID.
133
+ * @returns the removed edge (EO) if it exists, or null if either the source or destination vertex does not exist.
134
134
  */
135
135
  deleteEdgeSrcToDest(srcOrKey, destOrKey) {
136
136
  const src = this._getVertex(srcOrKey);
@@ -151,9 +151,9 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
151
151
  }
152
152
  /**
153
153
  * The function removes an edge from a graph and returns the removed edge, or null if the edge was not found.
154
- * @param {E} edge - The `edge` parameter is an object that represents an edge in a graph. It has two properties: `src`
154
+ * @param {EO} edge - The `edge` parameter is an object that represents an edge in a graph. It has two properties: `src`
155
155
  * and `dest`, which represent the source and destination vertices of the edge, respectively.
156
- * @returns The method `deleteEdge` returns the removed edge (`E`) if it exists, or `null` if the edge does not exist.
156
+ * @returns The method `deleteEdge` returns the removed edge (`EO`) if it exists, or `null` if the edge does not exist.
157
157
  */
158
158
  deleteEdge(edge) {
159
159
  let removed = null;
@@ -173,11 +173,11 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
173
173
  }
174
174
  /**
175
175
  * The function removes edges between two vertices and returns the removed edges.
176
- * @param {VertexKey | V} v1 - The parameter `v1` can be either a `VertexKey` or a `V`. A `VertexKey` represents the
177
- * unique identifier of a vertex in a graph, while `V` represents the actual vertex object.
178
- * @param {VertexKey | V} v2 - The parameter `v2` represents either a `VertexKey` or a `V` object. It is used to specify
176
+ * @param {VertexKey | VO} v1 - The parameter `v1` can be either a `VertexKey` or a `VO`. A `VertexKey` represents the
177
+ * unique identifier of a vertex in a graph, while `VO` represents the actual vertex object.
178
+ * @param {VertexKey | VO} v2 - The parameter `v2` represents either a `VertexKey` or a `VO` object. It is used to specify
179
179
  * the second vertex in the edge that needs to be removed.
180
- * @returns an array of removed edges (E[]).
180
+ * @returns an array of removed edges (EO[]).
181
181
  */
182
182
  deleteEdgesBetween(v1, v2) {
183
183
  const removed = [];
@@ -191,9 +191,9 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
191
191
  }
192
192
  /**
193
193
  * The function `incomingEdgesOf` returns an array of incoming edges for a given vertex or vertex ID.
194
- * @param {V | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`V`) or a vertex ID
194
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
195
195
  * (`VertexKey`).
196
- * @returns The method `incomingEdgesOf` returns an array of edges (`E[]`).
196
+ * @returns The method `incomingEdgesOf` returns an array of edges (`EO[]`).
197
197
  */
198
198
  incomingEdgesOf(vertexOrKey) {
199
199
  const target = this._getVertex(vertexOrKey);
@@ -204,9 +204,9 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
204
204
  }
205
205
  /**
206
206
  * The function `outgoingEdgesOf` returns an array of outgoing edges from a given vertex or vertex ID.
207
- * @param {V | VertexKey} vertexOrKey - The parameter `vertexOrKey` can accept either a vertex object (`V`) or a vertex ID
207
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can accept either a vertex object (`VO`) or a vertex ID
208
208
  * (`VertexKey`).
209
- * @returns The method `outgoingEdgesOf` returns an array of edges (`E[]`).
209
+ * @returns The method `outgoingEdgesOf` returns an array of edges (`EO[]`).
210
210
  */
211
211
  outgoingEdgesOf(vertexOrKey) {
212
212
  const target = this._getVertex(vertexOrKey);
@@ -217,7 +217,7 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
217
217
  }
218
218
  /**
219
219
  * The function "degreeOf" returns the total degree of a vertex, which is the sum of its out-degree and in-degree.
220
- * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`.
220
+ * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
221
221
  * @returns The sum of the out-degree and in-degree of the specified vertex or vertex ID.
222
222
  */
223
223
  degreeOf(vertexOrKey) {
@@ -225,7 +225,7 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
225
225
  }
226
226
  /**
227
227
  * The function "inDegreeOf" returns the number of incoming edges for a given vertex.
228
- * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`.
228
+ * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
229
229
  * @returns The number of incoming edges of the specified vertex or vertex ID.
230
230
  */
231
231
  inDegreeOf(vertexOrKey) {
@@ -233,7 +233,7 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
233
233
  }
234
234
  /**
235
235
  * The function `outDegreeOf` returns the number of outgoing edges from a given vertex.
236
- * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`.
236
+ * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
237
237
  * @returns The number of outgoing edges from the specified vertex or vertex ID.
238
238
  */
239
239
  outDegreeOf(vertexOrKey) {
@@ -241,7 +241,7 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
241
241
  }
242
242
  /**
243
243
  * The function "edgesOf" returns an array of both outgoing and incoming edges of a given vertex or vertex ID.
244
- * @param {VertexKey | V} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `V`.
244
+ * @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
245
245
  * @returns The function `edgesOf` returns an array of edges.
246
246
  */
247
247
  edgesOf(vertexOrKey) {
@@ -249,25 +249,25 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
249
249
  }
250
250
  /**
251
251
  * The function "getEdgeSrc" returns the source vertex of an edge, or null if the edge does not exist.
252
- * @param {E} e - The parameter "e" is of type E, which represents an edge in a graph.
253
- * @returns either a vertex object (V) or null.
252
+ * @param {EO} e - The parameter "e" is of type EO, which represents an edge in a graph.
253
+ * @returns either a vertex object (VO) or null.
254
254
  */
255
255
  getEdgeSrc(e) {
256
256
  return this._getVertex(e.src);
257
257
  }
258
258
  /**
259
259
  * The function "getEdgeDest" returns the destination vertex of an edge.
260
- * @param {E} e - The parameter "e" is of type "E", which represents an edge in a graph.
261
- * @returns either a vertex object of type V or null.
260
+ * @param {EO} e - The parameter "e" is of type "EO", which represents an edge in a graph.
261
+ * @returns either a vertex object of type VO or null.
262
262
  */
263
263
  getEdgeDest(e) {
264
264
  return this._getVertex(e.dest);
265
265
  }
266
266
  /**
267
267
  * The function `getDestinations` returns an array of destination vertices connected to a given vertex.
268
- * @param {V | VertexKey | null} vertex - The `vertex` parameter represents the starting vertex from which we want to
269
- * find the destinations. It can be either a `V` object, a `VertexKey` value, or `null`.
270
- * @returns an array of vertices (V[]).
268
+ * @param {VO | VertexKey | null} vertex - The `vertex` parameter represents the starting vertex from which we want to
269
+ * find the destinations. It can be either a `VO` object, a `VertexKey` value, or `null`.
270
+ * @returns an array of vertices (VO[]).
271
271
  */
272
272
  getDestinations(vertex) {
273
273
  if (vertex === null) {
@@ -329,7 +329,7 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
329
329
  }
330
330
  /**
331
331
  * The `edgeSet` function returns an array of all the edges in the graph.
332
- * @returns The `edgeSet()` method returns an array of edges (`E[]`).
332
+ * @returns The `edgeSet()` method returns an array of edges (`EO[]`).
333
333
  */
334
334
  edgeSet() {
335
335
  let edges = [];
@@ -340,9 +340,9 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
340
340
  }
341
341
  /**
342
342
  * The function `getNeighbors` returns an array of neighboring vertices of a given vertex or vertex ID in a graph.
343
- * @param {V | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`V`) or a vertex ID
343
+ * @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
344
344
  * (`VertexKey`).
345
- * @returns an array of vertices (V[]).
345
+ * @returns an array of vertices (VO[]).
346
346
  */
347
347
  getNeighbors(vertexOrKey) {
348
348
  const neighbors = [];
@@ -362,8 +362,8 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
362
362
  /**
363
363
  * The function "getEndsOfEdge" returns the source and destination vertices of an edge if it exists in the graph,
364
364
  * otherwise it returns null.
365
- * @param {E} edge - The parameter `edge` is of type `E`, which represents an edge in a graph.
366
- * @returns The function `getEndsOfEdge` returns an array containing two vertices `[V, V]` if the edge exists in the
365
+ * @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph.
366
+ * @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
367
367
  * graph. If the edge does not exist, it returns `null`.
368
368
  */
369
369
  getEndsOfEdge(edge) {
@@ -381,7 +381,7 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
381
381
  }
382
382
  /**
383
383
  * The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertices exist.
384
- * @param {E} edge - The parameter `edge` is of type `E`, which represents an edge in a graph. It is the edge that
384
+ * @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph. It is the edge that
385
385
  * needs to be added to the graph.
386
386
  * @returns a boolean value. It returns true if the edge was successfully added to the graph, and false if either the
387
387
  * source or destination vertex does not exist in the graph.
@@ -13,7 +13,7 @@ export declare class MapVertex<V = any> extends DirectedVertex<V> {
13
13
  * @param {V} [val] - The "val" parameter is an optional value of type V. It is not required to be provided when
14
14
  * creating an instance of the class.
15
15
  */
16
- constructor(key: VertexKey, lat: number, long: number, val?: V);
16
+ constructor(key: VertexKey, val: V, lat: number, long: number);
17
17
  private _lat;
18
18
  get lat(): number;
19
19
  set lat(value: number);
@@ -21,7 +21,7 @@ export declare class MapVertex<V = any> extends DirectedVertex<V> {
21
21
  get long(): number;
22
22
  set long(value: number);
23
23
  }
24
- export declare class MapEdge<V = any> extends DirectedEdge<V> {
24
+ export declare class MapEdge<E = any> extends DirectedEdge<E> {
25
25
  /**
26
26
  * The constructor function initializes a new instance of a class with the given source, destination, weight, and
27
27
  * value.
@@ -29,12 +29,12 @@ export declare class MapEdge<V = any> extends DirectedEdge<V> {
29
29
  * a graph.
30
30
  * @param {VertexKey} dest - The `dest` parameter is the identifier of the destination vertex for an edge.
31
31
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
32
- * @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to store additional
32
+ * @param {E} [val] - The "val" parameter is an optional parameter of type E. It is used to store additional
33
33
  * information or data associated with the edge.
34
34
  */
35
- constructor(src: VertexKey, dest: VertexKey, weight?: number, val?: V);
35
+ constructor(src: VertexKey, dest: VertexKey, weight?: number, val?: E);
36
36
  }
37
- export declare class MapGraph<V extends MapVertex<V['val']> = MapVertex, E extends MapEdge = MapEdge> extends DirectedGraph<V, E> {
37
+ export declare class MapGraph<V = any, E = any, VO extends MapVertex<V> = MapVertex<V>, EO extends MapEdge<E> = MapEdge<E>> extends DirectedGraph<V, E, VO, EO> {
38
38
  /**
39
39
  * The constructor function initializes the origin and bottomRight properties of a MapGraphCoordinate object.
40
40
  * @param {MapGraphCoordinate} origin - The `origin` parameter is a `MapGraphCoordinate` object that represents the
@@ -56,13 +56,13 @@ export declare class MapGraph<V extends MapVertex<V['val']> = MapVertex, E exten
56
56
  * @param {VertexKey} key - The key parameter is the unique identifier for the vertex. It is of type VertexKey, which could
57
57
  * be a string or a number depending on how you define it in your code.
58
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`.
59
+ * is of type `V`, which means it should be of the same type as the `val` property of the vertex class `VO`.
60
60
  * @param {number} lat - The `lat` parameter represents the latitude of the vertex. It is a number that specifies the
61
61
  * position of the vertex on the Earth's surface in the north-south direction.
62
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`.
63
+ * @returns The method is returning a new instance of the `MapVertex` class, casted as type `VO`.
64
64
  */
65
- createVertex(key: VertexKey, lat?: number, long?: number, val?: V['val']): V;
65
+ createVertex(key: VertexKey, val?: V, lat?: number, long?: number): VO;
66
66
  /**
67
67
  * The function creates a new instance of a MapEdge with the given source, destination, weight, and value.
68
68
  * @param {VertexKey} src - The source vertex ID of the edge. It represents the starting point of the edge.
@@ -73,7 +73,7 @@ export declare class MapGraph<V extends MapVertex<V['val']> = MapVertex, E exten
73
73
  * If the weight is not provided, it can be set to a default value or left undefined.
74
74
  * @param [val] - The `val` parameter is an optional value that can be assigned to the edge. It can be of any type,
75
75
  * depending on the specific implementation of the `MapEdge` class.
76
- * @returns a new instance of the `MapEdge` class, cast as type `E`.
76
+ * @returns a new instance of the `MapEdge` class, cast as type `EO`.
77
77
  */
78
- createEdge(src: VertexKey, dest: VertexKey, weight?: number, val?: E['val']): E;
78
+ createEdge(src: VertexKey, dest: VertexKey, weight?: number, val?: E): EO;
79
79
  }
@@ -15,7 +15,7 @@ class MapVertex extends directed_graph_1.DirectedVertex {
15
15
  * @param {V} [val] - The "val" parameter is an optional value of type V. It is not required to be provided when
16
16
  * creating an instance of the class.
17
17
  */
18
- constructor(key, lat, long, val) {
18
+ constructor(key, val, lat, long) {
19
19
  super(key, val);
20
20
  this._lat = lat;
21
21
  this._long = long;
@@ -44,7 +44,7 @@ class MapEdge extends directed_graph_1.DirectedEdge {
44
44
  * a graph.
45
45
  * @param {VertexKey} dest - The `dest` parameter is the identifier of the destination vertex for an edge.
46
46
  * @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
47
- * @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to store additional
47
+ * @param {E} [val] - The "val" parameter is an optional parameter of type E. It is used to store additional
48
48
  * information or data associated with the edge.
49
49
  */
50
50
  constructor(src, dest, weight, val) {
@@ -86,14 +86,14 @@ class MapGraph extends directed_graph_1.DirectedGraph {
86
86
  * @param {VertexKey} key - The key parameter is the unique identifier for the vertex. It is of type VertexKey, which could
87
87
  * be a string or a number depending on how you define it in your code.
88
88
  * @param [val] - The `val` parameter is an optional value that can be assigned to the `val` property of the vertex. It
89
- * is of type `V['val']`, which means it should be of the same type as the `val` property of the vertex class `V`.
89
+ * is of type `V`, which means it should be of the same type as the `val` property of the vertex class `VO`.
90
90
  * @param {number} lat - The `lat` parameter represents the latitude of the vertex. It is a number that specifies the
91
91
  * position of the vertex on the Earth's surface in the north-south direction.
92
92
  * @param {number} long - The `long` parameter represents the longitude coordinate of the vertex.
93
- * @returns The method is returning a new instance of the `MapVertex` class, casted as type `V`.
93
+ * @returns The method is returning a new instance of the `MapVertex` class, casted as type `VO`.
94
94
  */
95
- createVertex(key, lat = this.origin[0], long = this.origin[1], val) {
96
- return new MapVertex(key, lat, long, val);
95
+ createVertex(key, val, lat = this.origin[0], long = this.origin[1]) {
96
+ return new MapVertex(key, val, lat, long);
97
97
  }
98
98
  /**
99
99
  * The function creates a new instance of a MapEdge with the given source, destination, weight, and value.
@@ -105,7 +105,7 @@ class MapGraph extends directed_graph_1.DirectedGraph {
105
105
  * If the weight is not provided, it can be set to a default value or left undefined.
106
106
  * @param [val] - The `val` parameter is an optional value that can be assigned to the edge. It can be of any type,
107
107
  * depending on the specific implementation of the `MapEdge` class.
108
- * @returns a new instance of the `MapEdge` class, cast as type `E`.
108
+ * @returns a new instance of the `MapEdge` class, cast as type `EO`.
109
109
  */
110
110
  createEdge(src, dest, weight, val) {
111
111
  return new MapEdge(src, dest, weight, val);