Skip to content

chirana07/aisearch-v2

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

35 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– AI Search Algorithm Visualizer

An interactive web-based visualizer for classic AI search algorithms built with Brython (Python in the browser).

License: MIT Live Demo

✨ Features

8 Search Algorithms Implemented

Uninformed Search:

  • πŸ”΅ Breadth-First Search (BFS)
  • πŸ”΄ Depth-First Search (DFS)
  • 🟑 Depth-Limited Search (DLS)
  • 🟒 Iterative Deepening Search (IDS)
  • 🟣 Uniform Cost Search (UCS)
  • πŸ”Ά Bidirectional Search

Informed Search:

  • 🟠 Greedy Best-First Search
  • ⭐ A* Search

Interactive Visualization

  • Step-by-step animation with play/pause controls
  • Forward/backward stepping through algorithm execution
  • Adjustable animation speed (1x to 10x)
  • Real-time data display showing Fringe, Visited, and Path
  • Color-coded node states for easy tracking
  • Responsive canvas with zoom, pan, and grid

Graph Building Tools

  • βž• Add/Delete Nodes
  • πŸ”— Add/Delete Edges
  • βœ‹ Drag to move nodes
  • 🎯 Set source and goal nodes
  • πŸ”’ Edit heuristic values
  • βš–οΈ Edit edge weights
  • πŸ”„ Undo/Redo support

Export Capabilities

  • πŸ“· PNG: Export static graph images
  • 🎬 GIF: Record animated algorithm execution
  • πŸ“„ PDF: Generate comprehensive reports
  • 🎨 SVG: Vector graphics for publications
  • πŸ’Ύ JSON: Save/load graph structures
  • πŸ“Š CSV: Export performance metrics

Two Deployment Options

  1. Standalone Version (GitHub Pages)

    • No installation required
    • Works entirely in the browser
    • Uses Brython (Python in browser)
    • Perfect for quick demonstrations
  2. Next.js Application (Full-featured)

    • User authentication (email/password, OAuth)
    • Save and manage multiple graphs
    • Version history
    • Sharing capabilities
    • Advanced analytics

πŸš€ Quick Start

Standalone Version (GitHub Pages)

  1. Clone the repository:

    git clone https://github.com/ashfaknawshad/aisearch-v2.git
    cd aisearch-v2
  2. Open in browser: Simply open index.html in your web browser, or:

    # Using Python's built-in server
    python -m http.server 8000

    Then navigate to http://localhost:8000

  3. Deploy to GitHub Pages:

    • Push to GitHub
    • Go to repository Settings β†’ Pages
    • Select main branch as source
    • Your site will be live at https://yourusername.github.io/aisearch-v2/

πŸ“– Usage

Building a Graph

  1. Add Nodes: Click "Add Node" tool and click on canvas
  2. Connect Nodes: Click "Add Edge" tool, click two nodes to connect
  3. Set Source: The first node is automatically the source (red)
  4. Set Goal: Click "Set Goal" tool and click a node (green)
  5. Add Heuristics: For A*/Greedy, click "Edit Heuristic" and click a node
  6. Add Weights: For UCS/A*, click "Edit Weight" and click an edge

Running Algorithms

  1. Select Algorithm: Choose from the dropdown menu
  2. Start Search: Click "▢️ Start Search" to begin animation
  3. Control Playback: Use Pause, Step Forward/Back buttons
  4. Adjust Speed: Use the slider to control animation speed
  5. View Results: Check the right panel for statistics and path found

Keyboard Shortcuts

Key Action
A Add Node tool
E Add Edge tool
M Move Node tool
D Delete Node tool
G Set Goal tool
H Edit Heuristic tool
Space Start/Pause search
←/β†’ Step Backward/Forward
Ctrl+Z Undo
Ctrl+Y Redo
Ctrl+S Save Graph
R Reset View
L Toggle Labels

πŸ“š Documentation

πŸ—οΈ Project Structure

ai-search-v2/
β”œβ”€β”€ index.html              # Standalone visualizer entry point
β”œβ”€β”€ main.py                 # Brython visualization logic
β”œβ”€β”€ SearchAgent.py          # Algorithm implementations
β”œβ”€β”€ Node.py                 # Node data structure
β”œβ”€β”€ PriorityQueue.py        # Priority queue & data structures
β”œβ”€β”€ styles.css              # Styling with dark mode
β”œβ”€β”€ README.md               # This file
β”œβ”€β”€ LICENSE                 # MIT License
β”œβ”€β”€ .gitignore             # Git ignore rules
β”œβ”€β”€ docs/                   # Documentation
β”‚   β”œβ”€β”€ algorithm-guide.md
β”‚   β”œβ”€β”€ api-reference.md
β”‚   └── deployment-guide.md
└── nextjs-app/            # Next.js application
    β”œβ”€β”€ package.json
    β”œβ”€β”€ next.config.js
    β”œβ”€β”€ tsconfig.json
    β”œβ”€β”€ prisma/
    β”‚   └── schema.prisma
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ app/
    β”‚   β”œβ”€β”€ components/
    β”‚   └── lib/
    └── public/

🎯 Algorithm Comparison

Algorithm Complete Optimal Time Complexity Space Complexity
BFS βœ… Yes βœ… Yes* O(V + E) O(V)
DFS ❌ No ❌ No O(V + E) O(V)
DLS ❌ No** ❌ No O(b^l) O(l)
IDS βœ… Yes βœ… Yes* O(b^d) O(d)
UCS βœ… Yes βœ… Yes O(b^(1+⌊C*/Ξ΅βŒ‹)) O(b^(1+⌊C*/Ξ΅βŒ‹))
Bidirectional βœ… Yes βœ… Yes* O(b^(d/2)) O(b^(d/2))
Greedy ❌ No ❌ No O(b^m) O(b^m)
A* βœ… Yes βœ… Yes*** O(b^d) O(b^d)

* For unweighted graphs
** Only if goal within depth limit
*** With admissible heuristic

πŸŽ“ Educational Use

This visualizer is perfect for:

  • Computer Science students learning AI search algorithms
  • Teachers demonstrating algorithm behavior
  • Researchers prototyping and testing heuristics
  • Interview preparation for algorithm questions
  • Self-learners understanding pathfinding concepts

πŸ› οΈ Technology Stack

Standalone Version

  • HTML5 Canvas for rendering
  • Brython (Python in browser)
  • Vanilla CSS with CSS variables
  • GIF.js for animation export
  • jsPDF for PDF reports

Next.js Application

  • Next.js 14+ (App Router)
  • TypeScript
  • Prisma ORM
  • NextAuth.js
  • Tailwind CSS
  • PostgreSQL/MongoDB
  • Lucide Icons

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

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

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Algorithm concepts from "Artificial Intelligence: A Modern Approach" by Russell & Norvig
  • Inspired by various online pathfinding visualizers
  • Built with ❀️ for the AI education community

πŸ“§ Contact

πŸ—ΊοΈ Roadmap

  • Add more algorithms (Dijkstra's, Bellman-Ford)
  • 3D graph visualization
  • Collaborative editing
  • Mobile app version
  • Algorithm performance comparison tool
  • Custom algorithm plugin system
  • Tutorial mode with guided walkthroughs
  • Integration with graph theory libraries

⭐ Star History

If you find this project useful, please consider giving it a star! ⭐


Made by [Ashfak Nawshad] | License | Changelog

About

Interactive platform for visualizing graph search algorithms (BFS, DFS, DLS, IDS, UCS, Bidirectional, Greedy, A*). Built with Python, HTML and CSS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 77.3%
  • HTML 12.1%
  • CSS 9.7%
  • Other 0.9%