当前位置: 首页>>代码示例>>Python>>正文


Python Graph.findNearestNode方法代码示例

本文整理汇总了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}
开发者ID:SummerZheng,项目名称:iRun_YN,代码行数:30,代码来源:TestPath.py

示例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']}
开发者ID:SummerZheng,项目名称:iRun_YN,代码行数:30,代码来源:TestPath2.py


注:本文中的Graph.Graph.findNearestNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。