How can I properly use Dijkstra's Algorithm?

Well, I read the API but I couldn’t really understand so can someone explain it to me and provide some piece of code if possible, please?

1 Like

This is odd, I found an algorithm similar to this. I also found a developer hub link

https://developer.roblox.com/en-us/recipes/dijkstra-s-algorithm

Based on the function above, Dijkstra’s Algorithm works as follows:

  1. It adds a starting node to the closed set.
  2. For every node in the closed set, it finds all the adjacent nodes and adds the distance traveled from the parent node to the distance to the next node. If there are two nodes in the closed set that share a neighbor, it gives the neighboring node the shorter distance.
  3. It finds the node with the shortest distance.
  4. It adds the node to closed set. If node is the goal, the process ends. Otherwise, it repeats from step 2.

The website has some sample of code which might help you understand, but also youtube videos I have found about this.

Google Screenshot

Edit:

Uh also, no clue why it’s like this but be aware of this function section part of the code


and the end at the bottom