def generate_graph(self): """Generates the graph using GraphWorld. """ grapher = BestPath(self.ichose) # create a BestPath object, using chosen cities grapher.set_map(self.graph) # set the map read from the database # generate a Tour by calling the generate_actualtour method of BetPath Class Tour = grapher.genrate_actualtour(Vertex(self.ichose[0])) layout = CircleLayout(Tour) gw = GraphWorld() gw.show_graph(Tour, layout) gw.mainloop()
def main(): read = ReadMap() read.read_file("test.map") print read.names grapher = BestPath(read.names[:5]) grapher.set_map(read.graph) bestTour = grapher.genrate_actualtour(Vertex(read.names[4])) print bestTour newGraph = Graph(bestTour.items) for i in range(len(bestTour.items) - 1): newEdge = Edge(bestTour.items[i], bestTour.items[i + 1]) newGraph.add_edge(newEdge) layout = RandomLayout(newGraph) # draw the graph gw = GraphWorld() gw.show_graph(newGraph, layout) gw.mainloop()