Question Paper
Question Paper
Problem Statement
Write a C, Java, or Python program to determine
the shortest path, in terms of total driving distance,
between two locations in a road network repre-
sented as a weighted undirected graph. The weight
of each edge is at least as large as the Euclidean
distance between the corresponding vertices. The
road network data is provided in a text file named
graph data.txt. Each node in the graph repre-
sents a location with specific coordinates, and each
edge represents a road with a given driving distance.
Your program must read this file and implement a
search algorithm to find the optimal path from a
specified starting location to a target location. You Output
must implement the search algorithm yourself; do Assuming the user wants the path from node 2 to
not use built-in library functions or modules (e.g., node 3 following is the output:
networkx in Python) that directly compute shortest
paths. You cannot use Dijkstra’s algorithm. Enter the start node index (0-4): 2
Enter the goal node index (0-4): 3
Path (from start to goal):
Input
2 -> 4 -> 3
An example of the content of the text file named Total Path Cost: 127.26
graph data.txt is as follows:
5 6 Submission Guidelines
96.695882 30.864883 Submit your source code as route <your roll>.x,
48.188706 27.740254 where x is either c, java, or py, and a file
40.391313 98.568165 output <your roll>.txt containing the output in
5.362280 8.607419 the above format, which shows the optimal path an
19.946435 79.894819 its cost.
0 1 57.799213
1 2 73.386690
1 3 72.435762 Marks Distribution
1 4 66.158788
2 4 42.195245 Marks will be awarded as follows (Total 100): 45
3 4 85.065436 marks for correct search algorithm implementation;
20 marks for proper input file handling and graph
The first and second entries are integers n and e,
representation; 25 marks for accurate shortest path
indicating the number of nodes and the number of
and cost calculation; 5 marks for correct output for-
edges. In this example, n is 5 and e is 6. The next n
matting; and 5 marks for code quality (readability,
lines are in
comments, variable names).
x y