A modern, interactive web application for visualizing Dijkstra's shortest path algorithm with real-time graph manipulation and pathfinding visualization.
This project provides an interactive platform for learning and visualizing Dijkstra's shortest path algorithm. Users can create custom graphs by adding nodes and weighted edges, then watch as the algorithm finds the optimal paths between any two nodes.
Perfect for: Computer Science students, algorithm enthusiasts, and educators teaching graph theory.
- Dynamic node creations
- Edge creation between nodes
- Custom weight assignment for each edge
- Step-by-step Dijkstra algorithm execution
- Visual highlighting of shortest paths
- Real-time distance calculations
- Priority queue implementation with optimal complexity
- Responsive design with Tailwind CSS
- Professional glassmorphism interface
- Interactive graph canvas with zoom/pan
- Live statistics and connection tracking
- RESTful API backend with Express.js
- Optimized algorithm implementation (O(V + E log V))
- Error handling and input validation
- Clean component architecture
{
"framework": "React 19.1.1",
"styling": "Tailwind CSS 4.1.13",
"visualization": "@xyflow/react",
"build-tool": "Vite",
"http-client": "Axios"
}
{
"runtime": "Node.js",
"framework": "Express.js 5.1.0",
"cors": "CORS enabled",
"algorithm": "Priority Queue Dijkstra"
}
- Node.js (v16.0.0 or higher)
- npm (v8.0.0 or higher) or yarn
- Modern web browser with ES6+ support
git clone https://github.com/yourusername/dijkstra-algorithm-visualizer.git
cd dijkstra-algorithm-visualizer
cd server
npm install
npm run dev
Server runs on http://localhost:5000
cd ../client
npm install
npm run dev
Client runs on http://localhost:5173
Open your browser and navigate to http://localhost:5173
dijkstra-algorithm-visualizer/
βββ π client/ # React Frontend
β βββ π public/ # Static assets
β βββ π src/
β β βββ π App.jsx # Main application component
β β βββ π App.css # Global styles
β β βββ π main.jsx # React entry point
β β βββ π index.css # Tailwind imports
β βββ π package.json # Frontend dependencies
β βββ π vite.config.js # Vite configuration
β βββ π tailwind.config.js # Tailwind configuration
βββ π server/ # Node.js Backend
β βββ π src/
β β βββ π server.js # Express server & Dijkstra logic
β βββ π package.json # Backend dependencies
βββ π README.md # Project documentation
Calculates shortest paths using Dijkstra's algorithm.
Request Body:
{
"nodes": ["1", "2", "3", "4"],
"edges": [
{ "from": "1", "to": "2", "weight": 4 },
{ "from": "1", "to": "3", "weight": 2 },
{ "from": "2", "to": "4", "weight": 1 },
{ "from": "3", "to": "4", "weight": 5 }
]
}
Response:
{
"distances": { "1": 0, "2": 8, "3": 5 },
"prev": { "1": null, "2": 3, "3": 1 },
"allPaths": [
{ "from": 1, "to": 1, "path": "[Array]" },
{ "from": 1, "to": 2, "path": "[Array]" },
{ "from": 1, "to": 3, "path": "[Array]" }
]
}
Client:
npm run dev # Start development server
npm run build # Build for production
npm run preview # Preview production build
Server:
npm run dev # Start with nodemon
npm start # Start production server
- ES6+ JavaScript with modern React patterns
- Functional components with React Hooks
- RESTful API design principles
- Responsive-first CSS with Tailwind
- Time Complexity: O((V + E) log V) using priority queue
- Space Complexity: O(V) for distance and prev tracking
- Data Structure: Min-heap priority queue for optimal performance
- Priority queue implementation for efficient node selection
- Comprehensive path reconstruction
- Distance tracking with infinity initialization
This project is licensed under the MIT License - see the LICENSE file for details.
Adarsh Chary
- GitHub: @M-ADARSHCHARY
- LinkedIn: Connect with me
If this project helped you learn or build something awesome, please consider giving it a star! β
Made with β€οΈ for the algorithms community