A modern web application that allows users to create, visualize, and find paths in custom graphs. This project combines a React frontend with a Flask backend and C++ pathfinding algorithm to provide an interactive graph visualization experience.
- Interactive Graph Creation: Create custom graphs by specifying the number of nodes and edges
- Visual Graph Representation: Beautiful SVG-based graph visualization with animated nodes and edges
- Pathfinding Algorithm: Find all possible paths between any two nodes using DFS (Depth-First Search)
- Real-time Visualization: See the selected path highlighted with animations and visual effects
- User-friendly Interface: Intuitive UI with step-by-step graph creation process
- Responsive Design: Modern, clean interface with smooth animations
- React 19 - Modern React with hooks for state management
- Vite - Fast build tool and development server
- Axios - HTTP client for API communication
- CSS3 - Custom styling with animations and visual effects
- SVG - Scalable vector graphics for graph visualization
- Flask - Python web framework for API endpoints
- Flask-CORS - Cross-origin resource sharing support
- C++ - High-performance pathfinding algorithm implementation
- ESLint - Code linting and formatting
- Vite - Development server and build tool
graph-pathfinding-visualizer/
βββ backend/
β βββ app.py # Flask API server
β βββ pathfinder.cpp # C++ pathfinding algorithm
β βββ requirements.txt # Python dependencies
β βββ render.yaml # Deployment configuration
βββ frontend/
β βββ src/
β β βββ components/
β β β βββ GraphVisualizer.jsx # Graph visualization component
β β β βββ GraphInputForm.jsx # Graph input form component
β β βββ api/
β β β βββ api.js # API communication utilities
β β βββ styles/
β β β βββ styles.css # Custom CSS styles
β β βββ App.jsx # Main application component
β β βββ main.jsx # Application entry point
β βββ public/
β βββ package.json # Frontend dependencies
β βββ vite.config.js # Vite configuration
βββ README.md # Project documentation
- Node.js (v16 or higher)
- Python 3.8 or higher
- C++ compiler (g++ or clang++)
- Navigate to the backend directory:
cd backend- Create a virtual environment (optional but recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install Python dependencies:
pip install -r requirements.txt- Compile the C++ pathfinding algorithm:
g++ -o pathfinder pathfinder.cpp- Start the Flask server:
python app.pyThe backend will be running on http://localhost:5000
- Navigate to the frontend directory:
cd frontend- Install dependencies:
npm install- Start the development server:
npm run devThe frontend will be running on http://localhost:5173
- Set Graph Parameters: Enter the number of nodes and edges for your graph
- Add Edges: Connect nodes by specifying source and destination node IDs
- Visualize: The graph will be displayed in a circular layout with numbered nodes
- Select Source Node: Click on the node you want to start from
- Select Destination Node: Click on the node you want to reach
- Find Path: Click "Find Path" to discover all possible routes
- View Results: The shortest path will be highlighted with animations
- Node Selection: Click nodes to select source and destination
- Path Visualization: Selected paths are highlighted with green edges and animations
- Real-time Updates: Graph updates immediately when adding edges or finding paths
- Error Handling: Clear error messages for invalid inputs or connection issues
Finds all possible paths between two nodes in the graph.
Request Body:
{
"source": "0",
"target": "3",
"edges": [
["0", "1"],
["1", "2"],
["2", "3"]
]
}Response:
{
"paths": [["0", "1", "2", "3"]]
}- Animated Nodes: Smooth transitions and hover effects
- Path Highlighting: Selected paths are highlighted with green color and animations
- Node States: Different colors for source (green), destination (red), and path nodes (blue)
- Interactive Elements: Clickable nodes with visual feedback
- Responsive Design: Works on different screen sizes
The backend can be deployed to platforms like Render, Heroku, or any Python hosting service. The render.yaml file provides configuration for Render deployment.
The frontend can be built and deployed to static hosting services:
cd frontend
npm run buildThe built files will be in the dist directory.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is open source and available under the MIT License.
- Backend Connection Error: Ensure the Flask server is running on port 5000
- C++ Compilation Error: Make sure you have a C++ compiler installed
- Node Modules Error: Run
npm installin the frontend directory - Port Conflicts: Check if ports 5000 (backend) and 5173 (frontend) are available
- Use browser developer tools to debug frontend issues
- Check Flask server logs for backend debugging
- Ensure CORS is properly configured for local development
- Test the C++ algorithm independently if pathfinding issues occur
Happy Pathfinding! πΊοΈ