本文整理汇总了Python中Graph.Graph.findNearestNode方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.findNearestNode方法的具体用法?Python Graph.findNearestNode怎么用?Python Graph.findNearestNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph.Graph
的用法示例。
在下文中一共展示了Graph.findNearestNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PathTestMashUp
# 需要导入模块: from Graph import Graph [as 别名]
# 或者: from Graph.Graph import findNearestNode [as 别名]
def PathTestMashUp(startPt, endPt, runDis, ):
startCor = GeoCode(startPt);
endCor = GeoCode(endPt)
miniGraph = Graph()
bounds = createMiniWorld(miniGraph, startCor, endCor)
startNode = [0, 0]
dist = miniGraph.findNearestNode(startCor, startNode)
print 'the closest node found to startPt is '+ str(startNode) +', with dist '+str(dist)
endNode = [0, 0]
dist = miniGraph.findNearestNode(endCor, endNode)
print 'the closest node found to endPt is '+str(endNode) +', with dist '+str(dist)
startNode = cor2ID(startNode)
endNode = cor2ID(endNode)
K=5
pathDict = miniGraph.findPath(startNode, endNode, runDis, K)
for k in range(0, K):
print 'The actual path dis is '+ str(pathDict[k]['cost'])
#print pathDict[k]['path']
return {'miniGraph': miniGraph,
'startPt':startCor,
'endPt':endCor,
'startNode':startNode,
'endNode':endNode,
'pathDict':pathDict}
示例2: PathTestMashUp
# 需要导入模块: from Graph import Graph [as 别名]
# 或者: from Graph.Graph import findNearestNode [as 别名]
def PathTestMashUp(startPt, endPt, targetDis):
startCor = GeoCode(startPt);
endCor = GeoCode(endPt)
miniGraph = Graph()
bounds = createMiniWorld(miniGraph, startCor, endCor)
startNode = [0, 0]
dist = miniGraph.findNearestNode(startCor, startNode)
print 'the closest node found to startPt is '+ str(startNode) +', with dist '+str(dist)
endNode = [0, 0]
dist = miniGraph.findNearestNode(endCor, endNode)
print 'the closest node found to endPt is '+str(endNode) +', with dist '+str(dist)
startNode = cor2ID(startNode)
endNode = cor2ID(endNode)
myPath = miniGraph.MonteCarloBestPath(startNode, endNode, targetDis)
print 'The actual path dis is '+ str(myPath['dist'])
return {'miniGraph': miniGraph,
'startPt':startCor,
'endPt':endCor,
'startNode':startNode,
'endNode':endNode,
'dist': myPath['dist'],
'path': myPath['path']}