Motivation: I noticed I've been struggling a little bit with DSA, so I decided to make a whole project around it. I figured if I could successfully code a pathfinding visualizer, I surely would understand Djikstras algorithm, BFS and A*. Hopefully this helps others too.
- Algorithms: BFS (unweighted shortest path), Dijkstra (weighted), A*(heuristic-guided).
- Heuristics: Manhattan, Euclidean, Chebyshev/Diagonal.
- Data structures: adjacency via grid neighbors, binary heap priority queue (using
heapq
), parent maps. - Visualization:
- CLI: step-by-step ASCII animation.
- Pygame (optional): pretty grid with live expansion coloring.
- Benchmarks: compare runtime and explored nodes across algorithms on random mazes.
- Tests: correctness checks with
pytest
.
#Use a venv
python -m venv .venv && source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install library in editable mode
pip install -e ".[dev]" # for tests
pip install -e ".[viz]" # for pygame visualizer
pip install -e ".[plots]" # to generate benchmark plots (optional)
# Run the CLI visualizer
python -m pathviz.visualize_cli --algo astar --rows 25 --cols 45 --density 0.28 --speed 0.01
# Other algos: bfs, dijkstra
python -m pathviz.visualize_pygame --algo astar --rows 30 --cols 50 --density 0.30
python -m pathviz.benchmarks --rows 35 --cols 60 --trials 5 --density 0.3 --seed 1337 --plot out.png
pytest -q
pathfinding-visualizer/
src/pathviz/
__init__.py
grid.py
heuristics.py
algorithms.py
visualize_cli.py
visualize_pygame.py
benchmarks.py
tests/
test_algorithms.py
examples/
run_cli.py
run_pygame.py
docs/
architecture.md
pyproject.toml
README.md
LICENSE