# StateGraph.py from MapState import * from Search import * def main(): us = Map() win = GraphWin(us.getName(), 1000, 750) win.setCoords(0, us.getHeight()-1, us.getWidth()-1, 0) win.setBackground("white") print "The map of US has been created." print "It has", len(us.getStates()), "states." for state in us.getStates(): us.getState(state).drawState(win, 'white') # read population data f = open("stateGraph.txt") fcontents = f.read().split('\n') for line in fcontents: if len(line) > 1: nbrs = line.split(',') state = nbrs.pop(0) #print state, nbrs if us.hasState(state): s = us.getState(state) s.nbrs = [] for n in nbrs: s.nbrs.append(us.getState(n)) print "Done reading neighbors..." start = "Washington" end = "Maryland" print "Searching path from %1s to %1s" % (us.getState(start).getName(), us.getState(end).getName()) UniformCost(us.getState(start), us.getState(end)) main()