Guru on Rails
I'm pretty lazy (lol). I found the best explanation after watching 100 thousand videos. I'm just kidding. This video is easy to understand so that I don't explain any more. This is old algorithm but very useful for map and distances.
I intended to make another one but unluckily I'm not native speaker. This guy did it good than me, why don't we just use it? It's like we make decisions in design. Taking advantage of existing design or create the new one? It depends on the quality we will make. If we are not sure we will make a better version, using the existing one is a good idea. But if we can make it better and we also have time to do. Just do it!
The idea behind is we collect all of direct shortest distances. If we can make a route from A to H with these shortest distances, we will have a shortest route. The lookup just stops when all of nodes were visited.
However, the algorithms always begin with Data Structure. It helps the algorithm more efficient. A bad data structure might make your code worse. Hence, we firstly think of data structure. How to design it?