An interactive website to visualize popular pathfinding algorithms in real time. Analyse how BFS, DFS, Dijkstra's, and A* algorithms explore a grid to find the shortest path between two points.
- 4 Classic Algorithms: BFS, DFS, Dijkstra's, and A* Search
- Real-time Visualization: Watch algorithms explore the grid step-by-step
- Interactive Grid: Click to set start/end points, drag to draw barriers
- Adjustable Speed: Control visualization speed from slow to instant
- Multiple Grid Sizes: Choose from 20×20 up to 35×35 grids
- Random Maze Generation: Generate random obstacles for testing
- Performance Metrics: Track nodes visited, path length, and execution time
- Responsive Design: Works on desktop, tablet, and mobile devices
| Technology | Purpose |
|---|---|
| HTML5 | Structure and semantic markup |
| CSS3 | Styling, animations, and responsive design |
| JavaScript (ES6+) | Algorithm implementation and DOM manipulation |
pathfinding-visualizer/
│
├── index.html # Main HTML structure
├── style.css # All styling and animations
├── script.js # Algorithm implementations and app logic
└── README.md # Project documentation (this file)
-
Clone the repository
git clone https://github.com/swechchhapatel/pathfinding-visualizer.git cd pathfinding-visualizer -
Open in browser
- Simply double-click
index.html - Or right-click → "Open with" → Choose your browser
- Simply double-click
-
Start visualizing!
-
Install Live Server (VS Code extension or npm package)
npm install -g live-server
-
Navigate to project folder
cd pathfinding-visualizer -
Start the server
live-server
-
Open in browser
- Automatically opens at
http://localhost:8080 - Auto-refreshes on file changes
- Automatically opens at
- Explores nodes level by level
- Guarantees shortest path in unweighted graphs
- Uses a queue data structure
- Time Complexity: O(V + E)
- Explores as far as possible along each branch
- Does NOT guarantee shortest path
- Uses a stack data structure
- Time Complexity: O(V + E)
- Always picks the node with smallest distance
- Guarantees shortest path (works with weighted graphs)
- Uses a priority queue approach
- Time Complexity: O(V²) or O(E log V) with heap
- Uses heuristic (Manhattan distance) to guide search
- Guarantees shortest path with admissible heuristic
- More efficient than Dijkstra for goal-directed search
- Time Complexity: O(E) in best case, O(V²) in worst case
| Algorithm | Shortest Path | Speed | Memory | Use Case |
|---|---|---|---|---|
| BFS | Yes | Medium | High | Unweighted graphs |
| DFS | No | Fast | Low | Graph traversal, not pathfinding |
| Dijkstra | Yes | Slow | Medium | Weighted graphs, no heuristic |
| A* | Yes | Fast | Medium | Goal-directed search, best overall |
- Add more algorithms
- Implement weighted graphs (different terrain costs)
- Add algorithm complexity visualization
- Implement step-by-step mode (pause/play)
Contributions are welcome and appreciated!
If you'd like to improve this project, please follow these steps:
- Fork the repository
- Create a new branch
git checkout -b feature/your-feature-name
- Make changes and commit
git commit -m "Add: your message" - Push to your branch and open a Pull Request
Made with ❤️

