Important: you do not need to display any of this on the Visualizer.
Important: this extra-credit may cause significant load on the IWS machines. Please nice your programs (talk to us or lab staff for more details).
For this extra credit, find out how many miles of cable it would take to wire all towns of population at least 10,000 people in Washington state (that should be about 100 points). Here's a Dr. Math link that may be useful in figuring out the distance between two cities from their latitude and longitude.
For the more ambitious, wire the entire US! Use data from the Census site mentioned above. The interesting thing to look at is the performance of your algorithm. How does it scale up from just Washington state? How did you expect it to scale up? Did it even finish in a reasonable amount of time? (I haven't tried this, myself; You may need to change the population cut-off) Perhaps profile your program with gprof. More extra-credit will be given for implementing heuristic optimizations and discussing them (e.g., do you really need to consider the edge between Boston and Seattle? does your performance improve if you ignore those edges, or does culling them take more time than you save?).
The Visualizer displays objects. Objects have a label and a color. The types of objects you're interested in are Nodes and Edges, which should be used for vertices and edges, respectively. An object is referred to by its id.
A node is created with a position, and an edge is created with its node end points. Positions are given as double-precision floating-point numbers between 0 and 1, with (0,0) being the top-left of the Visualizer window, and (1,1) the bottom-right.
Colors are specified by the SimpleColor enumeration. Examples of colors are eBlack, eRed and eYellow. The primary colors are there, but not much else.
You will probably never need to change the label of any object after creation. Labels are represented internally as strings. There are Svr... functions that set labels to numbers; these work by translating the numbers to a string.
If you right-click in the Visualizer window, you'll get a menu that will allow you to immediately exit the program, and that will print out a list of all the objects the Visualizer knows about. This may be useful during debugging. The list will appear on the stderr of your original program.
Specifics can be found in the header files common.h and client.h, located in the course include/ directory.
Vertex count List of vertices List of edgesThere are count lines in the list of vertices. Each vertex line has the format
n vertex-num x yHere n is the literal character 'n', vertex-num is an integer that is the vertex number, and x and y are double-precision floating-point positions, in the range 0..1 (that is, just what the Visualizer takes).
The vertex numbers should appear consecutively from 0 to count-1; that is, they must appear in order. I designed it this way to make it easy to catch input errors, although in retrospect it seems like overkill.
Each edge line has the format
src dst weightHere src and dst are the end points of the edge (of course, as the graph is undirected, there's really no difference between the source and the destination), and weight is the weight of the edge.
The program wgraph in the course directory reads and displays graphs of this format. The project file for this assignment includes some sample graphs in this format and some sample code for reading in the files.