diff --git a/asset-manifest.json b/asset-manifest.json
index 64e115a..28b028d 100644
--- a/asset-manifest.json
+++ b/asset-manifest.json
@@ -1,22 +1,22 @@
{
"files": {
- "main.css": "/pathfinder/static/css/main.5e441c9d.chunk.css",
- "main.js": "/pathfinder/static/js/main.82109f58.chunk.js",
- "main.js.map": "/pathfinder/static/js/main.82109f58.chunk.js.map",
- "runtime-main.js": "/pathfinder/static/js/runtime-main.862bc260.js",
- "runtime-main.js.map": "/pathfinder/static/js/runtime-main.862bc260.js.map",
- "static/js/2.bf2e51bc.chunk.js": "/pathfinder/static/js/2.bf2e51bc.chunk.js",
- "static/js/2.bf2e51bc.chunk.js.map": "/pathfinder/static/js/2.bf2e51bc.chunk.js.map",
- "static/js/3.caa12443.chunk.js": "/pathfinder/static/js/3.caa12443.chunk.js",
- "static/js/3.caa12443.chunk.js.map": "/pathfinder/static/js/3.caa12443.chunk.js.map",
- "index.html": "/pathfinder/index.html",
- "static/css/main.5e441c9d.chunk.css.map": "/pathfinder/static/css/main.5e441c9d.chunk.css.map",
- "static/js/2.bf2e51bc.chunk.js.LICENSE.txt": "/pathfinder/static/js/2.bf2e51bc.chunk.js.LICENSE.txt"
+ "main.css": "/Pathfinding-Visualizer/static/css/main.5e441c9d.chunk.css",
+ "main.js": "/Pathfinding-Visualizer/static/js/main.31158c27.chunk.js",
+ "main.js.map": "/Pathfinding-Visualizer/static/js/main.31158c27.chunk.js.map",
+ "runtime-main.js": "/Pathfinding-Visualizer/static/js/runtime-main.7f58abe0.js",
+ "runtime-main.js.map": "/Pathfinding-Visualizer/static/js/runtime-main.7f58abe0.js.map",
+ "static/js/2.bf2e51bc.chunk.js": "/Pathfinding-Visualizer/static/js/2.bf2e51bc.chunk.js",
+ "static/js/2.bf2e51bc.chunk.js.map": "/Pathfinding-Visualizer/static/js/2.bf2e51bc.chunk.js.map",
+ "static/js/3.caa12443.chunk.js": "/Pathfinding-Visualizer/static/js/3.caa12443.chunk.js",
+ "static/js/3.caa12443.chunk.js.map": "/Pathfinding-Visualizer/static/js/3.caa12443.chunk.js.map",
+ "index.html": "/Pathfinding-Visualizer/index.html",
+ "static/css/main.5e441c9d.chunk.css.map": "/Pathfinding-Visualizer/static/css/main.5e441c9d.chunk.css.map",
+ "static/js/2.bf2e51bc.chunk.js.LICENSE.txt": "/Pathfinding-Visualizer/static/js/2.bf2e51bc.chunk.js.LICENSE.txt"
},
"entrypoints": [
- "static/js/runtime-main.862bc260.js",
+ "static/js/runtime-main.7f58abe0.js",
"static/js/2.bf2e51bc.chunk.js",
"static/css/main.5e441c9d.chunk.css",
- "static/js/main.82109f58.chunk.js"
+ "static/js/main.31158c27.chunk.js"
]
}
\ No newline at end of file
diff --git a/index.html b/index.html
index 89fe793..d4bb372 100644
--- a/index.html
+++ b/index.html
@@ -1 +1 @@
-
Pathfinding Visualizer
\ No newline at end of file
+Pathfinding Visualizer
\ No newline at end of file
diff --git a/static/js/main.82109f58.chunk.js b/static/js/main.31158c27.chunk.js
similarity index 99%
rename from static/js/main.82109f58.chunk.js
rename to static/js/main.31158c27.chunk.js
index 193b5fe..679b53b 100644
--- a/static/js/main.82109f58.chunk.js
+++ b/static/js/main.31158c27.chunk.js
@@ -1,2 +1,2 @@
(this.webpackJsonppathfinder=this.webpackJsonppathfinder||[]).push([[0],{46:function(e,t,n){},47:function(e,t,n){},48:function(e,t,n){},50:function(e,t,n){},55:function(e,t,n){"use strict";n.r(t);var i=n(0),s=n.n(i),a=n(17),o=n.n(a),r=(n(46),n(47),n(31)),c=n(5),d=n(22),l=n(15),u=n(11),h=n(29),f=n(28);function v(e){e.sort((function(e,t){return e.distance-t.distance}))}function O(e,t){var n,i=function(e,t){var n=[],i=e.col,s=e.row;s>0&&n.push(t[s-1][i]);s0&&n.push(t[s][i-1]);i0&&((c=e[r-1][o]).isVisited||(c.previousNode=a,s.push(c))),r0&&((c=e[r][o-1]).isVisited||(c.previousNode=a,s.push(c))),o0&&((c=e[r-1][o]).isVisited||(c.previousNode=a,s.push(c))),r0&&((c=e[r][o-1]).isVisited||(c.previousNode=a,s.push(c))),o0&&n.push(t[s-1][i]);s0&&n.push(t[s][i-1]);i0&&void 0!==arguments[0]?arguments[0]:e.state.ROW_COUNT,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.state.COLUMN_COUNT,i=[],s=0;s "+window.innerWidth+"*"+window.innerHeight),e}return Object(l.a)(n,[{key:"componentDidMount",value:function(){this.updateDimensions(),window.addEventListener("resize",this.updateDimensions.bind(this));var e=this.getInitialGrid();this.setState({grid:e})}},{key:"componentWillUnmount",value:function(){window.removeEventListener("resize",this.updateDimensions.bind(this))}},{key:"toggleIsRunning",value:function(){this.setState({isRunning:!this.state.isRunning})}},{key:"updateDimensions",value:function(){if(window.innerWidth!=this.state.width||window.innerHeight!=this.state.height){this.setState({ROW_COUNT:parseInt(window.innerHeight/31),COLUMN_COUNT:parseInt(window.innerWidth/26),START_NODE_ROW:parseInt(window.innerHeight/30*1/2),START_NODE_COL:parseInt(window.innerWidth/25*1/4),FINISH_NODE_ROW:parseInt(window.innerHeight/30*1/2),FINISH_NODE_COL:parseInt(window.innerWidth/25*3/4)});var e=this.getInitialGrid();this.setState({grid:e})}}},{key:"handleMouseDown",value:function(e,t){if(!this.state.isRunning)if(this.isGridClear())if("node node-start"===document.getElementById("node-".concat(e,"-").concat(t)).className)this.setState({mouseIsPressed:!0,isStartNode:!0,currRow:e,currCol:t});else if("node node-finish"===document.getElementById("node-".concat(e,"-").concat(t)).className)this.setState({mouseIsPressed:!0,isFinishNode:!0,currRow:e,currCol:t});else{var n=W(this.state.grid,e,t);this.setState({grid:n,mouseIsPressed:!0,isWallNode:!0,currRow:e,currCol:t})}else this.clearGrid()}},{key:"isGridClear",value:function(){var e,t=Object(c.a)(this.state.grid);try{for(t.s();!(e=t.n()).done;){var n,i=e.value,s=Object(c.a)(i);try{for(s.s();!(n=s.n()).done;){var a=n.value,o=document.getElementById("node-".concat(a.row,"-").concat(a.col)).className;if("node node-visited"===o||"node node-shortest-path"===o)return!1}}catch(r){s.e(r)}finally{s.f()}}}catch(r){t.e(r)}finally{t.f()}return!0}},{key:"handleMouseEnter",value:function(e,t){if(!this.state.isRunning&&this.state.mouseIsPressed){var n=document.getElementById("node-".concat(e,"-").concat(t)).className;if(this.state.isStartNode){if("node node-wall"!==n)this.state.grid[this.state.currRow][this.state.currCol].isStart=!1,document.getElementById("node-".concat(this.state.currRow,"-").concat(this.state.currCol)).className="node",this.setState({currRow:e,currCol:t}),this.state.grid[e][t].isStart=!0,document.getElementById("node-".concat(e,"-").concat(t)).className="node node-start";this.setState({START_NODE_ROW:e,START_NODE_COL:t})}else if(this.state.isFinishNode){if("node node-wall"!==n)this.state.grid[this.state.currRow][this.state.currCol].isFinish=!1,document.getElementById("node-".concat(this.state.currRow,"-").concat(this.state.currCol)).className="node",this.setState({currRow:e,currCol:t}),this.state.grid[e][t].isFinish=!0,document.getElementById("node-".concat(e,"-").concat(t)).className="node node-finish";this.setState({FINISH_NODE_ROW:e,FINISH_NODE_COL:t})}else if(this.state.isWallNode){var i=W(this.state.grid,e,t);this.setState({grid:i})}}}},{key:"handleMouseUp",value:function(e,t){if(!this.state.isRunning){if(this.setState({mouseIsPressed:!1}),this.state.isStartNode){var n=!this.state.isStartNode;this.setState({isStartNode:n,START_NODE_ROW:e,START_NODE_COL:t})}else if(this.state.isFinishNode){var i=!this.state.isFinishNode;this.setState({isFinishNode:i,FINISH_NODE_ROW:e,FINISH_NODE_COL:t})}this.getInitialGrid()}}},{key:"handleMouseLeave",value:function(){if(this.state.isStartNode){var e=!this.state.isStartNode;this.setState({isStartNode:e,mouseIsPressed:!1})}else if(this.state.isFinishNode){var t=!this.state.isFinishNode;this.setState({isFinishNode:t,mouseIsPressed:!1})}else if(this.state.isWallNode){var n=!this.state.isWallNode;this.setState({isWallNode:n,mouseIsPressed:!1}),this.getInitialGrid()}}},{key:"clearGrid",value:function(){if(!this.state.isRunning){var e,t=this.state.grid.slice(),n=Object(c.a)(t);try{for(n.s();!(e=n.n()).done;){var i,s=e.value,a=Object(c.a)(s);try{for(a.s();!(i=a.n()).done;){var o=i.value,r=document.getElementById("node-".concat(o.row,"-").concat(o.col)).className;"node node-start"!==r&&"node node-finish"!==r&&"node node-wall"!==r&&(document.getElementById("node-".concat(o.row,"-").concat(o.col)).className="node",o.isVisited=!1,o.distance=1/0,o.distanceToFinishNode=Math.abs(this.state.FINISH_NODE_ROW-o.row)+Math.abs(this.state.FINISH_NODE_COL-o.col)),"node node-finish"===r&&(o.isVisited=!1,o.distance=1/0,o.distanceToFinishNode=0),"node node-start"===r&&(o.isVisited=!1,o.distance=1/0,o.distanceToFinishNode=Math.abs(this.state.FINISH_NODE_ROW-o.row)+Math.abs(this.state.FINISH_NODE_COL-o.col),o.isStart=!0,o.isWall=!1,o.previousNode=null,o.isNode=!0)}}catch(d){a.e(d)}finally{a.f()}}}catch(d){n.e(d)}finally{n.f()}}}},{key:"clearWalls",value:function(){if(!this.state.isRunning){var e,t=this.state.grid.slice(),n=Object(c.a)(t);try{for(n.s();!(e=n.n()).done;){var i,s=e.value,a=Object(c.a)(s);try{for(a.s();!(i=a.n()).done;){var o=i.value;"node node-wall"===document.getElementById("node-".concat(o.row,"-").concat(o.col)).className&&(document.getElementById("node-".concat(o.row,"-").concat(o.col)).className="node",o.isWall=!1)}}catch(r){a.e(r)}finally{a.f()}}}catch(r){n.e(r)}finally{n.f()}}}},{key:"visualize",value:function(e){if(!this.state.isRunning){this.clearGrid(),this.toggleIsRunning();var t,n=this.state.grid,i=n[this.state.START_NODE_ROW][this.state.START_NODE_COL],s=n[this.state.FINISH_NODE_ROW][this.state.FINISH_NODE_COL];switch(e){case"Dijkstra":t=j(n,i,s);break;case"AStar":t=N(n,i,s);break;case"BFS":t=p(n,i,s);break;case"DFS":t=m(n,i,s)}var a=function(e){var t=[],n=e;for(;null!==n;)t.unshift(n),n=n.previousNode;return t}(s);a.push("end"),this.animate(t,a)}}},{key:"animate",value:function(e,t){for(var n=this,i=function(i){if(i===e.length)return setTimeout((function(){n.animateShortestPath(t)}),10*i),{v:void 0};setTimeout((function(){var t=e[i],n=document.getElementById("node-".concat(t.row,"-").concat(t.col)).className;"node node-start"!==n&&"node node-finish"!==n&&(document.getElementById("node-".concat(t.row,"-").concat(t.col)).className="node node-visited")}),10*i)},s=0;s<=e.length;s++){var a=i(s);if("object"===typeof a)return a.v}}},{key:"animateShortestPath",value:function(e){for(var t=this,n=function(n){"end"===e[n]?setTimeout((function(){t.toggleIsRunning()}),50*n):setTimeout((function(){var t=e[n],i=document.getElementById("node-".concat(t.row,"-").concat(t.col)).className;"node node-start"!==i&&"node node-finish"!==i&&(document.getElementById("node-".concat(t.row,"-").concat(t.col)).className="node node-shortest-path")}),40*n)},i=0;i nodeA.distance - nodeB.distance);\n}\n\nfunction updateUnvisitedNeighbors(node, grid) {\n const unvisitedNeighbors = getUnvisitedNeighbors(node, grid);\n for (const neighbor of unvisitedNeighbors) {\n neighbor.distance = node.distance + 1 + neighbor.distanceToFinishNode;\n neighbor.previousNode = node;\n }\n}\n\nfunction getUnvisitedNeighbors(node, grid) {\n const neighbors = [];\n const {col, row} = node;\n if (row > 0) neighbors.push(grid[row - 1][col]);\n if (row < grid.length - 1) neighbors.push(grid[row + 1][col]);\n if (col > 0) neighbors.push(grid[row][col - 1]);\n if (col < grid[0].length - 1) neighbors.push(grid[row][col + 1]);\n return neighbors.filter(neighbor => !neighbor.isVisited);\n}\n\nexport default Astar;","function BFS (grid, startNode, endNode){\n const visitedNodesInOrder = [];\n let nextNodesStack = [startNode];\n while (nextNodesStack.length) {\n const currentNode = nextNodesStack.shift();\n if (currentNode === endNode) {\n console.log(\"Found!\");\n return visitedNodesInOrder;\n }\n\n if (\n !currentNode.isWall &&\n (currentNode.isStart || !currentNode.isVisited)\n ) {\n currentNode.isVisited = true;\n visitedNodesInOrder.push(currentNode);\n const {col, row} = currentNode;\n let nextNode;\n if (row > 0) {\n nextNode = grid[row - 1][col];\n if (!nextNode.isVisited) {\n nextNode.previousNode = currentNode;\n nextNodesStack.push(nextNode);\n }\n }\n if (row < grid.length - 1) {\n nextNode = grid[row + 1][col];\n if (!nextNode.isVisited) {\n nextNode.previousNode = currentNode;\n nextNodesStack.push(nextNode);\n }\n }\n if (col > 0) {\n nextNode = grid[row][col - 1];\n if (!nextNode.isVisited) {\n nextNode.previousNode = currentNode;\n nextNodesStack.push(nextNode);\n }\n }\n if (col < grid[0].length - 1) {\n nextNode = grid[row][col + 1];\n if (!nextNode.isVisited) {\n nextNode.previousNode = currentNode;\n nextNodesStack.push(nextNode);\n }\n }\n }\n }\n}\n\nexport default BFS;","function DFS(grid, startNode, endNode) {\n const visitedNodesInOrder = [];\n const nextNodesStack = [];\n nextNodesStack.push(startNode);\n while (nextNodesStack.length) {\n const currentNode = nextNodesStack.pop();\n\n if (currentNode === endNode) {\n console.log(\"Found!\");\n return visitedNodesInOrder;\n }\n\n if (\n !currentNode.isWall &&\n (currentNode.isStart || !currentNode.isVisited)\n ) {\n currentNode.isVisited = true;\n visitedNodesInOrder.push(currentNode);\n\n const {col, row} = currentNode;\n let nextNode;\n if (row > 0) {\n nextNode = grid[row - 1][col];\n if (!nextNode.isVisited) {\n nextNode.previousNode = currentNode;\n nextNodesStack.push(nextNode);\n }\n }\n if (row < grid.length - 1) {\n nextNode = grid[row + 1][col];\n if (!nextNode.isVisited) {\n nextNode.previousNode = currentNode;\n nextNodesStack.push(nextNode);\n }\n }\n if (col > 0) {\n nextNode = grid[row][col - 1];\n if (!nextNode.isVisited) {\n nextNode.previousNode = currentNode;\n nextNodesStack.push(nextNode);\n }\n }\n if (col < grid[0].length - 1) {\n nextNode = grid[row][col + 1];\n if (!nextNode.isVisited) {\n nextNode.previousNode = currentNode;\n nextNodesStack.push(nextNode);\n }\n }\n }\n }\n}\n\nexport default DFS;","function Dijkstra(grid, startNode, endNode) {\n \n const visitedNodesInOrder = [];\n startNode.distance = 0;\n const unvisitedNodes = getAllNodes(grid); \n \n while (unvisitedNodes.length) {\n sortNodesByDistance(unvisitedNodes);\n const closestNode = unvisitedNodes.shift();\n \n if (!closestNode.isWall) {\n \n if (closestNode.distance === Infinity) return visitedNodesInOrder;\n closestNode.isVisited = true;\n visitedNodesInOrder.push(closestNode);\n if (closestNode === endNode){\n console.log(\"Found!\");\n return visitedNodesInOrder;\n } \n updateUnvisitedNeighbors(closestNode, grid);\n }\n }\n}\n\nfunction getAllNodes(grid) {\n const nodes = [];\n for (const row of grid) {\n for (const node of row) {\n nodes.push(node);\n }\n }\n return nodes;\n}\n\nfunction sortNodesByDistance(unvisitedNodes) {\n unvisitedNodes.sort((nodeA, nodeB) => nodeA.distance - nodeB.distance);\n}\n\nfunction updateUnvisitedNeighbors(node, grid) {\n const unvisitedNeighbors = getUnvisitedNeighbors(node, grid);\n for (const neighbor of unvisitedNeighbors) {\n neighbor.distance = node.distance + 1;\n neighbor.previousNode = node;\n }\n}\n\nfunction getUnvisitedNeighbors(node, grid) {\n const neighbors = [];\n const {col, row} = node;\n if (row > 0) neighbors.push(grid[row - 1][col]);\n if (row < grid.length - 1) neighbors.push(grid[row + 1][col]);\n if (col > 0) neighbors.push(grid[row][col - 1]);\n if (col < grid[0].length - 1) neighbors.push(grid[row][col + 1]);\n return neighbors.filter(neighbor => !neighbor.isVisited);\n}\n\nexport default Dijkstra;","import React, {Component} from 'react';\n\nimport './styles/Node.css';\n\nexport default class Node extends Component {\n render() {\n const {\n col,\n isFinish,\n isStart,\n isWall,\n onMouseDown,\n onMouseEnter,\n onMouseUp,\n row,\n } = this.props;\n \n const extraClassName = isFinish\n ? 'node-finish'\n : isStart\n ? 'node-start'\n : isWall\n ? 'node-wall'\n : '';\n\n return (\n onMouseDown(row, col)}\n onMouseEnter={() => onMouseEnter(row, col)}\n onMouseUp={() => onMouseUp()}> | \n );\n }\n}","import React, { Component, useState, useEffect } from 'react';\n\nimport astar from './algorithms/Astar';\nimport bfs from './algorithms/BFS';\nimport dfs from './algorithms/DFS';\nimport dijkstra from './algorithms/Dijkstra';\nimport Node from './Node';\n\nimport { AppBar, Button , Box, Typography, Container } from '@material-ui/core'\nimport { ThemeProvider, createMuiTheme } from '@material-ui/core/styles';\n\nimport './styles/Pathfinder.css';\n\nconst theme = createMuiTheme({\n typography: {\n fontFamily: [\n 'Maven Pro',\n 'sans-serif',\n ].join(','),\n },});\n\nclass Pathfinder extends Component {\n constructor() {\n super();\n this.state = {\n grid: [],\n width: window.innerWidth,\n height: window.innerHeight,\n START_NODE_ROW: parseInt(window.innerHeight/30*1/2),\n START_NODE_COL: parseInt(window.innerWidth/25*1/4),\n FINISH_NODE_ROW: parseInt(window.innerHeight/30*1/2),\n FINISH_NODE_COL: parseInt(window.innerWidth/25*3/4),\n mouseIsPressed: false,\n ROW_COUNT: parseInt(window.innerHeight/31),\n COLUMN_COUNT: parseInt(window.innerWidth/26),\n MOBILE_ROW_COUNT: 10,\n MOBILE_COLUMN_COUNT: 20,\n isRunning: false,\n isStartNode: false,\n isFinishNode: false,\n isWallNode: false, \n currRow: 0,\n currCol: 0,\n isDesktopView: true,\n };\n\n this.handleMouseDown = this.handleMouseDown.bind(this);\n this.handleMouseLeave = this.handleMouseLeave.bind(this);\n this.toggleIsRunning = this.toggleIsRunning.bind(this);\n console.log(\"screen size => \"+window.innerWidth + \"*\" + window.innerHeight); \n }\n\n componentDidMount() {\n this.updateDimensions();\n window.addEventListener(\"resize\", this.updateDimensions.bind(this));\n const grid = this.getInitialGrid();\n this.setState({grid});\n }\n \n componentWillUnmount() {\n window.removeEventListener(\"resize\", this.updateDimensions.bind(this));\n }\n\n toggleIsRunning() {\n this.setState({isRunning: !this.state.isRunning});\n }\n\n updateDimensions() {\n if(window.innerWidth != this.state.width || window.innerHeight != this.state.height) {\n this.setState({ \n ROW_COUNT: parseInt(window.innerHeight/31),\n COLUMN_COUNT: parseInt(window.innerWidth/26),\n START_NODE_ROW: parseInt(window.innerHeight/30*1/2),\n START_NODE_COL: parseInt(window.innerWidth/25*1/4),\n FINISH_NODE_ROW: parseInt(window.innerHeight/30*1/2),\n FINISH_NODE_COL: parseInt(window.innerWidth/25*3/4),\n });\n //console.log(\"screen resized => \"+ window.innerWidth + \"*\" + window.innerHeight);\n const grid = this.getInitialGrid();\n this.setState({grid});\n }\n }\n\n\n /******************** Set up the initial grid ********************/\n getInitialGrid = (\n rowCount = this.state.ROW_COUNT,\n colCount = this.state.COLUMN_COUNT,\n ) => {\n const initialGrid = [];\n for (let row = 0; row < rowCount; row++) {\n const currentRow = [];\n for (let col = 0; col < colCount; col++) {\n currentRow.push(this.createNode(row, col));\n }\n initialGrid.push(currentRow);\n }\n return initialGrid;\n };\n\n createNode = (row, col) => {\n return {\n row,\n col,\n isStart:\n row === this.state.START_NODE_ROW && col === this.state.START_NODE_COL,\n isFinish:\n row === this.state.FINISH_NODE_ROW &&\n col === this.state.FINISH_NODE_COL,\n distance: Infinity,\n distanceToFinishNode:\n Math.abs(this.state.FINISH_NODE_ROW - row) +\n Math.abs(this.state.FINISH_NODE_COL - col),\n isVisited: false,\n isWall: false,\n previousNode: null,\n isNode: true,\n };\n };\n\n /******************** Control mouse events ********************/\n handleMouseDown(row, col) {\n if (!this.state.isRunning) {\n if (this.isGridClear()) {\n if (\n document.getElementById(`node-${row}-${col}`).className ===\n 'node node-start'\n ) {\n this.setState({\n mouseIsPressed: true,\n isStartNode: true,\n currRow: row,\n currCol: col,\n });\n } else if (\n document.getElementById(`node-${row}-${col}`).className ===\n 'node node-finish'\n ) {\n this.setState({\n mouseIsPressed: true,\n isFinishNode: true,\n currRow: row,\n currCol: col,\n });\n } else {\n const newGrid = getNewGridWithWallToggled(this.state.grid, row, col);\n this.setState({\n grid: newGrid,\n mouseIsPressed: true,\n isWallNode: true,\n currRow: row,\n currCol: col,\n });\n }\n } else {\n this.clearGrid();\n }\n }\n }\n\n isGridClear() {\n for (const row of this.state.grid) {\n for (const node of row) {\n const nodeClassName = document.getElementById(\n `node-${node.row}-${node.col}`,\n ).className;\n if (\n nodeClassName === 'node node-visited' ||\n nodeClassName === 'node node-shortest-path'\n ) {\n return false;\n }\n }\n }\n return true;\n }\n\n handleMouseEnter(row, col) {\n if (!this.state.isRunning) {\n if (this.state.mouseIsPressed) {\n const nodeClassName = document.getElementById(`node-${row}-${col}`)\n .className;\n if (this.state.isStartNode) {\n if (nodeClassName !== 'node node-wall') {\n const prevStartNode = this.state.grid[this.state.currRow][\n this.state.currCol\n ];\n prevStartNode.isStart = false;\n document.getElementById(\n `node-${this.state.currRow}-${this.state.currCol}`,\n ).className = 'node';\n\n this.setState({currRow: row, currCol: col});\n const currStartNode = this.state.grid[row][col];\n currStartNode.isStart = true;\n document.getElementById(`node-${row}-${col}`).className =\n 'node node-start';\n }\n this.setState({START_NODE_ROW: row, START_NODE_COL: col});\n } else if (this.state.isFinishNode) {\n if (nodeClassName !== 'node node-wall') {\n const prevFinishNode = this.state.grid[this.state.currRow][\n this.state.currCol\n ];\n prevFinishNode.isFinish = false;\n document.getElementById(\n `node-${this.state.currRow}-${this.state.currCol}`,\n ).className = 'node';\n\n this.setState({currRow: row, currCol: col});\n const currFinishNode = this.state.grid[row][col];\n currFinishNode.isFinish = true;\n document.getElementById(`node-${row}-${col}`).className =\n 'node node-finish';\n }\n this.setState({FINISH_NODE_ROW: row, FINISH_NODE_COL: col});\n } else if (this.state.isWallNode) {\n const newGrid = getNewGridWithWallToggled(this.state.grid, row, col);\n this.setState({grid: newGrid});\n }\n }\n }\n }\n\n handleMouseUp(row, col) {\n if (!this.state.isRunning) {\n this.setState({mouseIsPressed: false});\n if (this.state.isStartNode) {\n const isStartNode = !this.state.isStartNode;\n this.setState({isStartNode, START_NODE_ROW: row, START_NODE_COL: col});\n } else if (this.state.isFinishNode) {\n const isFinishNode = !this.state.isFinishNode;\n this.setState({\n isFinishNode,\n FINISH_NODE_ROW: row,\n FINISH_NODE_COL: col,\n });\n }\n this.getInitialGrid();\n }\n }\n\n handleMouseLeave() {\n if (this.state.isStartNode) {\n const isStartNode = !this.state.isStartNode;\n this.setState({isStartNode, mouseIsPressed: false});\n } else if (this.state.isFinishNode) {\n const isFinishNode = !this.state.isFinishNode;\n this.setState({isFinishNode, mouseIsPressed: false});\n } else if (this.state.isWallNode) {\n const isWallNode = !this.state.isWallNode;\n this.setState({isWallNode, mouseIsPressed: false});\n this.getInitialGrid();\n }\n }\n\n /******************** Clear Board/Walls ********************/\n\n clearGrid() {\n if (!this.state.isRunning) {\n const newGrid = this.state.grid.slice();\n for (const row of newGrid) {\n for (const node of row) {\n let nodeClassName = document.getElementById(\n `node-${node.row}-${node.col}`,\n ).className;\n if (\n nodeClassName !== 'node node-start' &&\n nodeClassName !== 'node node-finish' &&\n nodeClassName !== 'node node-wall'\n ) {\n document.getElementById(`node-${node.row}-${node.col}`).className =\n 'node';\n node.isVisited = false;\n node.distance = Infinity;\n node.distanceToFinishNode =\n Math.abs(this.state.FINISH_NODE_ROW - node.row) +\n Math.abs(this.state.FINISH_NODE_COL - node.col);\n }\n if (nodeClassName === 'node node-finish') {\n node.isVisited = false;\n node.distance = Infinity;\n node.distanceToFinishNode = 0;\n }\n if (nodeClassName === 'node node-start') {\n node.isVisited = false;\n node.distance = Infinity;\n node.distanceToFinishNode =\n Math.abs(this.state.FINISH_NODE_ROW - node.row) +\n Math.abs(this.state.FINISH_NODE_COL - node.col);\n node.isStart = true;\n node.isWall = false;\n node.previousNode = null;\n node.isNode = true;\n }\n }\n }\n }\n }\n\n clearWalls() {\n if (!this.state.isRunning) {\n const newGrid = this.state.grid.slice();\n for (const row of newGrid) {\n for (const node of row) {\n let nodeClassName = document.getElementById(\n `node-${node.row}-${node.col}`,\n ).className;\n if (nodeClassName === 'node node-wall') {\n document.getElementById(`node-${node.row}-${node.col}`).className =\n 'node';\n node.isWall = false;\n }\n }\n }\n }\n }\n\n /******************** Create Animations ********************/\n visualize(algo) {\n if (!this.state.isRunning) {\n this.clearGrid();\n this.toggleIsRunning();\n const {grid} = this.state;\n const startNode =\n grid[this.state.START_NODE_ROW][this.state.START_NODE_COL];\n const finishNode =\n grid[this.state.FINISH_NODE_ROW][this.state.FINISH_NODE_COL];\n let visitedNodesInOrder;\n switch (algo) {\n case 'Dijkstra':\n visitedNodesInOrder = dijkstra(grid, startNode, finishNode);\n break;\n case 'AStar':\n visitedNodesInOrder = astar(grid, startNode, finishNode);\n break;\n case 'BFS':\n visitedNodesInOrder = bfs(grid, startNode, finishNode);\n break;\n case 'DFS':\n visitedNodesInOrder = dfs(grid, startNode, finishNode);\n break;\n default:\n // should never get here\n break;\n }\n const nodesInShortestPathOrder = getNodesInShortestPathOrder(finishNode);\n nodesInShortestPathOrder.push('end');\n this.animate(visitedNodesInOrder, nodesInShortestPathOrder);\n }\n }\n\n animate(visitedNodesInOrder, nodesInShortestPathOrder) {\n for (let i = 0; i <= visitedNodesInOrder.length; i++) {\n if (i === visitedNodesInOrder.length) {\n setTimeout(() => {\n this.animateShortestPath(nodesInShortestPathOrder);\n }, 10 * i);\n return;\n }\n setTimeout(() => {\n const node = visitedNodesInOrder[i];\n const nodeClassName = document.getElementById(\n `node-${node.row}-${node.col}`,\n ).className;\n if (\n nodeClassName !== 'node node-start' &&\n nodeClassName !== 'node node-finish'\n ) {\n document.getElementById(`node-${node.row}-${node.col}`).className =\n 'node node-visited';\n }\n }, 10 * i);\n }\n }\n\n /******************** Create path from start to finish ********************/\n animateShortestPath(nodesInShortestPathOrder) {\n for (let i = 0; i < nodesInShortestPathOrder.length; i++) {\n if (nodesInShortestPathOrder[i] === 'end') {\n setTimeout(() => {\n this.toggleIsRunning();\n }, i * 50);\n } else {\n setTimeout(() => {\n const node = nodesInShortestPathOrder[i];\n const nodeClassName = document.getElementById(\n `node-${node.row}-${node.col}`,\n ).className;\n if (\n nodeClassName !== 'node node-start' &&\n nodeClassName !== 'node node-finish'\n ) {\n document.getElementById(`node-${node.row}-${node.col}`).className =\n 'node node-shortest-path';\n }\n }, i * 40);\n }\n }\n }\n\n render() {\n const {grid, mouseIsPressed} = this.state;\n \n return (\n \n
\n \n \n \n Pathfinding Visualizer\n \n \n \n \n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n \n this.handleMouseLeave()}>\n \n {grid.map((row, rowIdx) => {\n return (\n \n {row.map((node, nodeIdx) => {\n const {row, col, isFinish, isStart, isWall} = node;\n return (\n \n this.handleMouseDown(row, col)\n }\n onMouseEnter={(row, col) =>\n this.handleMouseEnter(row, col)\n }\n onMouseUp={() => this.handleMouseUp(row, col)}\n row={row}>\n );\n })}\n
\n );\n })}\n \n
\n \n \n \n
\n );\n }\n}\n\n/******************** Create Walls ********************/\nconst getNewGridWithWallToggled = (grid, row, col) => {\n \n const newGrid = grid.slice();\n const node = newGrid[row][col];\n if (!node.isStart && !node.isFinish && node.isNode) {\n const newNode = {\n ...node,\n isWall: !node.isWall,\n };\n newGrid[row][col] = newNode;\n }\n return newGrid;\n};\n\nfunction getNodesInShortestPathOrder(finishNode) {\n const nodesInShortestPathOrder = [];\n let currentNode = finishNode;\n while (currentNode !== null) {\n nodesInShortestPathOrder.unshift(currentNode);\n currentNode = currentNode.previousNode;\n }\n return nodesInShortestPathOrder;\n}\n\nexport default Pathfinder;","import React from 'react'\nimport './App.css';\nimport Pathfinder from './components/Pathfinder';\n\nfunction App() {\n return (\n \n );\n}\n\nexport default App;\n","const reportWebVitals = onPerfEntry => {\n if (onPerfEntry && onPerfEntry instanceof Function) {\n import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {\n getCLS(onPerfEntry);\n getFID(onPerfEntry);\n getFCP(onPerfEntry);\n getLCP(onPerfEntry);\n getTTFB(onPerfEntry);\n });\n }\n};\n\nexport default reportWebVitals;\n","import React from 'react';\nimport ReactDOM from 'react-dom';\nimport './index.css';\nimport App from './App';\nimport reportWebVitals from './reportWebVitals';\n\nReactDOM.render(\n \n \n ,\n document.getElementById('root')\n);\n\n// If you want to start measuring performance in your app, pass a function\n// to log results (for example: reportWebVitals(console.log))\n// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals\nreportWebVitals();\n"],"sourceRoot":""}
\ No newline at end of file
+{"version":3,"sources":["components/algorithms/Astar.js","components/algorithms/BFS.js","components/algorithms/DFS.js","components/algorithms/Dijkstra.js","components/Node.js","components/Pathfinder.js","App.js","reportWebVitals.js","index.js"],"names":["sortByDistance","unvisitedNodes","sort","nodeA","nodeB","distance","updateUnvisitedNeighbors","node","grid","unvisitedNeighbors","neighbors","col","row","push","length","filter","neighbor","isVisited","getUnvisitedNeighbors","distanceToFinishNode","previousNode","Astar","startNode","finishNode","visitedNodesInOrder","nodes","getAllNodes","closestNode","shift","isWall","Infinity","console","log","BFS","endNode","nextNodesStack","currentNode","isStart","nextNode","DFS","pop","sortNodesByDistance","Dijkstra","Node","this","props","isFinish","onMouseDown","onMouseEnter","onMouseUp","extraClassName","id","className","Component","theme","createMuiTheme","typography","fontFamily","join","Pathfinder","getInitialGrid","rowCount","state","ROW_COUNT","colCount","COLUMN_COUNT","initialGrid","currentRow","createNode","START_NODE_ROW","START_NODE_COL","FINISH_NODE_ROW","FINISH_NODE_COL","Math","abs","isNode","width","window","innerWidth","height","innerHeight","parseInt","mouseIsPressed","MOBILE_ROW_COUNT","MOBILE_COLUMN_COUNT","isRunning","isStartNode","isFinishNode","isWallNode","currRow","currCol","isDesktopView","handleMouseDown","bind","handleMouseLeave","toggleIsRunning","updateDimensions","addEventListener","setState","removeEventListener","isGridClear","document","getElementById","newGrid","getNewGridWithWallToggled","clearGrid","nodeClassName","slice","algo","dijkstra","astar","bfs","dfs","nodesInShortestPathOrder","unshift","getNodesInShortestPathOrder","animate","i","setTimeout","animateShortestPath","AppBar","position","Box","my","ThemeProvider","Typography","variant","color","component","m","Button","type","onClick","clearWalls","visualize","onMouseLeave","map","rowIdx","nodeIdx","handleMouseEnter","handleMouseUp","newNode","App","reportWebVitals","onPerfEntry","Function","then","getCLS","getFID","getFCP","getLCP","getTTFB","ReactDOM","render","StrictMode"],"mappings":"8SAiCA,SAASA,EAAeC,GACtBA,EAAeC,MAAK,SAACC,EAAOC,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AAO,2BACRtI,GADQ,IAEXsB,QAAStB,EAAKsB,SAEhB0E,EAAQ3F,GAAKD,GAAOkI,EAEtB,OAAOtC,GAaM5C,QCxgBAmF,MARf,WACE,OACE,qBAAK1F,UAAU,MAAf,SACE,cAAC,EAAD,OCKS2F,EAZS,SAAAC,GAClBA,GAAeA,aAAuBC,UACxC,6BAAqBC,MAAK,YAAkD,IAA/CC,EAA8C,EAA9CA,OAAQC,EAAsC,EAAtCA,OAAQC,EAA8B,EAA9BA,OAAQC,EAAsB,EAAtBA,OAAQC,EAAc,EAAdA,QAC3DJ,EAAOH,GACPI,EAAOJ,GACPK,EAAOL,GACPM,EAAON,GACPO,EAAQP,OCDdQ,IAASC,OACP,cAAC,IAAMC,WAAP,UACE,cAAC,EAAD,MAEFrD,SAASC,eAAe,SAM1ByC,M","file":"static/js/main.31158c27.chunk.js","sourcesContent":["function Astar(grid, startNode, finishNode) {\n \n const visitedNodesInOrder = [];\n startNode.distance = 0;\n const unvisitedNodes = getAllNodes(grid);\n\n while (unvisitedNodes.length) {\n sortByDistance(unvisitedNodes);\n const closestNode = unvisitedNodes.shift();\n \n if (!closestNode.isWall) {\n \n if (closestNode.distance === Infinity) return visitedNodesInOrder;\n closestNode.isVisited = true;\n visitedNodesInOrder.push(closestNode);\n if (closestNode === finishNode) {\n console.log(\"Found!\");\n return visitedNodesInOrder;}\n updateUnvisitedNeighbors(closestNode, grid);\n }\n }\n}\n\nfunction getAllNodes(grid) {\n const nodes = [];\n for (const row of grid) {\n for (const node of row) {\n nodes.push(node);\n }\n }\n return nodes;\n}\n\nfunction sortByDistance(unvisitedNodes) {\n unvisitedNodes.sort((nodeA, nodeB) => nodeA.distance - nodeB.distance);\n}\n\nfunction updateUnvisitedNeighbors(node, grid) {\n const unvisitedNeighbors = getUnvisitedNeighbors(node, grid);\n for (const neighbor of unvisitedNeighbors) {\n neighbor.distance = node.distance + 1 + neighbor.distanceToFinishNode;\n neighbor.previousNode = node;\n }\n}\n\nfunction getUnvisitedNeighbors(node, grid) {\n const neighbors = [];\n const {col, row} = node;\n if (row > 0) neighbors.push(grid[row - 1][col]);\n if (row < grid.length - 1) neighbors.push(grid[row + 1][col]);\n if (col > 0) neighbors.push(grid[row][col - 1]);\n if (col < grid[0].length - 1) neighbors.push(grid[row][col + 1]);\n return neighbors.filter(neighbor => !neighbor.isVisited);\n}\n\nexport default Astar;","function BFS (grid, startNode, endNode){\n const visitedNodesInOrder = [];\n let nextNodesStack = [startNode];\n while (nextNodesStack.length) {\n const currentNode = nextNodesStack.shift();\n if (currentNode === endNode) {\n console.log(\"Found!\");\n return visitedNodesInOrder;\n }\n\n if (\n !currentNode.isWall &&\n (currentNode.isStart || !currentNode.isVisited)\n ) {\n currentNode.isVisited = true;\n visitedNodesInOrder.push(currentNode);\n const {col, row} = currentNode;\n let nextNode;\n if (row > 0) {\n nextNode = grid[row - 1][col];\n if (!nextNode.isVisited) {\n nextNode.previousNode = currentNode;\n nextNodesStack.push(nextNode);\n }\n }\n if (row < grid.length - 1) {\n nextNode = grid[row + 1][col];\n if (!nextNode.isVisited) {\n nextNode.previousNode = currentNode;\n nextNodesStack.push(nextNode);\n }\n }\n if (col > 0) {\n nextNode = grid[row][col - 1];\n if (!nextNode.isVisited) {\n nextNode.previousNode = currentNode;\n nextNodesStack.push(nextNode);\n }\n }\n if (col < grid[0].length - 1) {\n nextNode = grid[row][col + 1];\n if (!nextNode.isVisited) {\n nextNode.previousNode = currentNode;\n nextNodesStack.push(nextNode);\n }\n }\n }\n }\n}\n\nexport default BFS;","function DFS(grid, startNode, endNode) {\n const visitedNodesInOrder = [];\n const nextNodesStack = [];\n nextNodesStack.push(startNode);\n while (nextNodesStack.length) {\n const currentNode = nextNodesStack.pop();\n\n if (currentNode === endNode) {\n console.log(\"Found!\");\n return visitedNodesInOrder;\n }\n\n if (\n !currentNode.isWall &&\n (currentNode.isStart || !currentNode.isVisited)\n ) {\n currentNode.isVisited = true;\n visitedNodesInOrder.push(currentNode);\n\n const {col, row} = currentNode;\n let nextNode;\n if (row > 0) {\n nextNode = grid[row - 1][col];\n if (!nextNode.isVisited) {\n nextNode.previousNode = currentNode;\n nextNodesStack.push(nextNode);\n }\n }\n if (row < grid.length - 1) {\n nextNode = grid[row + 1][col];\n if (!nextNode.isVisited) {\n nextNode.previousNode = currentNode;\n nextNodesStack.push(nextNode);\n }\n }\n if (col > 0) {\n nextNode = grid[row][col - 1];\n if (!nextNode.isVisited) {\n nextNode.previousNode = currentNode;\n nextNodesStack.push(nextNode);\n }\n }\n if (col < grid[0].length - 1) {\n nextNode = grid[row][col + 1];\n if (!nextNode.isVisited) {\n nextNode.previousNode = currentNode;\n nextNodesStack.push(nextNode);\n }\n }\n }\n }\n}\n\nexport default DFS;","function Dijkstra(grid, startNode, endNode) {\n \n const visitedNodesInOrder = [];\n startNode.distance = 0;\n const unvisitedNodes = getAllNodes(grid); \n \n while (unvisitedNodes.length) {\n sortNodesByDistance(unvisitedNodes);\n const closestNode = unvisitedNodes.shift();\n \n if (!closestNode.isWall) {\n \n if (closestNode.distance === Infinity) return visitedNodesInOrder;\n closestNode.isVisited = true;\n visitedNodesInOrder.push(closestNode);\n if (closestNode === endNode){\n console.log(\"Found!\");\n return visitedNodesInOrder;\n } \n updateUnvisitedNeighbors(closestNode, grid);\n }\n }\n}\n\nfunction getAllNodes(grid) {\n const nodes = [];\n for (const row of grid) {\n for (const node of row) {\n nodes.push(node);\n }\n }\n return nodes;\n}\n\nfunction sortNodesByDistance(unvisitedNodes) {\n unvisitedNodes.sort((nodeA, nodeB) => nodeA.distance - nodeB.distance);\n}\n\nfunction updateUnvisitedNeighbors(node, grid) {\n const unvisitedNeighbors = getUnvisitedNeighbors(node, grid);\n for (const neighbor of unvisitedNeighbors) {\n neighbor.distance = node.distance + 1;\n neighbor.previousNode = node;\n }\n}\n\nfunction getUnvisitedNeighbors(node, grid) {\n const neighbors = [];\n const {col, row} = node;\n if (row > 0) neighbors.push(grid[row - 1][col]);\n if (row < grid.length - 1) neighbors.push(grid[row + 1][col]);\n if (col > 0) neighbors.push(grid[row][col - 1]);\n if (col < grid[0].length - 1) neighbors.push(grid[row][col + 1]);\n return neighbors.filter(neighbor => !neighbor.isVisited);\n}\n\nexport default Dijkstra;","import React, {Component} from 'react';\n\nimport './styles/Node.css';\n\nexport default class Node extends Component {\n render() {\n const {\n col,\n isFinish,\n isStart,\n isWall,\n onMouseDown,\n onMouseEnter,\n onMouseUp,\n row,\n } = this.props;\n \n const extraClassName = isFinish\n ? 'node-finish'\n : isStart\n ? 'node-start'\n : isWall\n ? 'node-wall'\n : '';\n\n return (\n onMouseDown(row, col)}\n onMouseEnter={() => onMouseEnter(row, col)}\n onMouseUp={() => onMouseUp()}> | \n );\n }\n}","import React, { Component, useState, useEffect } from 'react';\n\nimport astar from './algorithms/Astar';\nimport bfs from './algorithms/BFS';\nimport dfs from './algorithms/DFS';\nimport dijkstra from './algorithms/Dijkstra';\nimport Node from './Node';\n\nimport { AppBar, Button , Box, Typography, Container } from '@material-ui/core'\nimport { ThemeProvider, createMuiTheme } from '@material-ui/core/styles';\n\nimport './styles/Pathfinder.css';\n\nconst theme = createMuiTheme({\n typography: {\n fontFamily: [\n 'Maven Pro',\n 'sans-serif',\n ].join(','),\n },});\n\nclass Pathfinder extends Component {\n constructor() {\n super();\n this.state = {\n grid: [],\n width: window.innerWidth,\n height: window.innerHeight,\n START_NODE_ROW: parseInt(window.innerHeight/30*1/2),\n START_NODE_COL: parseInt(window.innerWidth/25*1/4),\n FINISH_NODE_ROW: parseInt(window.innerHeight/30*1/2),\n FINISH_NODE_COL: parseInt(window.innerWidth/25*3/4),\n mouseIsPressed: false,\n ROW_COUNT: parseInt(window.innerHeight/31),\n COLUMN_COUNT: parseInt(window.innerWidth/26),\n MOBILE_ROW_COUNT: 10,\n MOBILE_COLUMN_COUNT: 20,\n isRunning: false,\n isStartNode: false,\n isFinishNode: false,\n isWallNode: false, \n currRow: 0,\n currCol: 0,\n isDesktopView: true,\n };\n\n this.handleMouseDown = this.handleMouseDown.bind(this);\n this.handleMouseLeave = this.handleMouseLeave.bind(this);\n this.toggleIsRunning = this.toggleIsRunning.bind(this);\n console.log(\"screen size => \"+window.innerWidth + \"*\" + window.innerHeight); \n }\n\n componentDidMount() {\n this.updateDimensions();\n window.addEventListener(\"resize\", this.updateDimensions.bind(this));\n const grid = this.getInitialGrid();\n this.setState({grid});\n }\n \n componentWillUnmount() {\n window.removeEventListener(\"resize\", this.updateDimensions.bind(this));\n }\n\n toggleIsRunning() {\n this.setState({isRunning: !this.state.isRunning});\n }\n\n updateDimensions() {\n if(window.innerWidth != this.state.width || window.innerHeight != this.state.height) {\n this.setState({ \n ROW_COUNT: parseInt(window.innerHeight/31),\n COLUMN_COUNT: parseInt(window.innerWidth/26),\n START_NODE_ROW: parseInt(window.innerHeight/30*1/2),\n START_NODE_COL: parseInt(window.innerWidth/25*1/4),\n FINISH_NODE_ROW: parseInt(window.innerHeight/30*1/2),\n FINISH_NODE_COL: parseInt(window.innerWidth/25*3/4),\n });\n //console.log(\"screen resized => \"+ window.innerWidth + \"*\" + window.innerHeight);\n const grid = this.getInitialGrid();\n this.setState({grid});\n }\n }\n\n\n /******************** Set up the initial grid ********************/\n getInitialGrid = (\n rowCount = this.state.ROW_COUNT,\n colCount = this.state.COLUMN_COUNT,\n ) => {\n const initialGrid = [];\n for (let row = 0; row < rowCount; row++) {\n const currentRow = [];\n for (let col = 0; col < colCount; col++) {\n currentRow.push(this.createNode(row, col));\n }\n initialGrid.push(currentRow);\n }\n return initialGrid;\n };\n\n createNode = (row, col) => {\n return {\n row,\n col,\n isStart:\n row === this.state.START_NODE_ROW && col === this.state.START_NODE_COL,\n isFinish:\n row === this.state.FINISH_NODE_ROW &&\n col === this.state.FINISH_NODE_COL,\n distance: Infinity,\n distanceToFinishNode:\n Math.abs(this.state.FINISH_NODE_ROW - row) +\n Math.abs(this.state.FINISH_NODE_COL - col),\n isVisited: false,\n isWall: false,\n previousNode: null,\n isNode: true,\n };\n };\n\n /******************** Control mouse events ********************/\n handleMouseDown(row, col) {\n if (!this.state.isRunning) {\n if (this.isGridClear()) {\n if (\n document.getElementById(`node-${row}-${col}`).className ===\n 'node node-start'\n ) {\n this.setState({\n mouseIsPressed: true,\n isStartNode: true,\n currRow: row,\n currCol: col,\n });\n } else if (\n document.getElementById(`node-${row}-${col}`).className ===\n 'node node-finish'\n ) {\n this.setState({\n mouseIsPressed: true,\n isFinishNode: true,\n currRow: row,\n currCol: col,\n });\n } else {\n const newGrid = getNewGridWithWallToggled(this.state.grid, row, col);\n this.setState({\n grid: newGrid,\n mouseIsPressed: true,\n isWallNode: true,\n currRow: row,\n currCol: col,\n });\n }\n } else {\n this.clearGrid();\n }\n }\n }\n\n isGridClear() {\n for (const row of this.state.grid) {\n for (const node of row) {\n const nodeClassName = document.getElementById(\n `node-${node.row}-${node.col}`,\n ).className;\n if (\n nodeClassName === 'node node-visited' ||\n nodeClassName === 'node node-shortest-path'\n ) {\n return false;\n }\n }\n }\n return true;\n }\n\n handleMouseEnter(row, col) {\n if (!this.state.isRunning) {\n if (this.state.mouseIsPressed) {\n const nodeClassName = document.getElementById(`node-${row}-${col}`)\n .className;\n if (this.state.isStartNode) {\n if (nodeClassName !== 'node node-wall') {\n const prevStartNode = this.state.grid[this.state.currRow][\n this.state.currCol\n ];\n prevStartNode.isStart = false;\n document.getElementById(\n `node-${this.state.currRow}-${this.state.currCol}`,\n ).className = 'node';\n\n this.setState({currRow: row, currCol: col});\n const currStartNode = this.state.grid[row][col];\n currStartNode.isStart = true;\n document.getElementById(`node-${row}-${col}`).className =\n 'node node-start';\n }\n this.setState({START_NODE_ROW: row, START_NODE_COL: col});\n } else if (this.state.isFinishNode) {\n if (nodeClassName !== 'node node-wall') {\n const prevFinishNode = this.state.grid[this.state.currRow][\n this.state.currCol\n ];\n prevFinishNode.isFinish = false;\n document.getElementById(\n `node-${this.state.currRow}-${this.state.currCol}`,\n ).className = 'node';\n\n this.setState({currRow: row, currCol: col});\n const currFinishNode = this.state.grid[row][col];\n currFinishNode.isFinish = true;\n document.getElementById(`node-${row}-${col}`).className =\n 'node node-finish';\n }\n this.setState({FINISH_NODE_ROW: row, FINISH_NODE_COL: col});\n } else if (this.state.isWallNode) {\n const newGrid = getNewGridWithWallToggled(this.state.grid, row, col);\n this.setState({grid: newGrid});\n }\n }\n }\n }\n\n handleMouseUp(row, col) {\n if (!this.state.isRunning) {\n this.setState({mouseIsPressed: false});\n if (this.state.isStartNode) {\n const isStartNode = !this.state.isStartNode;\n this.setState({isStartNode, START_NODE_ROW: row, START_NODE_COL: col});\n } else if (this.state.isFinishNode) {\n const isFinishNode = !this.state.isFinishNode;\n this.setState({\n isFinishNode,\n FINISH_NODE_ROW: row,\n FINISH_NODE_COL: col,\n });\n }\n this.getInitialGrid();\n }\n }\n\n handleMouseLeave() {\n if (this.state.isStartNode) {\n const isStartNode = !this.state.isStartNode;\n this.setState({isStartNode, mouseIsPressed: false});\n } else if (this.state.isFinishNode) {\n const isFinishNode = !this.state.isFinishNode;\n this.setState({isFinishNode, mouseIsPressed: false});\n } else if (this.state.isWallNode) {\n const isWallNode = !this.state.isWallNode;\n this.setState({isWallNode, mouseIsPressed: false});\n this.getInitialGrid();\n }\n }\n\n /******************** Clear Board/Walls ********************/\n\n clearGrid() {\n if (!this.state.isRunning) {\n const newGrid = this.state.grid.slice();\n for (const row of newGrid) {\n for (const node of row) {\n let nodeClassName = document.getElementById(\n `node-${node.row}-${node.col}`,\n ).className;\n if (\n nodeClassName !== 'node node-start' &&\n nodeClassName !== 'node node-finish' &&\n nodeClassName !== 'node node-wall'\n ) {\n document.getElementById(`node-${node.row}-${node.col}`).className =\n 'node';\n node.isVisited = false;\n node.distance = Infinity;\n node.distanceToFinishNode =\n Math.abs(this.state.FINISH_NODE_ROW - node.row) +\n Math.abs(this.state.FINISH_NODE_COL - node.col);\n }\n if (nodeClassName === 'node node-finish') {\n node.isVisited = false;\n node.distance = Infinity;\n node.distanceToFinishNode = 0;\n }\n if (nodeClassName === 'node node-start') {\n node.isVisited = false;\n node.distance = Infinity;\n node.distanceToFinishNode =\n Math.abs(this.state.FINISH_NODE_ROW - node.row) +\n Math.abs(this.state.FINISH_NODE_COL - node.col);\n node.isStart = true;\n node.isWall = false;\n node.previousNode = null;\n node.isNode = true;\n }\n }\n }\n }\n }\n\n clearWalls() {\n if (!this.state.isRunning) {\n const newGrid = this.state.grid.slice();\n for (const row of newGrid) {\n for (const node of row) {\n let nodeClassName = document.getElementById(\n `node-${node.row}-${node.col}`,\n ).className;\n if (nodeClassName === 'node node-wall') {\n document.getElementById(`node-${node.row}-${node.col}`).className =\n 'node';\n node.isWall = false;\n }\n }\n }\n }\n }\n\n /******************** Create Animations ********************/\n visualize(algo) {\n if (!this.state.isRunning) {\n this.clearGrid();\n this.toggleIsRunning();\n const {grid} = this.state;\n const startNode =\n grid[this.state.START_NODE_ROW][this.state.START_NODE_COL];\n const finishNode =\n grid[this.state.FINISH_NODE_ROW][this.state.FINISH_NODE_COL];\n let visitedNodesInOrder;\n switch (algo) {\n case 'Dijkstra':\n visitedNodesInOrder = dijkstra(grid, startNode, finishNode);\n break;\n case 'AStar':\n visitedNodesInOrder = astar(grid, startNode, finishNode);\n break;\n case 'BFS':\n visitedNodesInOrder = bfs(grid, startNode, finishNode);\n break;\n case 'DFS':\n visitedNodesInOrder = dfs(grid, startNode, finishNode);\n break;\n default:\n // should never get here\n break;\n }\n const nodesInShortestPathOrder = getNodesInShortestPathOrder(finishNode);\n nodesInShortestPathOrder.push('end');\n this.animate(visitedNodesInOrder, nodesInShortestPathOrder);\n }\n }\n\n animate(visitedNodesInOrder, nodesInShortestPathOrder) {\n for (let i = 0; i <= visitedNodesInOrder.length; i++) {\n if (i === visitedNodesInOrder.length) {\n setTimeout(() => {\n this.animateShortestPath(nodesInShortestPathOrder);\n }, 10 * i);\n return;\n }\n setTimeout(() => {\n const node = visitedNodesInOrder[i];\n const nodeClassName = document.getElementById(\n `node-${node.row}-${node.col}`,\n ).className;\n if (\n nodeClassName !== 'node node-start' &&\n nodeClassName !== 'node node-finish'\n ) {\n document.getElementById(`node-${node.row}-${node.col}`).className =\n 'node node-visited';\n }\n }, 10 * i);\n }\n }\n\n /******************** Create path from start to finish ********************/\n animateShortestPath(nodesInShortestPathOrder) {\n for (let i = 0; i < nodesInShortestPathOrder.length; i++) {\n if (nodesInShortestPathOrder[i] === 'end') {\n setTimeout(() => {\n this.toggleIsRunning();\n }, i * 50);\n } else {\n setTimeout(() => {\n const node = nodesInShortestPathOrder[i];\n const nodeClassName = document.getElementById(\n `node-${node.row}-${node.col}`,\n ).className;\n if (\n nodeClassName !== 'node node-start' &&\n nodeClassName !== 'node node-finish'\n ) {\n document.getElementById(`node-${node.row}-${node.col}`).className =\n 'node node-shortest-path';\n }\n }, i * 40);\n }\n }\n }\n\n render() {\n const {grid, mouseIsPressed} = this.state;\n \n return (\n \n
\n \n \n \n Pathfinding Visualizer\n \n \n \n \n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n \n this.handleMouseLeave()}>\n \n {grid.map((row, rowIdx) => {\n return (\n \n {row.map((node, nodeIdx) => {\n const {row, col, isFinish, isStart, isWall} = node;\n return (\n \n this.handleMouseDown(row, col)\n }\n onMouseEnter={(row, col) =>\n this.handleMouseEnter(row, col)\n }\n onMouseUp={() => this.handleMouseUp(row, col)}\n row={row}>\n );\n })}\n
\n );\n })}\n \n
\n \n \n \n
\n );\n }\n}\n\n/******************** Create Walls ********************/\nconst getNewGridWithWallToggled = (grid, row, col) => {\n \n const newGrid = grid.slice();\n const node = newGrid[row][col];\n if (!node.isStart && !node.isFinish && node.isNode) {\n const newNode = {\n ...node,\n isWall: !node.isWall,\n };\n newGrid[row][col] = newNode;\n }\n return newGrid;\n};\n\nfunction getNodesInShortestPathOrder(finishNode) {\n const nodesInShortestPathOrder = [];\n let currentNode = finishNode;\n while (currentNode !== null) {\n nodesInShortestPathOrder.unshift(currentNode);\n currentNode = currentNode.previousNode;\n }\n return nodesInShortestPathOrder;\n}\n\nexport default Pathfinder;","import React from 'react'\nimport './App.css';\nimport Pathfinder from './components/Pathfinder';\n\nfunction App() {\n return (\n \n );\n}\n\nexport default App;\n","const reportWebVitals = onPerfEntry => {\n if (onPerfEntry && onPerfEntry instanceof Function) {\n import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {\n getCLS(onPerfEntry);\n getFID(onPerfEntry);\n getFCP(onPerfEntry);\n getLCP(onPerfEntry);\n getTTFB(onPerfEntry);\n });\n }\n};\n\nexport default reportWebVitals;\n","import React from 'react';\nimport ReactDOM from 'react-dom';\nimport './index.css';\nimport App from './App';\nimport reportWebVitals from './reportWebVitals';\n\nReactDOM.render(\n \n \n ,\n document.getElementById('root')\n);\n\n// If you want to start measuring performance in your app, pass a function\n// to log results (for example: reportWebVitals(console.log))\n// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals\nreportWebVitals();\n"],"sourceRoot":""}
\ No newline at end of file
diff --git a/static/js/runtime-main.7f58abe0.js b/static/js/runtime-main.7f58abe0.js
new file mode 100644
index 0000000..4ecdb8f
--- /dev/null
+++ b/static/js/runtime-main.7f58abe0.js
@@ -0,0 +1,2 @@
+!function(e){function r(r){for(var n,i,a=r[0],c=r[1],l=r[2],p=0,s=[];p