Skip to content

Commit 4de6cec

Browse files
committed
everything checks out, except for that one bug: Error Modal doesn't show up for Dijkstra or A*
1 parent b52b082 commit 4de6cec

File tree

8 files changed

+27
-22
lines changed

8 files changed

+27
-22
lines changed

.eslintcache

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/App.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
import React, { Component } from 'react';
22
import "bootstrap/dist/css/bootstrap.min.css";
33
import PathVisualizer from './components/PathVisualizer/PathVisualizer';
4-
import { Container } from "reactstrap";
54

65
class App extends Component {
7-
state = {}
8-
96
render() {
10-
return (
11-
<div>
12-
<PathVisualizer />
13-
</div>
14-
);
7+
return (
8+
<PathVisualizer />
9+
);
1510
}
1611
}
1712

src/algorithms/bfs.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Performs BFS algorithm; returns *all* nodes in the order
2+
// in which they were visited. Also makes nodes point back to their
3+
// previous node, effectively allowing us to compute the shortest path
4+
// by backtracking from the finish node.
15
export function bfs(grid, startNode, finishNode) {
26
const visitedNodesInOrder = [];
37
// queue to keep track of the visited nodes

src/algorithms/dfs.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Performs DFS algorithm; returns *all* nodes in the order
2+
// in which they were visited. Also makes nodes point back to their
3+
// previous node, effectively allowing us to compute the shortest path
4+
// by backtracking from the finish node.
15
export function dfs(grid, startNode, finishNode) {
26
const visitedNodesInOrder = [];
37
// stack to keep track of the visited nodes

src/components/AppNavbar/AppNavbar.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ const AppNavbar = (props) => {
3434
<NavItem id={"Tooltip-" + 6}>
3535
<NavLink href="https://github.com/Sethuram52001/Path-Finding-Visualizer">GitHub</NavLink>
3636
</NavItem>
37-
<UncontrolledDropdown id={"Tooltip-" + 5} nav inNavbar>
38-
<DropdownToggle nav caret>
37+
<UncontrolledDropdown nav inNavbar>
38+
<DropdownToggle id={"Tooltip-" + 5} nav caret>
3939
Algorithms
4040
</DropdownToggle>
4141
<DropdownMenu right>
@@ -53,8 +53,8 @@ const AppNavbar = (props) => {
5353
</DropdownItem>
5454
</DropdownMenu>
5555
</UncontrolledDropdown>
56-
<UncontrolledDropdown id={"Tooltip-" + 4} nav inNavbar>
57-
<DropdownToggle nav caret>
56+
<UncontrolledDropdown nav inNavbar>
57+
<DropdownToggle id={"Tooltip-" + 4} nav caret>
5858
Generate Maze
5959
</DropdownToggle>
6060
<DropdownMenu right>

src/components/ErrorModal/ErrorModal.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import React from 'react';
22
import { Modal, ModalHeader } from 'reactstrap';
33

4-
const ErrorModal = (props) => {
5-
const {
6-
className
7-
} = props;
4+
const ErrorModal = () => {
85

96
return (
107
<div>
11-
<Modal isOpen={true} className={className}>
12-
<ModalHeader>Path not found</ModalHeader>
8+
<Modal isOpen={true}>
9+
<ModalHeader style={{color: 'black'}}>Path is not found</ModalHeader>
1310
</Modal>
1411
</div>
1512
);

src/components/PathVisualizer/PathVisualizer.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,16 @@ class PathVisualizer extends Component {
293293
}
294294
}
295295

296+
/*------------------------------------------------------------------------------------------------------------------------------*/
297+
298+
// sets the stae to visualizing, to prevent any other func from executing during the visualization
296299
setVisualization = () => {
297300
this.setState({
298301
isVisualizing: !this.state.isVisualizing
299302
});
300303
}
301304

305+
// same as the previous func, but this one to set the state outside of this component, in algorithms visualizing components
302306
handleClick = () => {
303307
setVisualizationState(this);
304308
}

src/maze-algorithms/recursiveDivision.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export function recursiveDivisionMaze(grid, startNode, finishNode) {
1414
return walls;
1515
}
1616

17+
// main func
1718
function getRecursiveWalls(vertical, horizontal, grid, startNode, finishNode) {
1819
if (vertical.length < 2 || horizontal.length < 2)
1920
return;
@@ -31,12 +32,12 @@ function getRecursiveWalls(vertical, horizontal, grid, startNode, finishNode) {
3132
// recursive part where the approach to
3233
// start horizontal or vertical is dependent on dir variable
3334
if (dir === 0) {
34-
addWall(dir, num, vertical, horizontal, startNode, finishNode);
35+
addWalls(dir, num, vertical, horizontal, startNode, finishNode);
3536
getRecursiveWalls(vertical.slice(0, vertical.indexOf(num)), horizontal, grid, startNode, finishNode);
3637
getRecursiveWalls(vertical.slice(vertical.indexOf(num) + 1), horizontal, grid, startNode, finishNode);
3738
}
3839
else {
39-
addWall(dir, num, vertical, horizontal, startNode, finishNode);
40+
addWalls(dir, num, vertical, horizontal, startNode, finishNode);
4041
getRecursiveWalls(vertical, horizontal.slice(0, horizontal.indexOf(num)), grid, startNode, finishNode);
4142
getRecursiveWalls(vertical, horizontal.slice(horizontal.indexOf(num) + 1), grid, startNode, finishNode);
4243
}
@@ -56,7 +57,7 @@ function generateOddRandomNumber(arr) {
5657
}
5758

5859
// func to push the coordinates of nodes into wall array
59-
function addWall(dir, num, vertical, horizontal, startNode, finishNode) {
60+
function addWalls(dir, num, vertical, horizontal, startNode, finishNode) {
6061
let isStartFinish = false;
6162
let tempWalls = [];
6263
if (dir === 0) {

0 commit comments

Comments
 (0)