Skip to content

Commit 040de56

Browse files
committed
fixed ucs expanded nodes
1 parent a3ae2ca commit 040de56

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/components/GraphTraversalVisualiser/GraphTraversalVisualiser.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
background-color: #0f0;
3636
}
3737

38+
.weight {
39+
background-color: red;
40+
}
41+
3842

3943
.expanded {
4044
background-color: aquamarine;

src/components/GraphTraversalVisualiser/GraphTraversalVisualiser.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ const MatrixVisualization = () => {
139139
colorNodes(result.path, result.expanded);
140140
} else if (method === 'UCS') {
141141
const result = UCS(matrix, [start.row, start.col], [objectives[0].row, objectives[0].col]);
142-
console.log(result.expanded); // TODO: ucs is not saving expanded nodes
142+
console.log(result.expanded);
143143
colorNodes(result.path, result.expanded);
144144
}
145145

src/components/GraphTraversalVisualiser/graphAlgorithms/ucs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function UCS(grid, start, destination) {
1616
let nodeKey = node.toString(); // to string for comparison
1717

1818
if (nodeKey === destination.toString()) { // check if we have arrived at the solution
19-
return { status: "found", path, cost };
19+
return { status: "found", path, cost , expanded};
2020
} else {
2121
if (!(visited.hasOwnProperty(nodeKey))) { // if we have not been to this node, add it
2222
visited[nodeKey] = true; // mark as visited

0 commit comments

Comments
 (0)