Skip to content

A demonstration of Dijktra's Algorithm using p5.js

License

Notifications You must be signed in to change notification settings

MiDo-kun/Dijkstras-Algorithm-Simulation

Repository files navigation

Dijkstra's Algorithm Simulation

Dijkstra's Algorithm Simulation is a web application that uses p5.js, a JavaScript framework library, to simulate how Dijkstra's algorithm works. The project allows visitors to understand how the algorithm works in real-time by animating the entire process of the algorithm. This project aims to help fellow developers gain a better understanding of how the algorithm works in real-world scenarios.

The application is designed to be user-friendly and interactive. Users can define the speed of the algorithm and animate the algorithm according to their preferences, such as finding the shortest path or the shortest path tree.

You can view the live website here.

Main Objectives

The main objectives of this project were to:

  • Implement Dijkstra's algorithm.
  • Use HTML canvas to display the graph.
  • Use event loop APIs such as setInterval and setTimeout to handle multiple tasks simultaneously and animate the algorithm's progression.
  • Use p5.js to draw nodes and edges in the canvas.
  • Understand how graph theory works, its general components and how they correlate to solve real-world problems.

Key Features

The Dijkstra's Algorithm Simulation offers the following key features:

  • Animated progression of the algorithm.
  • Use of weighted adjacency matrix.
  • Find the shortest path between two nodes.
  • Show the shortest path tree of the graph.

What I Learned

Through this project, I gained the following knowledge and skills:

  • A strong understanding of how event loops work in periodic updates and animation.
  • How to draw objects in p5.js.
  • How Dijkstra's algorithm works.
  • How to use HTML canvas to display graphs.
  • How to create custom graphs by using Weighted Adjacency Matrix.

Overall, this project provided me with a solid foundation in modern web development by using third-party libraries in JavaScript and related technologies. The skills and knowledge I gained will be useful in future web development projects.

Contributing

Contributions are welcome! If you want to contribute to the project, please follow these guidelines:

  1. Fork the repository to your own GitHub account.

  2. Clone the repository to your local machine:

    git clone https://github.com/MiDo-kun/Dijkstras-Algorithm-Simulation.git

  3. Create a new branch for your changes:

    git checkout -b your-branch-name

  4. Make your changes to the code.

  5. Commit your changes:

    git commit -m "Your commit message"

  6. Push your changes to your fork:

    git push origin your-branch-name

  7. Create a pull request from your fork to the main repository.

License

This project is licensed under the MIT License. See the LICENSE file for more information.