Dijkstra Algorithm: Key to Finding the Shortest Path, Google Map to Waze

YOON MI KIM
4 min readJun 13, 2019

--

How does Google Maps find the directions?

These popular rideshare apps including Uber and Lyft use Waze, which was bought by Google Maps back in 2013 for a little over a billion dollars. Personally, I use Waze for driving and Google Maps when I’m not.

How do you find the shortest path ?

There are three major shortest path algorithms: Bellman Ford’s Algorithm, Dijkstra’s Algorithm, and Floyd–Warshall’s Algorithm.

Google Map is based on this algorithm, Dijkstra’s Algorithm which was invented by Edsger W. Dijkstra, Dutch essayist DescriptionEdsger Wybe Dijkstra was a Dutch systems scientist, programmer, software engineer, science essayist, and pioneer in computing science. A theoretical physicist by training, he worked as a programmer at the Mathematisch Centrum from 1952 to 1962.

https://www.azquotes.com/picture-quotes/quote-why-has-elegance-found-so-little-following-that-is-the-reality-of-it-elegance-has-the-edsger-dijkstra-56-70-61.jpg

Dijkstra is a greedy algorithm. What is greedy algorithm?

Greedy is an algorithmic paradigm that builds up a solution piece by piece, always choosing the next piece that offers the most obvious and immediate benefit. So the problems where choosing locally optimal also leads to global solution are best fit for Greedy.

A greedy algorithm is a simple, intuitive algorithm that is used in optimization problems. The algorithm makes the optimal choice at each step as it attempts to find the overall optimal way to solve the entire problem. Greedy algorithms are quite successful in some problems, such as Huffman encoding which is used to compress data, or Dijkstra’s algorithm, which is used to find the shortest path through a graph.

However, in many problems, a greedy strategy does not produce an optimal solution. For example, in the animation below, the greedy algorithm seeks to find the path with the largest sum. It does this by selecting the largest available number at each step. The greedy algorithm fails to find the largest sum, however, because it makes decisions based only on the information it has at any one step, without regard to the overall problem.

With a goal of reaching the largest sum, at each step, the greedy algorithm will choose what appears to be the optimal immediate choice, so it will choose 12 instead of 3 at the second step and will not reach the best solution, which contains 99.

the struggle is real

Dijkstra’s algorithm (or Dijkstra’s Shortest Path First algorithm, SPF algorithm) is an algorithm for finding the shortest paths between nodes in a graph, which may represent, for example, road networks. It was conceived by computer scientist Edsger W. Dijkstra in 1956 and published three years later. The algorithm exists in many variants; Dijkstra’s original variant found the shortest path between two nodes, but a more common variant fixes a single node as the “source” node and finds shortest paths from the source to all other nodes in the graph, producing a shortest-path tree.

  • => => → find the shortest path (minimum cost path)
Image result for dijkstra algorithm pseudocode
pseudocode
Dijkstra’s algorithm to find the shortest path between a and b. It picks the unvisited vertex with the lowest distance, calculates the distance through it to each unvisited neighbor, and updates the neighbor’s distance if smaller. Mark visited (set to red) when done with neighbors. https://upload.wikimedia.org/wikipedia/commons/5/57/Dijkstra_Animation.gif

Work Cited

https://www.myrouteonline.com/blog/what-is-the-best-shortest-path-algorithm

http://math.mit.edu/~rothvoss/18.304.3PM/Presentations/1-Melissa.pdf

https://brilliant.org/wiki/dijkstras-short-path-finder/

https://medium.com/basecs/finding-the-shortest-path-with-a-little-help-from-dijkstra-613149fbdc8e

https://www.hackerearth.com/practice/notes/dijkstras-algorithm/

https://www.hackerearth.com/practice/algorithms/graphs/shortest-path-algorithms/tutorial/

https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/graph/dijkstra

https://www.google.com/search?q=waze+app+algorithm&oq=waze+app+algorithm&aqs=chrome..69i57.4903j0j1&sourceid=chrome&ie=UTF-8

https://rubygarage.org/blog/how-to-make-a-gps-app-like-waze

https://www.quora.com/What-routing-algorithm-does-Waze-use

https://wiki.waze.com/wiki/Routing_server#Routing_algorithm_refinements

https://www.google.com/search?q=Greedy+algorithm&oq=Greedy+algorithm&aqs=chrome..69i57.233j0j1&sourceid=chrome&ie=UTF-8

--

--