data-structure-typed 1.48.4 → 1.48.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.
- package/CHANGELOG.md +1 -1
- package/dist/cjs/data-structures/base/iterable-base.d.ts +6 -6
- package/dist/cjs/data-structures/base/iterable-base.js +3 -3
- package/dist/cjs/data-structures/base/iterable-base.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +5 -3
- package/dist/cjs/data-structures/binary-tree/avl-tree.js +6 -4
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +18 -15
- package/dist/cjs/data-structures/binary-tree/binary-tree.js +16 -13
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/bst.d.ts +15 -11
- package/dist/cjs/data-structures/binary-tree/bst.js +17 -13
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +19 -13
- package/dist/cjs/data-structures/binary-tree/rb-tree.js +20 -14
- package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/tree-multimap.d.ts +21 -14
- package/dist/cjs/data-structures/binary-tree/tree-multimap.js +25 -18
- package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
- package/dist/cjs/data-structures/graph/abstract-graph.d.ts +52 -52
- package/dist/cjs/data-structures/graph/abstract-graph.js +78 -78
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/directed-graph.d.ts +47 -47
- package/dist/cjs/data-structures/graph/directed-graph.js +56 -56
- package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/map-graph.d.ts +5 -5
- package/dist/cjs/data-structures/graph/map-graph.js +8 -8
- package/dist/cjs/data-structures/graph/map-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/undirected-graph.d.ts +29 -29
- package/dist/cjs/data-structures/graph/undirected-graph.js +57 -57
- package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
- package/dist/cjs/data-structures/hash/hash-map.d.ts +8 -8
- package/dist/cjs/data-structures/hash/hash-map.js +2 -2
- package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
- package/dist/cjs/interfaces/binary-tree.d.ts +1 -1
- package/dist/cjs/types/data-structures/base/base.d.ts +3 -3
- package/dist/mjs/data-structures/base/iterable-base.d.ts +6 -6
- package/dist/mjs/data-structures/base/iterable-base.js +1 -1
- package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +5 -3
- package/dist/mjs/data-structures/binary-tree/avl-tree.js +6 -4
- package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +18 -15
- package/dist/mjs/data-structures/binary-tree/binary-tree.js +17 -14
- package/dist/mjs/data-structures/binary-tree/bst.d.ts +15 -11
- package/dist/mjs/data-structures/binary-tree/bst.js +17 -13
- package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +19 -13
- package/dist/mjs/data-structures/binary-tree/rb-tree.js +20 -14
- package/dist/mjs/data-structures/binary-tree/tree-multimap.d.ts +21 -14
- package/dist/mjs/data-structures/binary-tree/tree-multimap.js +25 -18
- package/dist/mjs/data-structures/graph/abstract-graph.d.ts +52 -52
- package/dist/mjs/data-structures/graph/abstract-graph.js +79 -79
- package/dist/mjs/data-structures/graph/directed-graph.d.ts +47 -47
- package/dist/mjs/data-structures/graph/directed-graph.js +56 -56
- package/dist/mjs/data-structures/graph/map-graph.d.ts +5 -5
- package/dist/mjs/data-structures/graph/map-graph.js +8 -8
- package/dist/mjs/data-structures/graph/undirected-graph.d.ts +29 -29
- package/dist/mjs/data-structures/graph/undirected-graph.js +59 -59
- package/dist/mjs/data-structures/hash/hash-map.d.ts +8 -8
- package/dist/mjs/data-structures/hash/hash-map.js +3 -3
- package/dist/mjs/interfaces/binary-tree.d.ts +1 -1
- package/dist/mjs/types/data-structures/base/base.d.ts +3 -3
- package/dist/umd/data-structure-typed.js +302 -280
- package/dist/umd/data-structure-typed.min.js +2 -2
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +1 -1
- package/src/data-structures/base/iterable-base.ts +6 -6
- package/src/data-structures/binary-tree/avl-tree.ts +8 -5
- package/src/data-structures/binary-tree/binary-tree.ts +23 -19
- package/src/data-structures/binary-tree/bst.ts +19 -14
- package/src/data-structures/binary-tree/rb-tree.ts +20 -14
- package/src/data-structures/binary-tree/tree-multimap.ts +27 -19
- package/src/data-structures/graph/abstract-graph.ts +82 -82
- package/src/data-structures/graph/directed-graph.ts +56 -56
- package/src/data-structures/graph/map-graph.ts +8 -8
- package/src/data-structures/graph/undirected-graph.ts +59 -59
- package/src/data-structures/hash/hash-map.ts +8 -8
- package/src/interfaces/binary-tree.ts +1 -1
- package/src/types/data-structures/base/base.ts +3 -3
- package/test/integration/bst.test.ts +1 -1
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +1 -1
- package/test/unit/data-structures/binary-tree/tree-multimap.test.ts +3 -3
- package/test/unit/data-structures/graph/directed-graph.test.ts +15 -15
- package/test/unit/data-structures/graph/map-graph.test.ts +3 -3
- package/test/unit/data-structures/graph/undirected-graph.test.ts +12 -12
|
@@ -15,7 +15,7 @@ export declare class DirectedEdge<E = any> extends AbstractEdge<E> {
|
|
|
15
15
|
src: VertexKey;
|
|
16
16
|
dest: VertexKey;
|
|
17
17
|
/**
|
|
18
|
-
* The constructor function initializes the source and destination
|
|
18
|
+
* The constructor function initializes the source and destination vertexMap of an edge, along with an optional weight
|
|
19
19
|
* and value.
|
|
20
20
|
* @param {VertexKey} src - The `src` parameter is the source vertex ID. It represents the starting point of an edge in
|
|
21
21
|
* a graph.
|
|
@@ -43,7 +43,7 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
|
|
|
43
43
|
/**
|
|
44
44
|
* The function creates a new vertex with an optional value and returns it.
|
|
45
45
|
* @param {VertexKey} key - The `key` parameter is the unique identifier for the vertex. It is of type `VertexKey`, which
|
|
46
|
-
* could be a number or a string depending on how you want to identify your
|
|
46
|
+
* could be a number or a string depending on how you want to identify your vertexMap.
|
|
47
47
|
* @param [value] - The 'value' parameter is an optional value that can be assigned to the vertex. If a value is provided,
|
|
48
48
|
* it will be assigned to the 'value' property of the vertex. If no value is provided, the 'value' property will be
|
|
49
49
|
* assigned the same value as the 'key' parameter
|
|
@@ -55,7 +55,7 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
|
|
|
55
55
|
* 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.
|
|
56
56
|
*/
|
|
57
57
|
/**
|
|
58
|
-
* The function creates a directed edge between two
|
|
58
|
+
* The function creates a directed edge between two vertexMap with an optional weight and value.
|
|
59
59
|
* @param {VertexKey} src - The source vertex ID of the edge. It represents the starting point of the edge.
|
|
60
60
|
* @param {VertexKey} dest - The `dest` parameter is the identifier of the destination vertex for the edge.
|
|
61
61
|
* @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge. If no
|
|
@@ -66,41 +66,41 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
|
|
|
66
66
|
*/
|
|
67
67
|
createEdge(src: VertexKey, dest: VertexKey, weight?: number, value?: E): EO;
|
|
68
68
|
/**
|
|
69
|
-
* Time Complexity: O(|V|) where |V| is the number of
|
|
69
|
+
* Time Complexity: O(|V|) where |V| is the number of vertexMap
|
|
70
70
|
* Space Complexity: O(1)
|
|
71
71
|
*/
|
|
72
72
|
/**
|
|
73
|
-
* Time Complexity: O(|V|) where |V| is the number of
|
|
73
|
+
* Time Complexity: O(|V|) where |V| is the number of vertexMap
|
|
74
74
|
* Space Complexity: O(1)
|
|
75
75
|
*
|
|
76
|
-
* The `getEdge` function retrieves an edge between two
|
|
76
|
+
* The `getEdge` function retrieves an edge between two vertexMap based on their source and destination IDs.
|
|
77
77
|
* @param {VO | VertexKey | undefined} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
|
|
78
78
|
* @param {VO | VertexKey | undefined} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
|
|
79
79
|
* destination vertex of the edge. It can be either a vertex object (`VO`), a vertex ID (`VertexKey`), or `undefined` if the
|
|
80
80
|
* destination is not specified.
|
|
81
|
-
* @returns the first edge found between the source and destination
|
|
81
|
+
* @returns the first edge found between the source and destination vertexMap, or undefined if no such edge is found.
|
|
82
82
|
*/
|
|
83
83
|
getEdge(srcOrKey: VO | VertexKey | undefined, destOrKey: VO | VertexKey | undefined): EO | undefined;
|
|
84
84
|
/**
|
|
85
|
-
* Time Complexity: O(|E|) where |E| is the number of
|
|
85
|
+
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
|
86
86
|
* Space Complexity: O(1)
|
|
87
87
|
*/
|
|
88
88
|
/**
|
|
89
|
-
* Time Complexity: O(|E|) where |E| is the number of
|
|
89
|
+
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
|
90
90
|
* Space Complexity: O(1)
|
|
91
91
|
*
|
|
92
|
-
* The function removes an edge between two
|
|
92
|
+
* The function removes an edge between two vertexMap in a graph and returns the removed edge.
|
|
93
93
|
* @param {VO | VertexKey} srcOrKey - The source vertex or its ID.
|
|
94
94
|
* @param {VO | VertexKey} destOrKey - The `destOrKey` parameter represents the destination vertex or its ID.
|
|
95
95
|
* @returns the removed edge (EO) if it exists, or undefined if either the source or destination vertex does not exist.
|
|
96
96
|
*/
|
|
97
97
|
deleteEdgeSrcToDest(srcOrKey: VO | VertexKey, destOrKey: VO | VertexKey): EO | undefined;
|
|
98
98
|
/**
|
|
99
|
-
* Time Complexity: O(E) where E is the number of
|
|
99
|
+
* Time Complexity: O(E) where E is the number of edgeMap
|
|
100
100
|
* Space Complexity: O(1)
|
|
101
101
|
*/
|
|
102
102
|
/**
|
|
103
|
-
* Time Complexity: O(E) where E is the number of
|
|
103
|
+
* Time Complexity: O(E) where E is the number of edgeMap
|
|
104
104
|
* Space Complexity: O(1)
|
|
105
105
|
*
|
|
106
106
|
* The `deleteEdge` function removes an edge from a graph and returns the removed edge.
|
|
@@ -128,19 +128,19 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
|
|
|
128
128
|
*/
|
|
129
129
|
deleteVertex(vertexOrKey: VO | VertexKey): boolean;
|
|
130
130
|
/**
|
|
131
|
-
* Time Complexity: O(|E|) where |E| is the number of
|
|
131
|
+
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
|
132
132
|
* Space Complexity: O(1)
|
|
133
133
|
*/
|
|
134
134
|
/**
|
|
135
|
-
* Time Complexity: O(|E|) where |E| is the number of
|
|
135
|
+
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
|
136
136
|
* Space Complexity: O(1)
|
|
137
137
|
*
|
|
138
|
-
* The function removes
|
|
138
|
+
* The function removes edgeMap between two vertexMap and returns the removed edgeMap.
|
|
139
139
|
* @param {VertexKey | VO} v1 - The parameter `v1` can be either a `VertexKey` or a `VO`. A `VertexKey` represents the
|
|
140
140
|
* unique identifier of a vertex in a graph, while `VO` represents the actual vertex object.
|
|
141
141
|
* @param {VertexKey | VO} v2 - The parameter `v2` represents either a `VertexKey` or a `VO` object. It is used to specify
|
|
142
142
|
* the second vertex in the edge that needs to be removed.
|
|
143
|
-
* @returns an array of removed
|
|
143
|
+
* @returns an array of removed edgeMap (EO[]).
|
|
144
144
|
*/
|
|
145
145
|
deleteEdgesBetween(v1: VertexKey | VO, v2: VertexKey | VO): EO[];
|
|
146
146
|
/**
|
|
@@ -151,10 +151,10 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
|
|
|
151
151
|
* Time Complexity: O(1)
|
|
152
152
|
* Space Complexity: O(1)
|
|
153
153
|
*
|
|
154
|
-
* The function `incomingEdgesOf` returns an array of incoming
|
|
154
|
+
* The function `incomingEdgesOf` returns an array of incoming edgeMap for a given vertex or vertex ID.
|
|
155
155
|
* @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
|
|
156
156
|
* (`VertexKey`).
|
|
157
|
-
* @returns The method `incomingEdgesOf` returns an array of
|
|
157
|
+
* @returns The method `incomingEdgesOf` returns an array of edgeMap (`EO[]`).
|
|
158
158
|
*/
|
|
159
159
|
incomingEdgesOf(vertexOrKey: VO | VertexKey): EO[];
|
|
160
160
|
/**
|
|
@@ -165,10 +165,10 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
|
|
|
165
165
|
* Time Complexity: O(1)
|
|
166
166
|
* Space Complexity: O(1)
|
|
167
167
|
*
|
|
168
|
-
* The function `outgoingEdgesOf` returns an array of outgoing
|
|
168
|
+
* The function `outgoingEdgesOf` returns an array of outgoing edgeMap from a given vertex or vertex ID.
|
|
169
169
|
* @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can accept either a vertex object (`VO`) or a vertex ID
|
|
170
170
|
* (`VertexKey`).
|
|
171
|
-
* @returns The method `outgoingEdgesOf` returns an array of
|
|
171
|
+
* @returns The method `outgoingEdgesOf` returns an array of edgeMap (`EO[]`).
|
|
172
172
|
*/
|
|
173
173
|
outgoingEdgesOf(vertexOrKey: VO | VertexKey): EO[];
|
|
174
174
|
/**
|
|
@@ -192,9 +192,9 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
|
|
|
192
192
|
* Time Complexity: O(1)
|
|
193
193
|
* Space Complexity: O(1)
|
|
194
194
|
*
|
|
195
|
-
* The function "inDegreeOf" returns the number of incoming
|
|
195
|
+
* The function "inDegreeOf" returns the number of incoming edgeMap for a given vertex.
|
|
196
196
|
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
|
|
197
|
-
* @returns The number of incoming
|
|
197
|
+
* @returns The number of incoming edgeMap of the specified vertex or vertex ID.
|
|
198
198
|
*/
|
|
199
199
|
inDegreeOf(vertexOrKey: VertexKey | VO): number;
|
|
200
200
|
/**
|
|
@@ -205,9 +205,9 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
|
|
|
205
205
|
* Time Complexity: O(1)
|
|
206
206
|
* Space Complexity: O(1)
|
|
207
207
|
*
|
|
208
|
-
* The function `outDegreeOf` returns the number of outgoing
|
|
208
|
+
* The function `outDegreeOf` returns the number of outgoing edgeMap from a given vertex.
|
|
209
209
|
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
|
|
210
|
-
* @returns The number of outgoing
|
|
210
|
+
* @returns The number of outgoing edgeMap from the specified vertex or vertex ID.
|
|
211
211
|
*/
|
|
212
212
|
outDegreeOf(vertexOrKey: VertexKey | VO): number;
|
|
213
213
|
/**
|
|
@@ -218,9 +218,9 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
|
|
|
218
218
|
* Time Complexity: O(1)
|
|
219
219
|
* Space Complexity: O(1)
|
|
220
220
|
*
|
|
221
|
-
* The function "edgesOf" returns an array of both outgoing and incoming
|
|
221
|
+
* The function "edgesOf" returns an array of both outgoing and incoming edgeMap of a given vertex or vertex ID.
|
|
222
222
|
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
|
|
223
|
-
* @returns The function `edgesOf` returns an array of
|
|
223
|
+
* @returns The function `edgesOf` returns an array of edgeMap.
|
|
224
224
|
*/
|
|
225
225
|
edgesOf(vertexOrKey: VertexKey | VO): EO[];
|
|
226
226
|
/**
|
|
@@ -250,59 +250,59 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
|
|
|
250
250
|
*/
|
|
251
251
|
getEdgeDest(e: EO): VO | undefined;
|
|
252
252
|
/**
|
|
253
|
-
* Time Complexity: O(|E|) where |E| is the number of
|
|
253
|
+
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
|
254
254
|
* Space Complexity: O(1)
|
|
255
255
|
*/
|
|
256
256
|
/**
|
|
257
|
-
* Time Complexity: O(|E|) where |E| is the number of
|
|
257
|
+
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
|
258
258
|
* Space Complexity: O(1)
|
|
259
259
|
*
|
|
260
|
-
* The function `getDestinations` returns an array of destination
|
|
260
|
+
* The function `getDestinations` returns an array of destination vertexMap connected to a given vertex.
|
|
261
261
|
* @param {VO | VertexKey | undefined} vertex - The `vertex` parameter represents the starting vertex from which we want to
|
|
262
262
|
* find the destinations. It can be either a `VO` object, a `VertexKey` value, or `undefined`.
|
|
263
|
-
* @returns an array of
|
|
263
|
+
* @returns an array of vertexMap (VO[]).
|
|
264
264
|
*/
|
|
265
265
|
getDestinations(vertex: VO | VertexKey | undefined): VO[];
|
|
266
266
|
/**
|
|
267
|
-
* Time Complexity: O(|V| + |E|) where |V| is the number of
|
|
267
|
+
* Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
|
|
268
268
|
* Space Complexity: O(|V|)
|
|
269
269
|
*/
|
|
270
270
|
/**
|
|
271
|
-
* Time Complexity: O(|V| + |E|) where |V| is the number of
|
|
271
|
+
* Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
|
|
272
272
|
* Space Complexity: O(|V|)
|
|
273
273
|
*
|
|
274
|
-
* The `topologicalSort` function performs a topological sort on a graph and returns an array of
|
|
274
|
+
* The `topologicalSort` function performs a topological sort on a graph and returns an array of vertexMap or vertex IDs
|
|
275
275
|
* in the sorted order, or undefined if the graph contains a cycle.
|
|
276
276
|
* @param {'vertex' | 'key'} [propertyName] - The `propertyName` parameter is an optional parameter that specifies the
|
|
277
|
-
* property to use for sorting the
|
|
278
|
-
* specified, the
|
|
279
|
-
* @returns an array of
|
|
277
|
+
* property to use for sorting the vertexMap. It can have two possible values: 'vertex' or 'key'. If 'vertex' is
|
|
278
|
+
* specified, the vertexMap themselves will be used for sorting. If 'key' is specified, the ids of
|
|
279
|
+
* @returns an array of vertexMap or vertex IDs in topological order. If there is a cycle in the graph, it returns undefined.
|
|
280
280
|
*/
|
|
281
281
|
topologicalSort(propertyName?: 'vertex' | 'key'): Array<VO | VertexKey> | undefined;
|
|
282
282
|
/**
|
|
283
|
-
* Time Complexity: O(|E|) where |E| is the number of
|
|
283
|
+
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
|
284
284
|
* Space Complexity: O(|E|)
|
|
285
285
|
*/
|
|
286
286
|
/**
|
|
287
|
-
* Time Complexity: O(|E|) where |E| is the number of
|
|
287
|
+
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
|
288
288
|
* Space Complexity: O(|E|)
|
|
289
289
|
*
|
|
290
|
-
* The `edgeSet` function returns an array of all the
|
|
291
|
-
* @returns The `edgeSet()` method returns an array of
|
|
290
|
+
* The `edgeSet` function returns an array of all the edgeMap in the graph.
|
|
291
|
+
* @returns The `edgeSet()` method returns an array of edgeMap (`EO[]`).
|
|
292
292
|
*/
|
|
293
293
|
edgeSet(): EO[];
|
|
294
294
|
/**
|
|
295
|
-
* Time Complexity: O(|E|) where |E| is the number of
|
|
295
|
+
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
|
296
296
|
* Space Complexity: O(1)
|
|
297
297
|
*/
|
|
298
298
|
/**
|
|
299
|
-
* Time Complexity: O(|E|) where |E| is the number of
|
|
299
|
+
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
|
300
300
|
* Space Complexity: O(1)
|
|
301
301
|
*
|
|
302
|
-
* The function `getNeighbors` returns an array of neighboring
|
|
302
|
+
* The function `getNeighbors` returns an array of neighboring vertexMap of a given vertex or vertex ID in a graph.
|
|
303
303
|
* @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
|
|
304
304
|
* (`VertexKey`).
|
|
305
|
-
* @returns an array of
|
|
305
|
+
* @returns an array of vertexMap (VO[]).
|
|
306
306
|
*/
|
|
307
307
|
getNeighbors(vertexOrKey: VO | VertexKey): VO[];
|
|
308
308
|
/**
|
|
@@ -313,10 +313,10 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
|
|
|
313
313
|
* Time Complexity: O(1)
|
|
314
314
|
* Space Complexity: O(1)
|
|
315
315
|
*
|
|
316
|
-
* The function "getEndsOfEdge" returns the source and destination
|
|
316
|
+
* The function "getEndsOfEdge" returns the source and destination vertexMap of an edge if it exists in the graph,
|
|
317
317
|
* otherwise it returns undefined.
|
|
318
318
|
* @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph.
|
|
319
|
-
* @returns The function `getEndsOfEdge` returns an array containing two
|
|
319
|
+
* @returns The function `getEndsOfEdge` returns an array containing two vertexMap `[VO, VO]` if the edge exists in the
|
|
320
320
|
* graph. If the edge does not exist, it returns `undefined`.
|
|
321
321
|
*/
|
|
322
322
|
getEndsOfEdge(edge: EO): [VO, VO] | undefined;
|
|
@@ -328,7 +328,7 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
|
|
|
328
328
|
* Time Complexity: O(1)
|
|
329
329
|
* Space Complexity: O(1)
|
|
330
330
|
*
|
|
331
|
-
* The function `_addEdgeOnly` adds an edge to a graph if the source and destination
|
|
331
|
+
* The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertexMap exist.
|
|
332
332
|
* @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph. It is the edge that
|
|
333
333
|
* needs to be added to the graph.
|
|
334
334
|
* @returns a boolean value. It returns true if the edge was successfully added to the graph, and false if either the
|
|
@@ -23,7 +23,7 @@ export class DirectedEdge extends AbstractEdge {
|
|
|
23
23
|
src;
|
|
24
24
|
dest;
|
|
25
25
|
/**
|
|
26
|
-
* The constructor function initializes the source and destination
|
|
26
|
+
* The constructor function initializes the source and destination vertexMap of an edge, along with an optional weight
|
|
27
27
|
* and value.
|
|
28
28
|
* @param {VertexKey} src - The `src` parameter is the source vertex ID. It represents the starting point of an edge in
|
|
29
29
|
* a graph.
|
|
@@ -61,7 +61,7 @@ export class DirectedGraph extends AbstractGraph {
|
|
|
61
61
|
/**
|
|
62
62
|
* The function creates a new vertex with an optional value and returns it.
|
|
63
63
|
* @param {VertexKey} key - The `key` parameter is the unique identifier for the vertex. It is of type `VertexKey`, which
|
|
64
|
-
* could be a number or a string depending on how you want to identify your
|
|
64
|
+
* could be a number or a string depending on how you want to identify your vertexMap.
|
|
65
65
|
* @param [value] - The 'value' parameter is an optional value that can be assigned to the vertex. If a value is provided,
|
|
66
66
|
* it will be assigned to the 'value' property of the vertex. If no value is provided, the 'value' property will be
|
|
67
67
|
* assigned the same value as the 'key' parameter
|
|
@@ -75,7 +75,7 @@ export class DirectedGraph extends AbstractGraph {
|
|
|
75
75
|
* 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.
|
|
76
76
|
*/
|
|
77
77
|
/**
|
|
78
|
-
* The function creates a directed edge between two
|
|
78
|
+
* The function creates a directed edge between two vertexMap with an optional weight and value.
|
|
79
79
|
* @param {VertexKey} src - The source vertex ID of the edge. It represents the starting point of the edge.
|
|
80
80
|
* @param {VertexKey} dest - The `dest` parameter is the identifier of the destination vertex for the edge.
|
|
81
81
|
* @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge. If no
|
|
@@ -88,43 +88,43 @@ export class DirectedGraph extends AbstractGraph {
|
|
|
88
88
|
return new DirectedEdge(src, dest, weight ?? 1, value);
|
|
89
89
|
}
|
|
90
90
|
/**
|
|
91
|
-
* Time Complexity: O(|V|) where |V| is the number of
|
|
91
|
+
* Time Complexity: O(|V|) where |V| is the number of vertexMap
|
|
92
92
|
* Space Complexity: O(1)
|
|
93
93
|
*/
|
|
94
94
|
/**
|
|
95
|
-
* Time Complexity: O(|V|) where |V| is the number of
|
|
95
|
+
* Time Complexity: O(|V|) where |V| is the number of vertexMap
|
|
96
96
|
* Space Complexity: O(1)
|
|
97
97
|
*
|
|
98
|
-
* The `getEdge` function retrieves an edge between two
|
|
98
|
+
* The `getEdge` function retrieves an edge between two vertexMap based on their source and destination IDs.
|
|
99
99
|
* @param {VO | VertexKey | undefined} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
|
|
100
100
|
* @param {VO | VertexKey | undefined} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
|
|
101
101
|
* destination vertex of the edge. It can be either a vertex object (`VO`), a vertex ID (`VertexKey`), or `undefined` if the
|
|
102
102
|
* destination is not specified.
|
|
103
|
-
* @returns the first edge found between the source and destination
|
|
103
|
+
* @returns the first edge found between the source and destination vertexMap, or undefined if no such edge is found.
|
|
104
104
|
*/
|
|
105
105
|
getEdge(srcOrKey, destOrKey) {
|
|
106
|
-
let
|
|
106
|
+
let edgeMap = [];
|
|
107
107
|
if (srcOrKey !== undefined && destOrKey !== undefined) {
|
|
108
108
|
const src = this._getVertex(srcOrKey);
|
|
109
109
|
const dest = this._getVertex(destOrKey);
|
|
110
110
|
if (src && dest) {
|
|
111
111
|
const srcOutEdges = this._outEdgeMap.get(src);
|
|
112
112
|
if (srcOutEdges) {
|
|
113
|
-
|
|
113
|
+
edgeMap = srcOutEdges.filter(edge => edge.dest === dest.key);
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
return
|
|
117
|
+
return edgeMap[0] || undefined;
|
|
118
118
|
}
|
|
119
119
|
/**
|
|
120
|
-
* Time Complexity: O(|E|) where |E| is the number of
|
|
120
|
+
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
|
121
121
|
* Space Complexity: O(1)
|
|
122
122
|
*/
|
|
123
123
|
/**
|
|
124
|
-
* Time Complexity: O(|E|) where |E| is the number of
|
|
124
|
+
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
|
125
125
|
* Space Complexity: O(1)
|
|
126
126
|
*
|
|
127
|
-
* The function removes an edge between two
|
|
127
|
+
* The function removes an edge between two vertexMap in a graph and returns the removed edge.
|
|
128
128
|
* @param {VO | VertexKey} srcOrKey - The source vertex or its ID.
|
|
129
129
|
* @param {VO | VertexKey} destOrKey - The `destOrKey` parameter represents the destination vertex or its ID.
|
|
130
130
|
* @returns the removed edge (EO) if it exists, or undefined if either the source or destination vertex does not exist.
|
|
@@ -147,11 +147,11 @@ export class DirectedGraph extends AbstractGraph {
|
|
|
147
147
|
return removed;
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
150
|
-
* Time Complexity: O(E) where E is the number of
|
|
150
|
+
* Time Complexity: O(E) where E is the number of edgeMap
|
|
151
151
|
* Space Complexity: O(1)
|
|
152
152
|
*/
|
|
153
153
|
/**
|
|
154
|
-
* Time Complexity: O(E) where E is the number of
|
|
154
|
+
* Time Complexity: O(E) where E is the number of edgeMap
|
|
155
155
|
* Space Complexity: O(1)
|
|
156
156
|
*
|
|
157
157
|
* The `deleteEdge` function removes an edge from a graph and returns the removed edge.
|
|
@@ -219,22 +219,22 @@ export class DirectedGraph extends AbstractGraph {
|
|
|
219
219
|
this._outEdgeMap.delete(vertex);
|
|
220
220
|
this._inEdgeMap.delete(vertex);
|
|
221
221
|
}
|
|
222
|
-
return this.
|
|
222
|
+
return this._vertexMap.delete(vertexKey);
|
|
223
223
|
}
|
|
224
224
|
/**
|
|
225
|
-
* Time Complexity: O(|E|) where |E| is the number of
|
|
225
|
+
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
|
226
226
|
* Space Complexity: O(1)
|
|
227
227
|
*/
|
|
228
228
|
/**
|
|
229
|
-
* Time Complexity: O(|E|) where |E| is the number of
|
|
229
|
+
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
|
230
230
|
* Space Complexity: O(1)
|
|
231
231
|
*
|
|
232
|
-
* The function removes
|
|
232
|
+
* The function removes edgeMap between two vertexMap and returns the removed edgeMap.
|
|
233
233
|
* @param {VertexKey | VO} v1 - The parameter `v1` can be either a `VertexKey` or a `VO`. A `VertexKey` represents the
|
|
234
234
|
* unique identifier of a vertex in a graph, while `VO` represents the actual vertex object.
|
|
235
235
|
* @param {VertexKey | VO} v2 - The parameter `v2` represents either a `VertexKey` or a `VO` object. It is used to specify
|
|
236
236
|
* the second vertex in the edge that needs to be removed.
|
|
237
|
-
* @returns an array of removed
|
|
237
|
+
* @returns an array of removed edgeMap (EO[]).
|
|
238
238
|
*/
|
|
239
239
|
deleteEdgesBetween(v1, v2) {
|
|
240
240
|
const removed = [];
|
|
@@ -254,10 +254,10 @@ export class DirectedGraph extends AbstractGraph {
|
|
|
254
254
|
* Time Complexity: O(1)
|
|
255
255
|
* Space Complexity: O(1)
|
|
256
256
|
*
|
|
257
|
-
* The function `incomingEdgesOf` returns an array of incoming
|
|
257
|
+
* The function `incomingEdgesOf` returns an array of incoming edgeMap for a given vertex or vertex ID.
|
|
258
258
|
* @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
|
|
259
259
|
* (`VertexKey`).
|
|
260
|
-
* @returns The method `incomingEdgesOf` returns an array of
|
|
260
|
+
* @returns The method `incomingEdgesOf` returns an array of edgeMap (`EO[]`).
|
|
261
261
|
*/
|
|
262
262
|
incomingEdgesOf(vertexOrKey) {
|
|
263
263
|
const target = this._getVertex(vertexOrKey);
|
|
@@ -274,10 +274,10 @@ export class DirectedGraph extends AbstractGraph {
|
|
|
274
274
|
* Time Complexity: O(1)
|
|
275
275
|
* Space Complexity: O(1)
|
|
276
276
|
*
|
|
277
|
-
* The function `outgoingEdgesOf` returns an array of outgoing
|
|
277
|
+
* The function `outgoingEdgesOf` returns an array of outgoing edgeMap from a given vertex or vertex ID.
|
|
278
278
|
* @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can accept either a vertex object (`VO`) or a vertex ID
|
|
279
279
|
* (`VertexKey`).
|
|
280
|
-
* @returns The method `outgoingEdgesOf` returns an array of
|
|
280
|
+
* @returns The method `outgoingEdgesOf` returns an array of edgeMap (`EO[]`).
|
|
281
281
|
*/
|
|
282
282
|
outgoingEdgesOf(vertexOrKey) {
|
|
283
283
|
const target = this._getVertex(vertexOrKey);
|
|
@@ -309,9 +309,9 @@ export class DirectedGraph extends AbstractGraph {
|
|
|
309
309
|
* Time Complexity: O(1)
|
|
310
310
|
* Space Complexity: O(1)
|
|
311
311
|
*
|
|
312
|
-
* The function "inDegreeOf" returns the number of incoming
|
|
312
|
+
* The function "inDegreeOf" returns the number of incoming edgeMap for a given vertex.
|
|
313
313
|
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
|
|
314
|
-
* @returns The number of incoming
|
|
314
|
+
* @returns The number of incoming edgeMap of the specified vertex or vertex ID.
|
|
315
315
|
*/
|
|
316
316
|
inDegreeOf(vertexOrKey) {
|
|
317
317
|
return this.incomingEdgesOf(vertexOrKey).length;
|
|
@@ -324,9 +324,9 @@ export class DirectedGraph extends AbstractGraph {
|
|
|
324
324
|
* Time Complexity: O(1)
|
|
325
325
|
* Space Complexity: O(1)
|
|
326
326
|
*
|
|
327
|
-
* The function `outDegreeOf` returns the number of outgoing
|
|
327
|
+
* The function `outDegreeOf` returns the number of outgoing edgeMap from a given vertex.
|
|
328
328
|
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
|
|
329
|
-
* @returns The number of outgoing
|
|
329
|
+
* @returns The number of outgoing edgeMap from the specified vertex or vertex ID.
|
|
330
330
|
*/
|
|
331
331
|
outDegreeOf(vertexOrKey) {
|
|
332
332
|
return this.outgoingEdgesOf(vertexOrKey).length;
|
|
@@ -339,9 +339,9 @@ export class DirectedGraph extends AbstractGraph {
|
|
|
339
339
|
* Time Complexity: O(1)
|
|
340
340
|
* Space Complexity: O(1)
|
|
341
341
|
*
|
|
342
|
-
* The function "edgesOf" returns an array of both outgoing and incoming
|
|
342
|
+
* The function "edgesOf" returns an array of both outgoing and incoming edgeMap of a given vertex or vertex ID.
|
|
343
343
|
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
|
|
344
|
-
* @returns The function `edgesOf` returns an array of
|
|
344
|
+
* @returns The function `edgesOf` returns an array of edgeMap.
|
|
345
345
|
*/
|
|
346
346
|
edgesOf(vertexOrKey) {
|
|
347
347
|
return [...this.outgoingEdgesOf(vertexOrKey), ...this.incomingEdgesOf(vertexOrKey)];
|
|
@@ -377,17 +377,17 @@ export class DirectedGraph extends AbstractGraph {
|
|
|
377
377
|
return this._getVertex(e.dest);
|
|
378
378
|
}
|
|
379
379
|
/**
|
|
380
|
-
* Time Complexity: O(|E|) where |E| is the number of
|
|
380
|
+
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
|
381
381
|
* Space Complexity: O(1)
|
|
382
382
|
*/
|
|
383
383
|
/**
|
|
384
|
-
* Time Complexity: O(|E|) where |E| is the number of
|
|
384
|
+
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
|
385
385
|
* Space Complexity: O(1)
|
|
386
386
|
*
|
|
387
|
-
* The function `getDestinations` returns an array of destination
|
|
387
|
+
* The function `getDestinations` returns an array of destination vertexMap connected to a given vertex.
|
|
388
388
|
* @param {VO | VertexKey | undefined} vertex - The `vertex` parameter represents the starting vertex from which we want to
|
|
389
389
|
* find the destinations. It can be either a `VO` object, a `VertexKey` value, or `undefined`.
|
|
390
|
-
* @returns an array of
|
|
390
|
+
* @returns an array of vertexMap (VO[]).
|
|
391
391
|
*/
|
|
392
392
|
getDestinations(vertex) {
|
|
393
393
|
if (vertex === undefined) {
|
|
@@ -404,26 +404,26 @@ export class DirectedGraph extends AbstractGraph {
|
|
|
404
404
|
return destinations;
|
|
405
405
|
}
|
|
406
406
|
/**
|
|
407
|
-
* Time Complexity: O(|V| + |E|) where |V| is the number of
|
|
407
|
+
* Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
|
|
408
408
|
* Space Complexity: O(|V|)
|
|
409
409
|
*/
|
|
410
410
|
/**
|
|
411
|
-
* Time Complexity: O(|V| + |E|) where |V| is the number of
|
|
411
|
+
* Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
|
|
412
412
|
* Space Complexity: O(|V|)
|
|
413
413
|
*
|
|
414
|
-
* The `topologicalSort` function performs a topological sort on a graph and returns an array of
|
|
414
|
+
* The `topologicalSort` function performs a topological sort on a graph and returns an array of vertexMap or vertex IDs
|
|
415
415
|
* in the sorted order, or undefined if the graph contains a cycle.
|
|
416
416
|
* @param {'vertex' | 'key'} [propertyName] - The `propertyName` parameter is an optional parameter that specifies the
|
|
417
|
-
* property to use for sorting the
|
|
418
|
-
* specified, the
|
|
419
|
-
* @returns an array of
|
|
417
|
+
* property to use for sorting the vertexMap. It can have two possible values: 'vertex' or 'key'. If 'vertex' is
|
|
418
|
+
* specified, the vertexMap themselves will be used for sorting. If 'key' is specified, the ids of
|
|
419
|
+
* @returns an array of vertexMap or vertex IDs in topological order. If there is a cycle in the graph, it returns undefined.
|
|
420
420
|
*/
|
|
421
421
|
topologicalSort(propertyName) {
|
|
422
422
|
propertyName = propertyName ?? 'key';
|
|
423
423
|
// When judging whether there is a cycle in the undirected graph, all nodes with degree of **<= 1** are enqueued
|
|
424
424
|
// When judging whether there is a cycle in the directed graph, all nodes with **in degree = 0** are enqueued
|
|
425
425
|
const statusMap = new Map();
|
|
426
|
-
for (const entry of this.
|
|
426
|
+
for (const entry of this.vertexMap) {
|
|
427
427
|
statusMap.set(entry[1], 0);
|
|
428
428
|
}
|
|
429
429
|
let sorted = [];
|
|
@@ -443,7 +443,7 @@ export class DirectedGraph extends AbstractGraph {
|
|
|
443
443
|
statusMap.set(cur, 2);
|
|
444
444
|
sorted.push(cur);
|
|
445
445
|
};
|
|
446
|
-
for (const entry of this.
|
|
446
|
+
for (const entry of this.vertexMap) {
|
|
447
447
|
if (statusMap.get(entry[1]) === 0) {
|
|
448
448
|
dfs(entry[1]);
|
|
449
449
|
}
|
|
@@ -455,35 +455,35 @@ export class DirectedGraph extends AbstractGraph {
|
|
|
455
455
|
return sorted.reverse();
|
|
456
456
|
}
|
|
457
457
|
/**
|
|
458
|
-
* Time Complexity: O(|E|) where |E| is the number of
|
|
458
|
+
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
|
459
459
|
* Space Complexity: O(|E|)
|
|
460
460
|
*/
|
|
461
461
|
/**
|
|
462
|
-
* Time Complexity: O(|E|) where |E| is the number of
|
|
462
|
+
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
|
463
463
|
* Space Complexity: O(|E|)
|
|
464
464
|
*
|
|
465
|
-
* The `edgeSet` function returns an array of all the
|
|
466
|
-
* @returns The `edgeSet()` method returns an array of
|
|
465
|
+
* The `edgeSet` function returns an array of all the edgeMap in the graph.
|
|
466
|
+
* @returns The `edgeSet()` method returns an array of edgeMap (`EO[]`).
|
|
467
467
|
*/
|
|
468
468
|
edgeSet() {
|
|
469
|
-
let
|
|
469
|
+
let edgeMap = [];
|
|
470
470
|
this._outEdgeMap.forEach(outEdges => {
|
|
471
|
-
|
|
471
|
+
edgeMap = [...edgeMap, ...outEdges];
|
|
472
472
|
});
|
|
473
|
-
return
|
|
473
|
+
return edgeMap;
|
|
474
474
|
}
|
|
475
475
|
/**
|
|
476
|
-
* Time Complexity: O(|E|) where |E| is the number of
|
|
476
|
+
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
|
477
477
|
* Space Complexity: O(1)
|
|
478
478
|
*/
|
|
479
479
|
/**
|
|
480
|
-
* Time Complexity: O(|E|) where |E| is the number of
|
|
480
|
+
* Time Complexity: O(|E|) where |E| is the number of edgeMap
|
|
481
481
|
* Space Complexity: O(1)
|
|
482
482
|
*
|
|
483
|
-
* The function `getNeighbors` returns an array of neighboring
|
|
483
|
+
* The function `getNeighbors` returns an array of neighboring vertexMap of a given vertex or vertex ID in a graph.
|
|
484
484
|
* @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
|
|
485
485
|
* (`VertexKey`).
|
|
486
|
-
* @returns an array of
|
|
486
|
+
* @returns an array of vertexMap (VO[]).
|
|
487
487
|
*/
|
|
488
488
|
getNeighbors(vertexOrKey) {
|
|
489
489
|
const neighbors = [];
|
|
@@ -508,10 +508,10 @@ export class DirectedGraph extends AbstractGraph {
|
|
|
508
508
|
* Time Complexity: O(1)
|
|
509
509
|
* Space Complexity: O(1)
|
|
510
510
|
*
|
|
511
|
-
* The function "getEndsOfEdge" returns the source and destination
|
|
511
|
+
* The function "getEndsOfEdge" returns the source and destination vertexMap of an edge if it exists in the graph,
|
|
512
512
|
* otherwise it returns undefined.
|
|
513
513
|
* @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph.
|
|
514
|
-
* @returns The function `getEndsOfEdge` returns an array containing two
|
|
514
|
+
* @returns The function `getEndsOfEdge` returns an array containing two vertexMap `[VO, VO]` if the edge exists in the
|
|
515
515
|
* graph. If the edge does not exist, it returns `undefined`.
|
|
516
516
|
*/
|
|
517
517
|
getEndsOfEdge(edge) {
|
|
@@ -535,7 +535,7 @@ export class DirectedGraph extends AbstractGraph {
|
|
|
535
535
|
* Time Complexity: O(1)
|
|
536
536
|
* Space Complexity: O(1)
|
|
537
537
|
*
|
|
538
|
-
* The function `_addEdgeOnly` adds an edge to a graph if the source and destination
|
|
538
|
+
* The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertexMap exist.
|
|
539
539
|
* @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph. It is the edge that
|
|
540
540
|
* needs to be added to the graph.
|
|
541
541
|
* @returns a boolean value. It returns true if the edge was successfully added to the graph, and false if either the
|
|
@@ -32,17 +32,17 @@ export declare class MapEdge<E = any> extends DirectedEdge<E> {
|
|
|
32
32
|
}
|
|
33
33
|
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> {
|
|
34
34
|
/**
|
|
35
|
-
* The constructor function initializes the
|
|
36
|
-
* @param {MapGraphCoordinate}
|
|
35
|
+
* The constructor function initializes the originCoord and bottomRight properties of a MapGraphCoordinate object.
|
|
36
|
+
* @param {MapGraphCoordinate} originCoord - The `originCoord` parameter is a `MapGraphCoordinate` object that represents the
|
|
37
37
|
* starting point or reference point of the map graph. It defines the coordinates of the top-left corner of the map
|
|
38
38
|
* graph.
|
|
39
39
|
* @param {MapGraphCoordinate} [bottomRight] - The `bottomRight` parameter is an optional parameter of type
|
|
40
40
|
* `MapGraphCoordinate`. It represents the bottom right coordinate of a map graph. If this parameter is not provided,
|
|
41
41
|
* it will default to `undefined`.
|
|
42
42
|
*/
|
|
43
|
-
constructor(
|
|
44
|
-
protected
|
|
45
|
-
get
|
|
43
|
+
constructor(originCoord: MapGraphCoordinate, bottomRight?: MapGraphCoordinate);
|
|
44
|
+
protected _originCoord: MapGraphCoordinate;
|
|
45
|
+
get originCoord(): MapGraphCoordinate;
|
|
46
46
|
protected _bottomRight: MapGraphCoordinate | undefined;
|
|
47
47
|
get bottomRight(): MapGraphCoordinate | undefined;
|
|
48
48
|
/**
|
|
@@ -37,22 +37,22 @@ export class MapEdge extends DirectedEdge {
|
|
|
37
37
|
}
|
|
38
38
|
export class MapGraph extends DirectedGraph {
|
|
39
39
|
/**
|
|
40
|
-
* The constructor function initializes the
|
|
41
|
-
* @param {MapGraphCoordinate}
|
|
40
|
+
* The constructor function initializes the originCoord and bottomRight properties of a MapGraphCoordinate object.
|
|
41
|
+
* @param {MapGraphCoordinate} originCoord - The `originCoord` parameter is a `MapGraphCoordinate` object that represents the
|
|
42
42
|
* starting point or reference point of the map graph. It defines the coordinates of the top-left corner of the map
|
|
43
43
|
* graph.
|
|
44
44
|
* @param {MapGraphCoordinate} [bottomRight] - The `bottomRight` parameter is an optional parameter of type
|
|
45
45
|
* `MapGraphCoordinate`. It represents the bottom right coordinate of a map graph. If this parameter is not provided,
|
|
46
46
|
* it will default to `undefined`.
|
|
47
47
|
*/
|
|
48
|
-
constructor(
|
|
48
|
+
constructor(originCoord, bottomRight) {
|
|
49
49
|
super();
|
|
50
|
-
this.
|
|
50
|
+
this._originCoord = originCoord;
|
|
51
51
|
this._bottomRight = bottomRight;
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
get
|
|
55
|
-
return this.
|
|
53
|
+
_originCoord = [0, 0];
|
|
54
|
+
get originCoord() {
|
|
55
|
+
return this._originCoord;
|
|
56
56
|
}
|
|
57
57
|
_bottomRight;
|
|
58
58
|
get bottomRight() {
|
|
@@ -69,7 +69,7 @@ export class MapGraph extends DirectedGraph {
|
|
|
69
69
|
* @param {number} long - The `long` parameter represents the longitude coordinate of the vertex.
|
|
70
70
|
* @returns The method is returning a new instance of the `MapVertex` class, casted as type `VO`.
|
|
71
71
|
*/
|
|
72
|
-
createVertex(key, value, lat = this.
|
|
72
|
+
createVertex(key, value, lat = this.originCoord[0], long = this.originCoord[1]) {
|
|
73
73
|
return new MapVertex(key, value, lat, long);
|
|
74
74
|
}
|
|
75
75
|
/**
|