Computer Science 385
Design and Analysis of Algorithms
Spring 2018, Siena College
We will be studying many graph algorithms this semester, some of which you will be implementing in Java. For many of these tasks, you will be working with real-world data sets derived from highway systems.
A big advantage of working with this kind of data is that it has a connection to reality, and that we can visualize the data and the results of our manipulations of that data with the Google Maps API. This data is collected by members of the Travel Mapping (TM) Project (http://tm.teresco.org/). The Map-based Educational Tools for Algorithm Learning (METAL) Project (/metal/) uses data from the TM project and converts it into a format that is more convenient for us to load into a graph structure and use. Much more about the project is available at the link above, but everything you need to know for this week should be in this document.
You will be assigned a partner to work with on this lab. Only one submission per group is needed.
Learning goals:
Getting Set Up
You will receive an email with the link to follow to set up your GitHub repository, which will be named metalintro-lab-yourgitname, for this Lab. One member of the group should follow the link to set up the repository on GitHub, then that person should email the instructor with the other group members' GitHub usernames so they can be granted access. This will allow all members of the group to clone the repository and commit and push changes to the origin on GitHub.
The Graph Data
METAL provides hundreds of graph files that can be used to explore data structures and algorithms. They range in size from just a few to hundreds of thousands of vertices and edges. We can use the small graphs for tracing algorithms (or debugging code) by hand, medium-sized graphs for testing during implementation, and large graphs to help analyze the efficiency of algorithms and our implementations of them.
All graphs are linked from http://tm.teresco.org/graphs/.
The graph data comes in two formats, simple and collapsed, which are described in detail at /metal/graph-formats.shtml. We will use the collapsed format graphs. For this first set of questions, please refer to the NY-region.tmg graph, which is included in your starter repository.
Reading the Graph into a Java Program
We need a graph data structure that can be used to store this graph data. In class we have seen that graphs can be stored in either an adjacency matrix or an adjacency list structure, and the graph's edges can either be directed or undirected.
In addition to the topological information we already considered in class, here we will need to store more information with the vertices (label and coordinates) and edges (road names, list of intermediate points).
Study the code that reads in the graph data files (the HighwayGraph constructor), and the toString method that prints it out.
Run the program's main method, passing in the DC-region.tmg graph (provided in your starter repository) as its command-line parameter. Compare the output of the program with the TMG file and be sure you understand how the contents of the data structure correspond to the contents of the file.
Expanding the Program's Functionality
Your programming tasks involve expanding the functionality of the HighwayGraph class. Do not modify the code that constructs the graph to accomplish these tasks.
Vertex Search
The first task is to perform a search of the graph vertices to find the "extreme" vertices: those are at the northernmost, southernmost, easternmost, and westernmost locations. For each, report the vertex label and its latitude/longitude pair. Also, find the vertices that have the shortest and longest labels. For these, you need only report the label. You may handle ties in any reasonable manner.
Before you start coding, watch a visualization of this process on a METAL graph loaded in HDX. Load a small to medium size graph into HDX (DC-region.tmg is a good choice, which you can either upload from your repository, or find within HDX by choosing "Routes Within a Single Region" before pressing the "Get Graph List" button). Then select "Vertex Extremes Search" from the "Algorithm Selection" and choose "Pretty Slow" for the simulation speed. Press "Start" and watch as the algorithm searches for the extreme points and shortest and longest labels.
Edge Search
Your second task is to perform a search of the graph edges to find the edges with the shortest and longest length. You will likely want to model your loop structure to traverse the edges in the graph after the one in the toString method.
Submitting
Once all written items are initialed to indicate completion, turn in one copy of this handout. Be sure names of all group members are clearly on the first page.
Your submission also requires that your code is committed and pushed to the master for your repository's origin on GitHub. If you see everything you intend to submit when you visit your repository's page on GitHub, you're set.