Skip to content

An interactive teaching and visualization tool for pathfinding algorithms in both Grid and Graph modes, built with React + Vite + Zustand.

Notifications You must be signed in to change notification settings

krishnactive/PathFinder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 

Repository files navigation

PathFinder Visualizer

An interactive teaching and visualization tool for pathfinding algorithms in both Grid and Graph modes, built with React + Vite + Zustand.


πŸš€ Features Implemented

βœ… Core Algorithms

  • BFS (Breadth-First Search, unweighted shortest path)
  • DFS (Depth-First Search, unweighted traversal)
  • Dijkstra (weighted shortest path)
  • A* (weighted shortest path with heuristic)

βœ… Grid Mode

  • Interactive grid (place/remove walls, adjust weights)
  • Weighted cells:
    • Cycle between common weights (1, 5, 10)
    • Double-click to manually set custom weights
  • Random obstacle generation & recursive maze generation
  • Start/End fixed, visual step-by-step exploration
  • Auto-fit grid + zoom controls
  • Adjustable grid size with auto-scaling cells

βœ… Graph Mode

  • Switch between Grid and Graph
  • Add/move nodes (double-click background to add, drag to move)
  • Connect nodes with edges (click-to-connect, edit weights by clicking label)
  • Weighted edges for Dijkstra & A*
  • Start/End nodes selectable
  • Algorithms run directly on graph structures

βœ… Teaching Tools

  • Logs terminal: step-by-step algorithm messages
  • Pseudocode terminal: C++-style pseudocode highlighting per step
  • Frontier/Queue/Stack panel: live view of BFS queue, DFS stack, or priority queue (Dijkstra/A*)
  • Tooltips: hover cells/nodes to inspect g, h, f, distance, parent
  • Playback controls: Play, Pause, Step Forward, Step Backward, Jump to Start/End
  • Progress bar with scrubbing & Fast Solve option

βœ… UI/UX Enhancements

  • Dark mode toggle with persistence (localStorage)
  • Keyboard shortcuts:
    • Space β†’ Play/Pause
    • ← / β†’ β†’ Step Backward/Forward
    • R β†’ Reset
  • Resizable panels (logs, pseudocode, frontier)
  • Zoom modes: Fit (auto-fit screen) and Fixed (manual scaling)

πŸ“‚ Project Structure

src/
β”œβ”€β”€ algorithms/          # Algorithm implementations
β”‚   β”œβ”€β”€ bfs.js           # BFS (Grid)
β”‚   β”œβ”€β”€ dfs.js           # DFS (Grid)
β”‚   β”œβ”€β”€ dijkstra.js      # Dijkstra (Grid)
β”‚   β”œβ”€β”€ astar.js         # A* (Grid)
β”‚   └── graph/           # Graph-mode algorithms
β”‚       β”œβ”€β”€ bfs.js
β”‚       β”œβ”€β”€ dfs.js
β”‚       β”œβ”€β”€ dijkstra.js
β”‚       └── astar.js
β”‚
β”œβ”€β”€ components/          # UI components
β”‚   β”œβ”€β”€ ControlsPanel.jsx     # Header controls (algorithm, mode, theme, playback, size)
β”‚   β”œβ”€β”€ Layout.jsx            # Main layout (grid/graph, side panels, logs)
β”‚   β”œβ”€β”€ GridVisualizer/       # Grid mode components
β”‚   β”‚   └── Grid.jsx
β”‚   β”œβ”€β”€ Graph/                # Graph mode components
β”‚   β”‚   └── GraphCanvas.jsx
β”‚   β”œβ”€β”€ PseudocodeTerminal.jsx # Shows pseudocode with highlighted line per step
β”‚   β”œβ”€β”€ TeachingLogs.jsx       # Scrollable log terminal (step-by-step actions)
β”‚   └── FrontierPanel.jsx      # Queue/Stack/PQ live visualization
β”‚
β”œβ”€β”€ store/
β”‚   └── visualizerStore.js     # Zustand store (all app state + playback engine)
β”‚
β”œβ”€β”€ utils/
β”‚   └── mazeGenerators.js      # Random + recursive maze generation
β”‚
β”œβ”€β”€ index.css                  # TailwindCSS + custom styles
└── main.jsx                   # Entry point, wraps Layout

πŸ“ File Notes

  • visualizerStore.js β†’ the heart of the app; manages state for Grid & Graph, playback steps, logs, pseudocode line, frontier snapshots, and theme.
  • Algorithm files β†’ each returns { visitedOrder, shortestPath, logs, meta, frontiers } so visualization panels can sync.
  • ControlsPanel.jsx β†’ dropdowns, buttons, speed sliders, zoom control, fast solve toggle, etc.
  • Layout.jsx β†’ flex layout with resizable panels; integrates keyboard shortcuts and theme application.
  • PseudocodeTerminal.jsx β†’ C++-style pseudocode, highlights lines based on logs.
  • TeachingLogs.jsx β†’ VSCode-like terminal showing algorithm messages.
  • FrontierPanel.jsx β†’ new addition! shows contents of BFS queue / DFS stack / Dijkstra-A* priority queue live.
  • GraphCanvas.jsx β†’ interactive SVG-based graph editor (nodes, edges, weights).
  • mazeGenerators.js β†’ provides randomized mazes for teaching Grid mode.

πŸ“Œ Upcoming Features

  • Right-click context menu for nodes/edges (Set Start/End, Edit Weight, Delete)
  • Directed edges toggle
  • Graph save/load slots (localStorage + JSON import/export)
  • A* heuristic selection (Manhattan/Euclidean/Zero)
  • Classroom presets for teaching

πŸ› οΈ Tech Stack

  • React + Vite
  • Zustand (state management)
  • TailwindCSS (styling)

πŸ“‚ Project Setup

# install dependencies
npm install

# run locally
npm run dev

# build for production
npm run build

πŸ‘¨β€πŸ« Author Notes

This project is designed as a teaching-first visualization tool.
It balances interactivity (edit grids/graphs live) with instructional clarity (pseudocode, logs, frontier visualization).
Perfect for classroom demos, self-study, or interview prep.


About

An interactive teaching and visualization tool for pathfinding algorithms in both Grid and Graph modes, built with React + Vite + Zustand.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages