Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Project: Finding Optimal Routes Total Points: 1 0 0 Due: Friday, July 2 6 , by 2 3 5 9 Central If you like, you
Project: Finding Optimal Routes
Total Points:
Due: Friday, July by Central
If you like, you may work in teams of Both teammates will receive the same grade. Please
carefully read the submission instructions at the end of the assignment.
Grader: Suravi Regmi sregmi@memphis.edu Grades will generally be posted within
weeks of the assignment due date. Questions about grading? Please contact her first.
The Story So Far...
The year is Humanity has managed to still be around and has recently joined the United
Federation of Spacefaring Civilizations. Youve been hired by the federation to write software for
their interstellar warp gate system, which connects various star systems in the universe together.
Each warp gate connects two systems together, but not every pair of systems is connected. For
example, there is no warp gate that directly connects Arcturus to Rigel, because the Arcturians
have had a longstanding feud with the Rigellians. However, there are gates connecting Arcturus to
Betelgeuse and Betelgeuse to Rigel, so its possible to travel from Arcturus to Rigel with a layover
at Betelgeuse. Furthermore, each star system has its own economy and trade agreements with other
systems, so the cost of using each warp gate differs widely. The problem you want your software
to solve is this: given any two star systems in the universe, whats the least expensive way to get
from the starting point to the destination? People and other intelligent sentient organisms want
cheap flights even in
COMP Summer Project Due Friday, July by Central
Graphs
Mathematically, we can model the warp gate network as a graph. Each star system is represented
by a vertex in the graph. Vertices that are connected by warp gates have an edge between them.
Vertices that are directly connected by edges are known as neighbors. Each edge has a weight
representing the cost of using that warp gate. Well assume that the gates are bidirectional, so if we
can travel from vertex A to vertex B we can also travel from B back to A at the same cost. The
fancy technical term for this kind of graph is a weighted undirected graph. We will also assume
that the graph is connected, meaning that its possible to get from any vertex to any other vertex
albeit not necessarily directly
Heres an example of a graph showing the connections between a few star systems. This graph
has four vertices and five edges.
Finding Shortest Paths
Dijkstras algorithm, developed in the s by Earth computer scientist Edsger Dijkstra, gives
us a way to find the least expensive shortest path between any two vertices of a graph. Heres
how the algorithm works:
Assign every vertex a distance of infty except the starting vertex, whose distance is Mark
every vertex as unvisited
Pick the minimumdistance unvisited vertex from the graph. Call this vertex V Note that
initially, this will always be the starting vertex since its the only one with a distance thats
not infty
Consider each of vertex V s unvisited neighbors. For each unvisited neighbor N :
Compute N s tentative distance by adding V s distance to the weight of the edge
connecting V and N
Page of
COMP Summer Project Due Friday, July by Central
If the tentative distance is less than N s current distance, replace N s distance with the
tentative distance. Also mark V as N s previous vertex.
If the tentative distance is not less than N s current distance, do nothing.
Mark vertex V as visited
Go back to step and repeat until the destination vertex has been visited At this point, the
destination vertexs distance is the cost of the shortest path, and the path itself can be found
by following the previous records from the destination backwards to the starting point.
For example, suppose we want to find the shortest path from Arcturus to Rigel in the previous
graph. Heres how Dijkstras algorithm would run:
Initialize every vertexs distance to infty except Arcturus, which has a distance of Mark every
vertex as unvisited.
Pick the minimumdistance unvisited vertex from the graph, which is Arcturus. Arcturus has
two unvisited neighbors, Betelgeuse and Eta Carinae.
For Betelgeuse, the tentative distance is Arcturus distance plus the weight of the
edge connecting Arcturus to Betelgeuse : is less than Betelgeuses current
distance infty so we replace Betelgeuses distance with and mark Betelgeuses previous
as Arcturus.
Page of
COMP Summer Project Due Friday, July by Central
For Eta Carinae, the tentative distance is Arcturus distance plus the weight of
the edge connecting Arcturus to Eta Carinae : is less than Eta
Carinaes current distance infty so we replace Eta Carinaes distance with and mark
Eta Carinaes previous as Arcturus.
Page of
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started