0% found this document useful (0 votes)
47 views

Extended Essay 2023

The document is an extended essay on the application of graph theory in GPS and navigation apps, specifically focusing on how weighted directed graphs are used to find the shortest paths in the United States and Azerbaijan. It explores various graph types, algorithms for solving shortest paths, and the significance of graph theory in enhancing navigational efficiency. The essay concludes that effective implementation of graph theory is crucial for improving user experience in navigation applications.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views

Extended Essay 2023

The document is an extended essay on the application of graph theory in GPS and navigation apps, specifically focusing on how weighted directed graphs are used to find the shortest paths in the United States and Azerbaijan. It explores various graph types, algorithms for solving shortest paths, and the significance of graph theory in enhancing navigational efficiency. The essay concludes that effective implementation of graph theory is crucial for improving user experience in navigation applications.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

1

IB Subject: Mathematics Extended Essay

Graph Theory in Pathfinding

How are weighted directed graphs applied by GPS and navigation apps to find

the shortest paths between locations in the United States and Azerbaijan?

Word Count: 3901


2

Table of Contents

1. Introduction 3

2. Topics 5

2.1. Graph Theory Elements and their Definitions 5

2.2. Shortest Path 6

3. Types of Shortest Paths 7

3.1. Unweighted Graphs 7

3.2. Weighted Graphs 8

4. Algorithms for Solving Shortest Path in an Unweighted Graph 10

4.1. Breadth-First Search 10

4.2. Depth-First Search 14

5. Algorithms for Solving Shortest Path in a Weighted Graph in Azerbaijan 19

5.1. Caveats of Breadth-First Search 19

5.2. Dijkstra’s Algorithm 22

6. Real-life Application of Dijkstra’s Algorithm in the United States 26

6.1. Real-life Example 26

6.2. Heuristic Functions 28

6.3. A* Algorithm 29

6.4. Heuristic Error 29

7. Conclusion 30

Bibliography 31
3

1. Introduction:

My research question is:

How are weighted directed graphs applied by GPS and navigation apps to find the shortest

paths between locations in the United States and Azerbaijan?

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

used to determine which paths are to be considered the shortest.


4

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

for a more efficient or more accurate path to be determined.

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

implementation and analysis will be explored and outlined.


5

2. Topics:

2.1. Graph Theory Elements and their Definitions:

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

all the edges rather than just the quantity of edges. 1

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

represented by an arrow pointing from one node to another.1

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

connections are what make up a graph.

Edge: An edge is the line that connects 2 different nodes on a graph. Such edges can be directional or

nondirectional.

Neighbor: A node that is connected to the current node by an edge.

1 “Graph Theory Types of Graphs - Javatpoint.” Www.javatpoint.com, Java


6

2.2. Shortest path:

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

3. Types of Shortest Paths:

A shortest path may vary depending on the type of graph analyzed. This is because different

types of graphs (weighted/unweighted) determine the length of a path in varying ways.

3.1. Unweighted Graphs:

In the case of unweighted graphs, the length of a path is determined by the quantity of edges that must

be traversed from point A to point Z:

𝑛
(𝑎, 𝑧) = ∑ 𝐸𝑖
𝑖=0

Where E represents the min set of all edges traversed.

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.

3.2. Weighted Graphs:

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

that the length of a path is identified as:

𝑛
(𝑎, 𝑧) = ∑ 𝐸𝑖𝑣𝑖
𝑖=0

Where E represents the min set of all edges traversed, and 𝑣𝑖 representing the weight (value) of the

edge 𝑒𝑖 in the set E.


9

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,

which would be 1259.

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

weights have to be looked at to effectively path-find.


10

4. Algorithms for Solving Shortest Path in an Unweighted Graph:

4.1. Breadth-First Search:

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

would first examine all neighbors of node a.

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

would then be checked.


12

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

4.2. Depth-First Search:

The depth-first search (DFS) is another algorithm to find a path from a to z.

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

as is seen in the following diagrams.

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

the algorithm twice could obtain the following results,


17

Figure 16

And this path would end with a depth of 4.

Figure 17
18

Another run through could garner the following path:

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

5. Algorithms for Solving Shortest Path in a Weighted Graph in Azerbaijan:

5.1. Caveats of Breadth-First Search:

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

First, all neighbors of Baku would be assigned a depth of 1:

Figure 20

From there, we assign all neighbors of Gobustan (that we haven’t already visited) a depth of 2, then

repeat for Shamakhi, then Fuzuli:

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)

for a total distance of 362 km.

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

total distance of 581 km.


22

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

address can be considered a node that number would be significantly higher.

5.2. Dijkstra’s Algorithm:

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

from node a to node e.

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

assign them a cost of infinity to start:

Node Cost Node arrived from

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

arrived from” entry for those nodes as a.

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

replaced, as its current value is infinity.

5 Joshi, Vaidehi. “Finding the Shortest Path, with a Little Help from Dijkstra.” Medium, Medium, 17 Oct. 2017
24

Node Cost Node arrived from

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

elect to not update it.

Node Cost Node arrived from

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.

Node Cost Node arrived from

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

a--c--d--e and has a total cost of 9.

7 Joshi, Vaidehi. “Finding the Shortest Path, with a Little Help from Dijkstra.” Medium, Medium, 17 Oct. 2017
26

6. Real-life Application of Dijkstra’s Algorithm in the United States

6.1. Real-life Example:

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

the United States, where I hope to attend university.

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

traveled. We will start in Boston, attempting a journey to get to Princeton.


27

Node Cost Node arrived from

Boston 0 Starting node

New York 215 Boston

Monticello 242 Boston

Allentown ∞

Princeton ∞

Similarly to before, the algorithm would look at paths interlinking the nodes, so it could, for example,

examine the neighbors of Monticello, and the cost of getting to them.

Node Cost Node arrived from

Boston 0 Starting node

New York (242+96) =338 Monticello

Monticello 242 Boston

Allentown (242+103) =345 Monticello

Princeton (242+130) =372 Monticello

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

Node Cost Node arrived from

Boston 0 Starting node

New York 215 Boston

Monticello (215+96) =311 New York

Allentown ∞

Princeton (215+53.4) =268.4 New York

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

Boston-Monticello-Allentown-Princeton would be found after the examination of the neighbors of

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

best available, therefore suggesting that path to the user.

6.2. Heuristic Functions:

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

was the one that was directed most south.8

8 Vaidya, Dheeraj. “Heuristics.” WallStreetMojo, CFA Institute , 21 May 2022


29

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

value to arrive at, but a lower heuristic value.9

6.4. Heuristic Error:

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,

causing us to prioritize searching other nodes with a lower heuristic value.

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

weights to pathfind and create the best possible paths.

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

Wiley & Sons, Inc., July 2001,

https://www.proquest.com/openview/635e778234586cae60952c8c271603b1/1?pq-origsite=gsc

holar&cbl=2043695.

“Graph Theory Types of Graphs - Javatpoint.” Www.javatpoint.com, Java,

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

1, Issues 3–4, Elsevier, 1970,

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.”

Simplilearn.com, Simplilearn, 26 Feb. 2023,

https://www.simplilearn.com/tutorials/artificial-intelligence-tutorial/a-star-algorithm#:~:text=A*

%20Search%20Algorithm%20is%20a,path%20algorithm%20(Dijkstra%27s%20Algorithm).

Vaidya, Dheeraj. “Heuristics.” WallStreetMojo, CFA Institute , 21 May 2022,

https://www.wallstreetmojo.com/heuristics/#:~:text=The%20four%20common%20types%20of,

anchoring%2C%20availability%2C%20and%20representativeness.

You might also like