An interactive visualiser which demonstrates the pro's and con's of various graph solving algorithms.
About The Project | Features | Getting Started | How To Use | The Algorithms | Contact The Team | License
It is deployed via Netlify here:
The Algo-Visualiser is a web app built in ReactJS that shows how various graph traversal algorithm work. It was built by Bassel Al-Sayed and Tom Walker out of a mutual wish to understand ReactJS and GPS systems and these algorithms together.
- Users can select a maze size (which will scale with their screen/phone size).
- Users can select a start and end point for the maze.
- Then add fences (obstructions for the algorithm).
- Then one of the 5 available algorithms is chosen.
- The algorithm is then run with the nodes searched coloured in.
- And then shortest path (found by the selected algorithm) drawn in a new colour.
- The grid can then be reset (keeping the fences and start/end nodes) to allow comparison of algorithms.
- Users can view benchmarking statistics for each run of an algorithm to compare against other algorithms using the same grid.
-
Clone the repo by running
git clone https://github.com/Walker-TW/Algorithm-Visualizer.git
-
Change into the cloned directory
cd Algorithm-Visualizer
-
Install dependencies
yarn
-
Booting the server:
- For hot reload during development (or quick start):
- Boot the server with
yarn start
- Navigate to http://localhost:3000 in your browser.
- The rendered page will update as you make changes
- You will also see any lint errors in the console.
- To view the optimised build
- run
yarn build
, then - Boot with
serve -s build
.- You can install serve globally with
yarn global add serve
ornpm i -g serve
, it's handy to have around.
- You can install serve globally with
yarn test
Launches the test runner (react-scripts jest with enzyme) in the interactive watch mode.
At time of writing, jest can be buggy with coverage in watch mode so for accurate coverage run yarn test:coverage
The algorithms demonstrated within the project are all graph traversal algorithms.
An algorithm that is weighted and will always find the shortest path. Works by spreading out and determining the shortest 'distance' to the final node by adding up the traversed weights.
An upgraded version of Dijkstra that takes the distance value of each node and combines it with a heuristic value to determine not just the distance to the finish node but the direction that it should take. Two types of heuristics are used in our project the Manhattan distance & the Euclidean distance. It will always find the shortest path when using the correct heuristic.
AKA 'as the crow flies' is a heuristic used in most straight line mazes. It uses the Pythagorean theorem on a triangle created from the two points that you wish to get to Point A (start point) & Point B (destination).
sqrt((x2-x1)^2 + (y2-y1)^2)
However because our grid is only traversable on horizontal or vertical vertices using this heurtistic will NOT always give the shortest path, though it will be much faster than other heuristics.
AKA the taxi-cab distance will only work on a grid system unlike the euclidean, this heuristic is calculated by taking the absolute values of subtracting the x & y values of two points on our triangle and then adding the result together. This allows a better relative distance.
|(x2-x1)| + |(y2-y1)|
Because Manhattan moves only in horizontal or vertical verticies it will always find the shortest path. However it will be much slower than Euclidean so if speed is an issue (especially in huge graphs) while accurancy is not choose Euclidean.
Is a graph traversal algorithm which will search all neighbour nodes (in this projects case north/east/west/south) of the main node before moving onto the next level. This will cause a spreading out effect and means that along a maze BRS will explore all diversions that it comes across. It will find the shortest path.
The brother of Breadth First Search it will not explore all neighbour nodes instead exploring all along a branch before backtracking to other non-visited nodes. Depth first search is the only algorithm listed which will NOT find the shortest path.
Distributed under the MIT License. See LICENSE
for more information.
This project was inspired by a video from Clément Mihailescu please visit his youtube channel here