Project Code ----------------------------- Olex Ponomarenko >> Road Class >> Private Data x1 y1 x2 y2 - This road is from point (x1,y1) to (x2,y2) size - A number from 1 to 5 representing the road's size (type) type - A string name of the kind of road this is: such as "Residential", or "Interstate Highway" intersections - a list of all the intersections that are on the road >> Methods __init__(self, loca, locb, size): initiates the road from location a to location b of the given size __str__(self): internal Python method (such as Java .toString()) that returns the type of road this is intersection(self, road): returns the type of intersection (i.e. stop sign, traffic light, exit, no intersection) that should be placed between the two roads (the given and the active) >> Location Class >> Private Data x y - This location is situated at (x,y) name - name of the intersection coords - another way of accessing the position of the location intersection - a boolean saying if this location is an intersection of two (or more) roads or not flagged - internal method used when generating the graph to flag locations on top of each other for deletion >> Methods __init__(self, sname,scoods,sintersection): constructor that initiates a location at the coordinates with the given name and boolean __str__(self): internal Python method that returns the name as well as the position of the location setCoords(self, newx,newy): changes the position of the location, keeping roads intact distto(self, loc) returns the distance between the active and the given road (self and loc) disttopt(self, lx,ly) returns the distance between self and a given point (lx, ly) also self-explanatory helper methods getCoords(self), getx(self), gety(self), getintersection(self) >> Main Program Structure test(filename, citynamefile, scale) calls the random graph generator, creates a graph, and tests it using the inputs. The output is left in the filename, and the console output recieves messages as well. >> Random Graph Generator Primary Functions makegraph(filename, citynamefile,scale) randomly generates a graph of scale number of locations on a scale x scale grid of pixels. The citynamefile is used to name locations that are created. The graph structure is then output into filename. testconnections(graph) tests whether each node of a graph is connected to each other node (checks integrity of map) connect(graph, a, b, roadsize, roadlist, roadcounter) connects a and b with a road of size roadsize, places the road into the roadlist, and adds a counter to roadcounter makerandomroad(graph, cities, roadlist, roadcounter) creates a random road between two random points in graph, updating the cities, roadlist, and roadcounter with the new road >> Random Graph Generator Auxillary Functions closelocation(location, list, scale) Finds a location in list that is within scale /40 (within 25 pixels on a 1000 pixel board) of the given location, and returns a pointer to the location closeindex(location, list, scale) Similar, but returns the index of the location in the list