Skip to content

TarjMecwan/Pathfinding-Visualizer

Repository files navigation

Pathfinding Visualizer

This Pathfinding Visualizer was developed for Cal Poly SLO’s CSC 349: Design and Analysis of Algorithms course while I was a Teaching Assistant. I created it to help students better understand how algorithms like Dijkstra’s, A*, and Breadth-First Search (BFS) work in a more visual and interactive way. The tool lets users place obstacles, adjust speed, and watch the algorithms explore and find optimal paths in real time, making complex concepts easier to grasp through dynamic visualization.

Pathfinding Algorithms

  • Dijkstra's Algorithm - Guarantees shortest path, explores uniformly
  • A-star Algorithm - Optimal and efficient, uses heuristics
  • Greedy Best First Search - Fast but doesn't guarantee shortest path
  • Bidirectional Greedy Search - Searches from both start and goal
  • Breadth First Search - Explores layer by layer
  • Depth First Search - Explores deeply before backtracking
  • Random Walk - Random exploration (educational purposes)

Maze Generation

  • Random Maze - Randomly placed walls
  • Recursive Division Maze - Creates chambers with passages
  • Vertical Division Maze - Vertical walls with random gaps
  • Horizontal Division Maze - Horizontal walls with random gaps

How to Use

Controls

  • Right-Click: Set start position (first click), then goal position (second click), then clear both (third click)
  • Left-Click + Drag: Draw walls
  • Run Button: Start the visualization
  • Pause Button: Pause the visualization
  • Reset Button: Clear the grid completely
  • Generate Maze: Create a maze pattern
  • Speed Slider: Adjust animation speed (lower = faster)

Running the Application

Prerequisites

  • Java JDK 19 or higher installed

Option 1: Run from Source

# Clone the repository
git clone https://github.com/tarjmecwan/pathfinding-visualizer.git
cd pathfinding-visualizer

# Compile
javac -d bin -sourcepath src/main/java src/main/java/com/pathfinding/visualizer/app/App.java

# Run
java -cp bin com.pathfinding.visualizer.app.App

Option 2: Run JAR File (Coming Soon)

java -jar PathfindingVisualizer.jar

Algorithm Comparison

Algorithm Guarantees Shortest Path Speed Use Case
Dijkstra's Yes Medium Weighted graphs, guaranteed shortest
A* Yes Fast Best overall, uses heuristics
Greedy BFS No Very Fast Quick solutions, not optimal
BFS Yes (unweighted) Medium Unweighted graphs
DFS No Fast Exploring all paths
Bidirectional Yes Fast Large graphs

Technologies Used

  • Java 19
  • Swing (GUI)
  • MVC Architecture Pattern
  • Strategy Pattern (for algorithms)

Screenshot

Pathfinding Visualizer

About

☕🧭 Java Pathfinding Visualizer | Dijkstra’s, A*, BFS

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages