小型但可扩展的寻路库
pypaths的Python项目详细描述
pypaths是一个小库,可用于计算内存中简单图的路径。使用pip安装即可试用:
> pip install pypaths
或者,也可以从源安装:
> git clone https://github.com/jonathanhood/pypaths.git > cd pypaths > python setup.py install
对于最简单的默认情况,用法非常简单:
frompypathsimportastarfinder=astar.pathfinder()printfinder((0,0),(2,2))
我们还可以提供一些参数来帮助算法理解您的特定图形:
frompypathsimportastarfinder=astar.pathfinder(distance=my_distance_function,# Calculate the absolute distance between two nodescost=my_cost_function,# Calculate the heuristic cost between nodesneighbors=my_neighbors_function)# Calculate the list of neighbors for a given nodeprintfinder("MY NODE 1","MY NODE 3")