@gabrielrufino/cube 1.0.25 → 1.0.26
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/build/Graph/index.js +16 -20
- package/package.json +2 -2
package/build/Graph/index.js
CHANGED
|
@@ -30,7 +30,7 @@ var Queue_1 = __importDefault(require("../Queue"));
|
|
|
30
30
|
var Set_1 = __importDefault(require("../Set"));
|
|
31
31
|
var Graph = /** @class */ (function () {
|
|
32
32
|
function Graph(_a) {
|
|
33
|
-
var _b = _a === void 0 ? {
|
|
33
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.inputs, inputs = _c === void 0 ? {} : _c, _d = _b.isDirected, isDirected = _d === void 0 ? false : _d;
|
|
34
34
|
this._isDirected = isDirected;
|
|
35
35
|
this._data = new Dictionary_1.default();
|
|
36
36
|
var nodes = Object.keys(inputs);
|
|
@@ -135,15 +135,13 @@ var Graph = /** @class */ (function () {
|
|
|
135
135
|
queue.enqueue(startNode);
|
|
136
136
|
while (!queue.isEmpty) {
|
|
137
137
|
var current = queue.dequeue() || '';
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
queue.enqueue(neighbor);
|
|
146
|
-
}
|
|
138
|
+
states[current] = GraphSearchNodeStates_1.default.DISCOVERED;
|
|
139
|
+
var neighbors = ((_a = this._data.get(current)) === null || _a === void 0 ? void 0 : _a.data) || [];
|
|
140
|
+
var unexploredNeighbors = neighbors.filter(function (neighbor) { return states[neighbor] === GraphSearchNodeStates_1.default.UNEXPLORED; });
|
|
141
|
+
for (var _i = 0, unexploredNeighbors_1 = unexploredNeighbors; _i < unexploredNeighbors_1.length; _i++) {
|
|
142
|
+
var neighbor = unexploredNeighbors_1[_i];
|
|
143
|
+
states[neighbor] = GraphSearchNodeStates_1.default.DISCOVERED;
|
|
144
|
+
queue.enqueue(neighbor);
|
|
147
145
|
}
|
|
148
146
|
states[current] = GraphSearchNodeStates_1.default.EXPLORED;
|
|
149
147
|
callback(current);
|
|
@@ -167,16 +165,14 @@ var Graph = /** @class */ (function () {
|
|
|
167
165
|
queue.enqueue(node);
|
|
168
166
|
while (!queue.isEmpty) {
|
|
169
167
|
var current = queue.dequeue() || '';
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
queue.enqueue(neighbor);
|
|
179
|
-
}
|
|
168
|
+
states[current] = GraphSearchNodeStates_1.default.DISCOVERED;
|
|
169
|
+
var neighbors = ((_a = this._data.get(current)) === null || _a === void 0 ? void 0 : _a.data) || [];
|
|
170
|
+
var unexploredNeighbors = neighbors.filter(function (neighbor) { return states[neighbor] === GraphSearchNodeStates_1.default.UNEXPLORED; });
|
|
171
|
+
for (var _i = 0, unexploredNeighbors_2 = unexploredNeighbors; _i < unexploredNeighbors_2.length; _i++) {
|
|
172
|
+
var neighbor = unexploredNeighbors_2[_i];
|
|
173
|
+
states[neighbor] = GraphSearchNodeStates_1.default.DISCOVERED;
|
|
174
|
+
distances[neighbor] = distances[current] + 1;
|
|
175
|
+
queue.enqueue(neighbor);
|
|
180
176
|
}
|
|
181
177
|
states[current] = GraphSearchNodeStates_1.default.EXPLORED;
|
|
182
178
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gabrielrufino/cube",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.26",
|
|
4
4
|
"description": "Data Structures and Algorithms made in Typescript",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -42,6 +42,6 @@
|
|
|
42
42
|
"stryker-cli": "^1.0.2",
|
|
43
43
|
"ts-jest": "^27.1.5",
|
|
44
44
|
"ts-node": "^10.8.0",
|
|
45
|
-
"typescript": "^4.
|
|
45
|
+
"typescript": "^4.7.2"
|
|
46
46
|
}
|
|
47
47
|
}
|