Lanning 2014
Lanning 2014
Keywords
Dijkstra’s Algorithm ; Google Maps
1. INTRODUCTION
Google Maps welcomed us into the 21st century with the most
popular navigation application used amongst the population. It is
fast and efficient with directions, which allows us to arrive at our
destination at the least amount of travel time, or distance, or with Figure 1: Directed-weighted graph
some other constrains. But how does Google Maps operate? Out Figure 1 is an example of Dijkstra’s Algorithm. It is a directed-
of all the complexity of Google Maps, it all starts with this basic weighted graph with the goal of finding the shortest path from
algorithm: Dijkstra’s Algorithm. It is the beginnings of Google point A to point F ([3]).
Maps and any navigation system. Dijkstra’s Algorithm is a fairly
recent concept. It has only been around for a little over 50 years. 2.1 Algorithm
Edsger Dijkstra formulated Dijkstra’s Algorithm as a graph search Below is Dijkstra’s Algorithm, written out with precise
algorithm that will find the shortest path. Dijkstra’s Algorithm is a instructions. We will need to understand what Dijkstra’s
k-search algorithm that will visit each node of the graph in order Algorithm is doing when finding the shortest path. The algorithm
to find the shortest path from start to finish. With the help of below will help with our understanding of Dijkstra’s Algorithm
computers, the algorithm can be computed in a timely matter. and it will allow us to complete problems dealing with Dijkstra’s
From the pseudo-codes of Dijkstra’s Algorithm, personal Algorithm (The algorithm below is from Wikipedia, visited on
navigation systems were born. Google Maps were made possible April 7, 2013).
by Dijkstra’s Algorithm. Google Maps has changed the way we
look at personal navigation. Google Maps offer navigation on 1. Visited (when planning a route between two specific
many different types of transportation, and even other planets nodes) or if the smallest tentative distance among the
([1]), ([4]). nodes in the unvisited set is infinity (when planning a
Assign to every node a tentative distance value: set it to
zero for our initial node and to infinity for all other
nodes.
Permission to make digital or hard copies of part or all of this work for 2. Mark all nodes unvisited. Set the initial node as current.
personal or classroom use is granted without fee provided that copies are Create a set of the unvisited nodes called the unvisited
not made or distributed for profit or commercial advantage and that copies set consisting of all the nodes except the initial node.
bear this notice and the full citation on the first page. Copyrights for third-
party components of this work must be honored. For all other uses, 3. For the current node, consider all of its unvisited
contact the Owner/Author. neighbors and calculate their tentative distances. For
example, if the current node A is marked with a distance
Copyright is held by the owner/author(s). of 6, and the edge connecting it with a neighbor B has
ACM SE '14, Mar 28-29 2014, Kennesaw, GA, USA
length 2, then the distance to B (through A) will be
ACM 978-1-4503-2923-1/14/03. 6+2=8. If this distance is less than the previously
http://dx.doi.org/10.1145/2638404.2638494
recorded tentative distance of B, then overwrite that 3.1 The Workings of Google Maps
distance. Even though a neighbor has been examined, it Understanding the workings of Google Maps is relatively simple,
is not marked as "visited" at this time, and it remains in as we will see in the example that follows. Consider on a small
the unvisited set. scale, that each intersect is the node and each street is the arc.
4. When we are done considering all of the neighbors of Dijkstra’s Algorithm will find the shortest distance from start to
the current node, mark the current node as visited and finish. In Google Maps, it will tell us the shortest route in distance
remove it from the unvisited set. A visited node will and time. On a large scale, let us consider that the cities are the
never be checked again. nodes and the interstates are the arcs. Dijkstra’s Algorithm and
Google Maps will do the same thing, finding the shortest path
5. If the destination node has been marked complete and/or shortest time.
traversal), then stop. The algorithm has finished.
6. Select the unvisited node that is marked with the
4. EXAMPLE
To understand Dijkstra’s Algorithm better, we have the following
smallest tentative distance, and set it as the new "current
example. This is a basic example to ease our way into understand
node" then go back to step 3.
the algorithm.
2.2 Applications of Dijkstra’s Algorithm
As we know, Dijkstra’s Algorithm finds the shortest path between
two points of a weight graph. The weights are just arbitrary 2 12
numbers. Money flow, prices, scheduling all can be optimized
through Dijkstra’s Algorithm. Besides the routing aspect,
Dijkstra’s Algorithm can be used in currency exchange, 8 5 4 10
telemarketer scheduling, traffic planning, etc. ([2]).
Dijkstra’s Algorithm has been useful for many of our navigational
6
luxuries. There are only a few disadvantages to Dijkstra’s
Algorithm. As previously stated, Dijkstra’s Algorithm cannot use Figure 3: Example problem of Dijkstra’s Algorithm, ([6]), ([7])
negative numbers ([1]). This would have an effect if we were
tracking money follow and there was a loss of money, a negative
1 0 2 2 4 14
value. Another, Dijkstra’s Algorithm is a lengthily process to due
0 2 14 16
by hand. This was more so a problem in the early years of
Dijkstra. We now have the capability of using computers to do the 2 12
work.