Skip to content

Detects the shortest path in a graph embedded in an image using Dijkstra’s algorithm and highlights the path directly on the image.

License

Notifications You must be signed in to change notification settings

Z4phxr/Dijkstra-Image-Graph-Pathfinding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Dijkstra Image Graph Pathfinding

This project implements an image-based graph detection system using Dijkstra's algorithm to find the shortest path between two nodes in a weighted, undirected graph drawn on an image.

The system:

  • Detects nodes (black circles with labels) and edge weights (red numbers),
  • Extracts valid connections using image processing and OCR,
  • Applies Dijkstra’s algorithm to compute the shortest path,
  • Draws the resulting path directly onto the original image.

All logic, explanation, and usage instructions are contained in the notebook file (dijkstra_image_pathfinding.ipynb).


Libraries Used

  • OpenCV (cv2) – image processing, shape detection, drawing
  • pytesseract – OCR to detect node labels and edge weights
  • NumPy – numerical operations, distance calculations
  • math – geometric computations
  • Google Colab patch (cv2_imshow) – used to display images in Google Colab

Note: If you're using Jupyter Notebook locally, replace cv2_imshow() with matplotlib.pyplot.imshow() or cv2.imshow() as needed, since cv2_imshow() is specific to Google Colab.


How to Use

  1. Upload or create an image with a graph following the drawing rules described in the notebook.
  2. Open the notebook in Google Colab (recommended) or Jupyter Notebook.
  3. Run all cells — the script will:
    • Detect graph structure,
    • Apply Dijkstra’s algorithm,
    • Output the original image with the shortest path highlighted.

📝 License

This project is open-source and licensed under the MIT License.

About

Detects the shortest path in a graph embedded in an image using Dijkstra’s algorithm and highlights the path directly on the image.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published