Extended Essay 2023
Extended Essay 2023
How are weighted directed graphs applied by GPS and navigation apps to find
the shortest paths between locations in the United States and Azerbaijan?
Table of Contents
1. Introduction 3
2. Topics 5
6.3. A* Algorithm 29
7. Conclusion 30
Bibliography 31
3
1. Introduction:
How are weighted directed graphs applied by GPS and navigation apps to find the shortest
The reason I hope to explore the use of graph theory in GPS navigation is due to its constant
applicability in my everyday life, where I use the Waze app to find the best way to get home. I once
visited my brother-in-law and he told me about graph theory, and how it's applied in many mundane
activities where it often goes unnoticed, such as navigation and social media. I was originally more
intrigued in the applications of graph theory in social media, however soon realized that it often plays
a relatively insignificant role, whereas in navigation it is essential and more layered in its application.
In the process of answering this question, I will be exploring different types of graphs that are
explored in graph theory, primarily focusing on directed and weighted graphs. I will dive deeper into
the analysis of how these graphs are combined with mathematical algorithms to find the shortest
routes for the navigation applications users, identifying which algorithms are used to overcome pitfalls
and obstacles, and what factors are identified and taken into account.
When analyzing each individual graph type, its benefits and practicality in combination with
other mathematical algorithms and types of analysis will be explained and judged, and a conclusion
will be drawn regarding the necessity of graph theory in navigational apps to find shortest paths in
Azerbaijan and the East Coast of the United States. More specifically, the actual purpose and method
of implementation of graph theory will be looked at, including the types of graph-analysis that are
The different graphs and approaches of analyzing them will differ in their complexity and
therefore their effectiveness. This will be explained further later on in the essay, however a brief
explanation for this is that certain graphs allow for a more in-depth analysis of the varying paths
which can impact an applications practicality, and that certain graph and path analysis methods allow
Graph theory is one of, if not the most important mathematical concept used by navigational
apps to improve their applications and the routes they create for their users. It allows for users to get to
and from destinations much faster, and apps that create better and more efficient routes will be more
desirable and hence more valuable. Graph theory allows for the apps to analyze the structures of cities
or countries, and factor in traffic congestion, length of a road, or the quantity of destinations that have
to be passed in order to create a route for the users of navigational applications to use, which makes
for better routes and happier users. Due to all of this, the implementation of graph theory is one of the
most important parts of navigational applications, and its complexity and effectiveness proportionally
affect the success of the application itself, and in this essay the best form of graph theory
2. Topics:
Graph theory: The mathematical theory of the properties and applications of graphs.
Weighted graph: A graph with edges which have been numbered by weights or numbers, wherein the
weights represent something, and wherein the length of a path becomes the sum of all the weights of
Unweighted graph: A graph where the edges have no numerical or weighted value. 1
Directed graph/Digraphs: A graph where the edges are directed and the direction of the edge is
Undirected graph: A graph where the edge between 2 nodes is undirected, therefore connected only by
a line.1
Node/Vertex: A node, also known as a vertex, is a single point on a graph. Such nodes and their
Edge: An edge is the line that connects 2 different nodes on a graph. Such edges can be directional or
nondirectional.
A shortest path represents the shortest path that must be traversed in order to get from a starting node,
a, to a destination node, z. A shortest path may vary depending on the type of graph used and the
depth (quantity of factors taken into account) of the analysis. Generally in routing, the qualification of
a solution being optimized can be determined by varying heuristics dependent on the problem, such as
total physical distances, changes in altitude, and others. This is why the optimal route in navigation
apps is sometimes not the physically shortest, as factors such as traffic congestion, weather, fares/tolls,
also must be taken into account based on the user’s preferences and demands.
7
A shortest path may vary depending on the type of graph analyzed. This is because different
In the case of unweighted graphs, the length of a path is determined by the quantity of edges that must
𝑛
(𝑎, 𝑧) = ∑ 𝐸𝑖
𝑖=0
Figure 1
In the case of the path above, the sigma notation would be applied for all the edges traversed from a to
z. It would start off at 0 edges, travel 1 edge when reaching b, travel another edge when reaching c,
and lastly finish the path by traversing one more edge to get to node z. Hence, above the path would
have a distance of 3.
8
Figure 2
The shortest path in unweighted graphs will be one that traverses the least quantity of edges. Varying
methods are used to find such paths efficiently and will be explored later in the essay.
In contrast, the length of a path for a weighted graph is not as straightforward. With every edge being
assigned a different “weight”, there are unequal costs in traversing an edge, and to find the length of a
path one must find the sum of both the number of edges traversed and all of their weights. This means
𝑛
(𝑎, 𝑧) = ∑ 𝐸𝑖𝑣𝑖
𝑖=0
Where E represents the min set of all edges traversed, and 𝑣𝑖 representing the weight (value) of the
Figure 3
In the case of a diagram above, the length of the path will be determined by adding the sums of the
edges in order or progression. The value of 𝑣1 would be the value of the first edge, here being the one
between a and b, with the value of 234. i would then progress to 2, and the value of 𝑣2 would be 193
as that is the value of the second edge in this progression. Lastly, the value of 𝑣3 would be the weight
of the third edge, here being the edge between c and z, with the value of 832. To find the length of the
path in this hypothetical example the 3 values have to be added up, hence being 234 + 193 + 832,
This means that the shortest path in a weighted graph will have to have the smallest sum of all its
edges and their respective weights, hence meaning that not only the quantity of nodes but all their
The most straightforward approach to traversing a graph is to perform a Breadth-First Search (BFS).
Figure 4
Assuming that the starting node is node a, and the destination node is node z, a Breadth-First Search
Figure 5
11
For each, we determine if any are the destination node, z. If none are the destination node, all nodes
neighboring node a would be marked as node b, and would have a depth of 1. For each node b (with
the depth of 1), we would perform the same analysis as in the case of a, wherein we would check all
their neighbors which have previously been unchecked (wherein a b node would not check the a node,
which has already been determined to be it's neighbor and not node z, and a b node would not check
other neighboring b nodes) and determine whether any are the node z.
Figure 6
If not, they are marked as having a depth of 2, and could be marked as node c, and their neighbors
Figure 7
In the case of this diagram, the z node was first able to be found at the depth of 3. If this wouldn’t have
happened, this cycle would continue until the z node would be found, and when found we would be
certain that the first found path leading to it is the shortest. This is known because none of the longer
paths had made it to the node z by the time that it was found through the shortest path.
Figure 8
13
As seen above, repeating the process one more time to find the depth of 4 would once again find a
path leading to the node z, however this is still a longer process than the original path found. The BFS
can be run one last time, finding the final version of the (a, z) path in the case of this graph.
Figure 9
Here the final (a, z) path that can be found has a depth of five, once again establishing that the first
found path was the quickest due to the nature of the BFS. The longer the BFS is run the longer the
paths are.2
2 Jose, Kelvin. “Graph Theory: Breadth First Search.” Medium, Towards Data Science, 27 May 2020
14
Figure 10
Unlike BFS, however, we focus on one neighbor at a time. In the case of a DFS, upon examining all
the neighbors of a and determining that none are z, one would be picked at random.
Figure 11
For this selected node, all of its neighbors would be analyzed similarly to what had happened with
node a.
15
Figure 12
If once again none are z the cycle would continuously repeat over and over until the node z is located
Figure 13
16
Figure 14
Figure 15
This means that the DFS algorithm creates one path at a time, and although the determined path is
functional, it isn’t necessarily the shortest. The only way to find the shortest path would be to
repeatedly run the algorithm over and over, storing all the results, and when all possible paths are
found picking whichever is the shortest. For example, in the case of the previous diagram, re-running
Figure 16
Figure 17
18
Figure 18
Of these 3 different runs of the DFS, the first was by no means the best, and in fact out of these 3 it
was the longest path found. Even in the case of this diagram, more potential paths could have been
found using the DFS algorithm, due to the interlinked nature of all of the nodes that in the previous 3
runs have been marked as b. To find the total number of paths possible, the counting principle could
be applied.3
This means that despite being accurate, the DFS algorithm is poorly optimized and takes a significant
amount of time, energy and data storage to locate the shortest paths, hence making BFS a more
reliable choice because it guarantees that the shortest path will be found in the very first run of its
analysis.
3 Jose, Kelvin. “Graph Theory: Depth First Search.” Medium, Towards Data Science, 27 May 2020
19
An issue arises when using an unmodified raw version of the BFS in the case of weighted graphs,
however. A Breadth-First Search assumes that all edges are equal, and hence when searching for the
shortest path simply finds the lowest number of edges traversed. If every edge is not equal, as is the
case in weighted graphs, this presents an issue. Take for example a situation in which we are
attempting to find the shortest distance path as we traverse from connected cities in my home country
of Azerbaijan:
Figure 19
If we are attempting to get from Baku to Ganja, our BFS graph would produce the following:
20
Figure 20
From there, we assign all neighbors of Gobustan (that we haven’t already visited) a depth of 2, then
Figure 21
Already, we find our first instance of Ganja, as it is connected to Fuzuli. In the case of a Breadth-First
Search, this very first instance would be assumed to be the shortest path. While this seems appropriate,
as it is the fewest number of edges traversed, we can see the problem when we compare this solution
21
with alternate paths taking into account the weight, here being only the physical distance between
cities..
From the weighted graph, we see that there are three potential non-cyclic routes that could be taken.
Figure 22
First, following Baku to Gobustan (63km), to Mugan (71km), to Yevlakh (159km) to Ganja (69km)
Second, we see Baku to Shamakhi (122km) to Agsu (36km) to Ganja (195km), for a total distance of
353 km.
And lastly, the route that BFS provided, which was Baku to Fuzuli (327km) to Ganja (254km) for a
As this example proves, BFS is capable of finding only the optimal route for traversing the least
number of edges, which is useful only for unweighted graphs. Although here we were able to
manually calculate the physical distances of the other potential routes, navigational applications would
want to avoid this, as it is inconvenient, time consuming, and significantly harder for more complex
graphs, as in this graph there were only 10 nodes, whereas in the case of a city where every road and
To combat this issue, we can modify BFS to evaluate more than just depth and number of edges
traversed. We can do this by storing the smallest sum of values of all paths to nodes a…z. Once we
find the first path to z, we can sum up its values, then stop searching down any paths whose values
sum up to a greater value. To show this, imagine we have the following graph and want to proceed
Figure 23
In order to perform Djikstra, we will need to keep a running table of all the nodes we have visited, as
well as the cost it takes to reach that node and the node we are departing from to get to it. We will start
4 Joshi, Vaidehi. “Finding the Shortest Path, with a Little Help from Dijkstra.” Medium, Medium, 17 Oct. 2017
23
at node a and proceed in a similar fashion to BFS. Since we have not reached any other nodes, we can
a 0 Starting node
b 7 a
c 3 a
d ∞
e ∞
We first examine the neighbors of a. For each, we look at the value of the edge, and will replace values
in the table if the value of the edge + the cost of the current node is less than the cost we have stored
on the table. Therefore, we replace the cost associated with node b and c, and will put the “node
We then repeat this for neighbors of node b, then for node c. So for node c’s neighbors, we have node
b and node d. Here we see that we can reduce the cost entries for both nodes, as the cost of node c +
the edge between node c and node b is less than the stored value we have for node b. Node d is also
5 Joshi, Vaidehi. “Finding the Shortest Path, with a Little Help from Dijkstra.” Medium, Medium, 17 Oct. 2017
24
a 0
b 4 c
c 3 a
d 5 c
e ∞
We then do this process for the neighbors of node b. We reach node e with a total cost of 13 and
update it. However, we arrive at node d with a cost of 9, which is greater than the current stored cost.
Therefore, we do not update the value for node d. Further, the calculated cost to node c is 5, so we
a 0
b 4 c
c 3 a
d 5 c
e 13 b
6 Joshi, Vaidehi. “Finding the Shortest Path, with a Little Help from Dijkstra.” Medium, Medium, 17 Oct. 2017
25
Lastly, we look at node d, and choose to not update the entries for node c and node b. However, we
see that the total cost to reach node e through node d is 9, which means that we update the entry.
a 0
b 4 c
c 3 a
d 5 c
e 9 d
Since we have checked all neighbors of node e, we can safely conclude that we have found the
shortest path. And using the table we can determine the shortest route by starting at node e and
backtracking by looking at the previous node that we store in the table. Thus, the shortest route is
7 Joshi, Vaidehi. “Finding the Shortest Path, with a Little Help from Dijkstra.” Medium, Medium, 17 Oct. 2017
26
In order to assess how Dijkstra’s Algorithm works in pathfinding with maps and not just on
hypothetical graphs, we will take a look at a simplified version of the map of the upper East Coast of
Figure 24
When applying Djikstra’s here, we will once again be keeping a running table of all the nodes being
visited, however here the nodes will be referred to by the city name, and the cost will be the distance
Allentown ∞
Princeton ∞
Similarly to before, the algorithm would look at paths interlinking the nodes, so it could, for example,
While in this variation the first instance of the Princeton node has already been found, the algorithm
would continue to be run, and now the neighbors of node New York would be examined.
28
Allentown ∞
The algorithm would continue cycling, finding varieties of paths which would get the user to their
destination, with all paths having varying values. For example, the path
Monticello which would then lead to the examination of the neighbors of Allentown, however while
arriving at the desired destination this path has a total cost of 403, being comparatively worse to the
others. In the end, the algorithm would find that the Boston-New York-Princeton path is ultimately the
What is interesting is that finding real-life situations can actually make this problem easier to solve.
This is because we can assign external, heuristic functions to the nodes we are traveling to. Let us
once again refer to the East Coast example. If we are heading from Boston to Princeton, there is more
for us to consider than just focusing on the current shortest paths we are examining. Since we are
traveling from North to South, paths that are bringing us more South should be prioritized, as paths
bringing us more North are increasing the minimum distance we need to travel before getting to b.
This was demonstrated quite well through Dijkstra's Algorithm, which found that the quickest path
6.3. A* Algorithm:
For weighted graphs, we can apply additional heuristics after visiting each node, adding to the overall
cost of getting to the node by estimating the cost of getting from the node to the endpoint. To provide
a real-world heuristic, on our path at node x, we may be able to see that there are physical obstacles
that exist from a considered node x and the location of the endpoint, such as a mountain, or water. We
can assign x a higher heuristic value, allowing us to focus on other nodes with a potentially higher
However, applying heuristics can also provide suboptimal solutions.. Take for example, a graph from
a to z where there exists an impassable obstacle at the center. A suboptimal answer can happen if we
overestimate the heuristic value of a node, like the cost of its physical distance from the endpoint,
9 S, Ravikiran A. “A* Algorithm in Artificial Intelligence You Must Know in 2023: Simplilearn.” Simplilearn.com, Simplilearn, 26 Feb. 2023
30
7. Conclusion:
The importance of graph theory in the process of pathfinding is pretty clear, with algorithm’s being
made specifically to combine the two and maximize the returns from using them adjunctly. The
process of pathfinding and navigation relies on graph theory to remain optimal, because in all
occasions when finding the best possible path, one needs to weigh several factors of all the different
edges that have to be traversed, and that is exactly what graph theory allows its employers to do.
Whilst not all types of graph theory are efficient, with weighted graphs being the predominantly used
force in the navigation industry, graph theory itself is a critical part of pathfinding. In the real world,
there may be some variations to how graph theory is applied, which weren’t as heavily covered in this
investigation, for example being traffic, which would be considered a heuristic element, but even in
such occasions, the use of the graph theory would remain the same, and all that would change is the
weighting of the paths. For example, rather than navigating solely through distance traveled, app
developers would create algorithms that combine factors like the distance traveled with the heuristic
elements through their own patented algorithms, and once again utilize graph theory with updated
While graph theory alone may not be enough to create a state-of-the-art application, it is one of the
most critical factors of the process, and can be applied in the real world as was seen here, with the
quickest paths being found relating to certain routes in the United States and in Azerbaijan.
31
Bibliography:
Even-Tzur, Gilad. “Graph Theory Applications to GPS Networks.” GPS Solutions Vol. 5, John
https://www.proquest.com/openview/635e778234586cae60952c8c271603b1/1?pq-origsite=gsc
holar&cbl=2043695.
https://www.javatpoint.com/graph-theory-types-of-graphs.
Jose, Kelvin. “Graph Theory: Breadth First Search.” Medium, Towards Data Science, 27 May
2020, https://towardsdatascience.com/graph-theory-breadth-first-search-d898e9f40fdd.
Jose, Kelvin. “Graph Theory: Depth First Search.” Medium, Towards Data Science, 27 May
2020, https://towardsdatascience.com/graph-theory-depth-first-search-977c1ae386e1.
Joshi, Vaidehi. “Finding the Shortest Path, with a Little Help from Dijkstra.” Medium, Medium,
17 Oct. 2017,
https://medium.com/basecs/finding-the-shortest-path-with-a-little-help-from-dijkstra-613149fbd
c8e.
Moore, Karleigh, et al. “Depth-First Search (DFS).” Brilliant Math & Science Wiki,
Brilliant.Org, https://brilliant.org/wiki/depth-first-search-dfs/.
Pohl, Ira. “Heuristic Search Viewed as Path Finding in a Graph.” Artificial Intelligence, Volume
https://www.sciencedirect.com/science/article/abs/pii/000437027090007X#:~:text=Heuristic%2
0functions%20are%20estimates%20of,accuracy%20of%20the%20heuristic%20function.
32
S, Ravikiran A. “A* Algorithm in Artificial Intelligence You Must Know in 2023: Simplilearn.”
https://www.simplilearn.com/tutorials/artificial-intelligence-tutorial/a-star-algorithm#:~:text=A*
%20Search%20Algorithm%20is%20a,path%20algorithm%20(Dijkstra%27s%20Algorithm).
https://www.wallstreetmojo.com/heuristics/#:~:text=The%20four%20common%20types%20of,
anchoring%2C%20availability%2C%20and%20representativeness.