本文整理汇总了Python中Graph.generateGraph方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.generateGraph方法的具体用法?Python Graph.generateGraph怎么用?Python Graph.generateGraph使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph.generateGraph方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testStepDistance
# 需要导入模块: import Graph [as 别名]
# 或者: from Graph import generateGraph [as 别名]
def testStepDistance(location, connection):
graph = Graph.generateGraph(location,connection)
for start in graph:
for end in graph:
if start != end:
assert(start.name != end.name)
foo = AStar.AStarDistance(graph,start, end).runStepByStep()
#print '({0},{1})'.format(start.name, end.name)
for each in foo:
pass
示例2: testNoneStopDistance
# 需要导入模块: import Graph [as 别名]
# 或者: from Graph import generateGraph [as 别名]
def testNoneStopDistance(location, connection):
graph = Graph.generateGraph(location,connection)
for start in graph:
for end in graph:
if start != end:
assert(start.name != end.name)
try:
result = AStar.AStarDistance(graph,start, end).runNoneStop()
#print '({0},{1})'.format(start.name, end.name),
except BaseException, e:
print
print str(e)
print '>>>Error: start {0}, end {0}'.format(start.name, end.name)
示例3: OnLoad
# 需要导入模块: import Graph [as 别名]
# 或者: from Graph import generateGraph [as 别名]
def OnLoad(self,evt):
# if not points location file or connection file
if self.cityPath == None or self.connectPath == None:
dlg = wx.MessageDialog(self.frame, 'Please choose city file and connection file',
'File Error!',
wx.OK | wx.ICON_INFORMATION
)
dlg.ShowModal()
dlg.Destroy()
return
#if self.citys != None:
# print '- '.join([each.name for each in self.citys])
#generate citys graph
self.citys = Graph.generateGraph(self.cityPath, self.connectPath)
#print '= '.join([each.name for each in self.citys])
#if file invalid
if self.citys == None:
dlg = wx.MessageDialog(self.frame, 'Chosen Files contain invalid value!',
'File Error!',
wx.OK | wx.ICON_INFORMATION
)
dlg.ShowModal()
dlg.Destroy()
return
self.isStepStarted = False
self.isResultValid = False
self.dragCity = None
self.dragPos = (-1,-1)
self.txtOutput.WriteText("Load Successfully\n")
self.SetChoice() # set items to start,city and delete city controls
x,y = self.calcVirtualSize() # calculate canvas size
self.pnlMain.SetVirtualSize((x,y)) # set canvas size
#self.pnlMain.SetScrollRate(10,10)
self.isLoad = True
#self.draw()
self.OnPaint(None)