@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.
@@ -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 ? { inputs: {}, isDirected: false } : _a, _c = _b.inputs, inputs = _c === void 0 ? {} : _c, _d = _b.isDirected, isDirected = _d === void 0 ? false : _d;
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
- if (current) {
139
- states[current] = GraphSearchNodeStates_1.default.DISCOVERED;
140
- var neighbors = ((_a = this._data.get(current)) === null || _a === void 0 ? void 0 : _a.data) || [];
141
- var unexploredNeighbors = neighbors.filter(function (neighbor) { return states[neighbor] === GraphSearchNodeStates_1.default.UNEXPLORED; });
142
- for (var _i = 0, unexploredNeighbors_1 = unexploredNeighbors; _i < unexploredNeighbors_1.length; _i++) {
143
- var neighbor = unexploredNeighbors_1[_i];
144
- states[neighbor] = GraphSearchNodeStates_1.default.DISCOVERED;
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
- if (current) {
171
- states[current] = GraphSearchNodeStates_1.default.DISCOVERED;
172
- var neighbors = ((_a = this._data.get(current)) === null || _a === void 0 ? void 0 : _a.data) || [];
173
- var unexploredNeighbors = neighbors.filter(function (neighbor) { return states[neighbor] === GraphSearchNodeStates_1.default.UNEXPLORED; });
174
- for (var _i = 0, unexploredNeighbors_2 = unexploredNeighbors; _i < unexploredNeighbors_2.length; _i++) {
175
- var neighbor = unexploredNeighbors_2[_i];
176
- states[neighbor] = GraphSearchNodeStates_1.default.DISCOVERED;
177
- distances[neighbor] = distances[current] + 1;
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.25",
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.6.4"
45
+ "typescript": "^4.7.2"
46
46
  }
47
47
  }