Homework 8: Handed out: 4/5; Due: 4/19.
Note: This assignment involves programming, which will have to be done using J++ in the CSUGLab. Even if you originally use another variant of Java for your program, make sure it runs in the CSUGLab.
As usual, you can discuss this assignment with anyone you like, but you must write it up yourself.
In this assignment, you are given data about the road network in the USA. What we want from you are programs to do the following:
In this assignment, you'll be working with a simplified version of National Highway Planning Network Version 3.0 , part of The National Transportation Atlas Data (NTAD) maintained by the Bureau of Transportation Statistics. Note that NHPN is primarily a planning network that contains only the major roads in the country (the top 10% of total road mileage).
The data you will need are in data.zip (1.23M). There are two files in data.zip. You can also choose to download the unzipped files directly:
Both files are in ASCII format.
Each record in road.dat (that is, each line in the file) represents one segment of a road. The format of a record is as follows:
Field Name | Begin Pos. | End Pos. | Description |
---|---|---|---|
ANODE | 0 | 4 | Node ID of the beginning of the segment |
BNODE | 5 | 9 | Node ID for the end of the segment |
MILES | 10 | 15 | Length of the segment measured in miles |
SIGN / DES | 16 | end | Sign and/or description of the segment |
Note:
Some of the nodes have a string description (the name of the corresponding place in most cases); this information is provided in the file place.dat:
Field Name | Begin Pos. | End Pos. | Description |
---|---|---|---|
NODE_ID | 0 | 4 | ID of the node |
DES | 5 | end | Description/name of the node |
Note:
Since this is the last programming assignment, you get to design the data structure on your own. Mapping a real world problem to the right representation is a very important part of programming. With the information given to you, you should decide on the right data structure for the graph, and you should implement Dijkstra's algorithm to find the shortest path (so that the sum of the "miles" of all the segments on the resulting path is smallest). You need to choose the right data structure for the priority queue. (Just make a decision between using an array or a binary heap.) For a dataset with smaller size, it might not make a big difference, but for this one, if you use the right thing, you get an answer quickly (or, in a reasonable amount of time) while if you choose unwisely, you will have to WAIT (and lose points!).
Just make your choice between BFS and DFS. (Yes, there's actually more than one connected component, since we have Hawaii and Alaska in this network.) One additional piece information I can give you is that the biggest connected component has around 91000 nodes although the graph is relatively sparse. This turns out to matter when it comes to choosing between BFS and DFS. (Try them both out and you should be able to see the difference...)
From "NYITHACA C-W" to "NYSYRACUSE ENE":
0: 55021 - 55031 0.3 mi STATE ST
1: 55031 - 55030 0.1 mi STATE ST
2: 55030 - 55033 0.09 mi S13 MEADOW ST
3: 55033 - 55028 0.76 mi GREEN ST
4: 55028 - 55035 0.44 mi STATE ST
5: 55035 - 55007 1.57 mi RYDEN RD
6: 55007 - 54977 1.98 mi RYDEN RD
7: 54977 - 54975 0.05 mi RYDEN RD
8: 54975 - 54952 1.07 mi S366
9: 54952 - 54934 1.18 mi S13 RYDEN RD
10: 54934 - 54915 4.71 mi S13 RYDEN RD
11: 54915 - 54897 0.53 mi S13
12: 54897 - 54842 3.56 mi S13
13: 54842 - 54774 3.49 mi S13
14: 54774 - 54731 1.65 mi S281
15: 54731 - 54715 0.48 mi S281
16: 54715 - 54706 0.64 mi S281
17: 54706 - 54665 1.04 mi S281
18: 54665 - 54649 0.46 mi S281
19: 54649 - 54613 0.76 mi S281
20: 54613 - 54367 7.73 mi S281
21: 54367 - 54268 2.27 mi I81 ORTH-SOUTH EXWY
22: 54268 - 54206 1.48 mi I81 ORTH-SOUTH EXWY
23: 54206 - 53948 6.64 mi I81 ORTH-SOUTH EXWY
24: 53948 - 53694 4.95 mi I81 ORTH-SOUTH EXWY
25: 53694 - 53619 2.06 mi I81 ORTH-SOUTH EXWY
26: 53619 - 53554 1.02 mi I81 ORTH-SOUTH EXWY
27: 53554 - 53528 0.28 mi I81 ORTH-SOUTH EXWY
28: 53528 - 53416 5.04 mi I481
29: 53416 - 53283 1.73 mi I481
30: 53283 - 53261 0.43 mi I481
31: 53261 - 53185 1.0 mi I481
32: 53185 - 53075 1.2 mi I481
Distance: 60.690002 miles.
The programming part shouldn't be too hard, but the relations might seem a bit complicated at first. If you start off on the wrong side, it might be time-consuming...so START EARLY!!
Write-up - 30%
Code - 70%
* Bo will the point person for this assignment.