Skip to content

mukulbhatia799/Graph-Visualizer-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Graph Pathfinding Visualizer

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.

πŸš€ Features

  • 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

πŸ› οΈ Tech Stack

Frontend

  • 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

Backend

  • Flask - Python web framework for API endpoints
  • Flask-CORS - Cross-origin resource sharing support
  • C++ - High-performance pathfinding algorithm implementation

Development Tools

  • ESLint - Code linting and formatting
  • Vite - Development server and build tool

πŸ“ Project Structure

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

πŸš€ Installation & Setup

Prerequisites

  • Node.js (v16 or higher)
  • Python 3.8 or higher
  • C++ compiler (g++ or clang++)

Backend Setup

  1. Navigate to the backend directory:
cd backend
  1. Create a virtual environment (optional but recommended):
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install Python dependencies:
pip install -r requirements.txt
  1. Compile the C++ pathfinding algorithm:
g++ -o pathfinder pathfinder.cpp
  1. Start the Flask server:
python app.py

The backend will be running on http://localhost:5000

Frontend Setup

  1. Navigate to the frontend directory:
cd frontend
  1. Install dependencies:
npm install
  1. Start the development server:
npm run dev

The frontend will be running on http://localhost:5173

🎯 Usage Guide

Creating a Graph

  1. Set Graph Parameters: Enter the number of nodes and edges for your graph
  2. Add Edges: Connect nodes by specifying source and destination node IDs
  3. Visualize: The graph will be displayed in a circular layout with numbered nodes

Finding Paths

  1. Select Source Node: Click on the node you want to start from
  2. Select Destination Node: Click on the node you want to reach
  3. Find Path: Click "Find Path" to discover all possible routes
  4. View Results: The shortest path will be highlighted with animations

Features in Action

  • 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

πŸ”§ API Endpoints

POST /pathfind

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"]]
}

🎨 Visual Features

  • 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

πŸš€ Deployment

Backend Deployment

The backend can be deployed to platforms like Render, Heroku, or any Python hosting service. The render.yaml file provides configuration for Render deployment.

Frontend Deployment

The frontend can be built and deployed to static hosting services:

cd frontend
npm run build

The built files will be in the dist directory.

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

This project is open source and available under the MIT License.

πŸ› Troubleshooting

Common Issues

  1. Backend Connection Error: Ensure the Flask server is running on port 5000
  2. C++ Compilation Error: Make sure you have a C++ compiler installed
  3. Node Modules Error: Run npm install in the frontend directory
  4. Port Conflicts: Check if ports 5000 (backend) and 5173 (frontend) are available

Development Tips

  • 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! πŸ—ΊοΈ

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors