Beispiel #1
0
 def __init__(self, nodeSet, **kargs):
     kargs['node_cls'] = AStarNode
     self.dist_measure = model.check_param(kargs, 'dist_measure', "euclidean", False)
     if self.dist_measure.strip() == "": 
         self.dist_measure = "euclidean"
     nodeSet.real_distance = self.distance 
     model.SearchModel.__init__(self, nodeSet, **kargs)
Beispiel #2
0
def find_path(**kargs):
    """
       find path from begin point to end one in data map.
       searching_method: "bfs, dfs, dijkstra, astar" 
       nodeset: node map
       dist_measure: euclidean, chebyshev, manhatton
    """
    searching_method = check_param(kargs, 'searching_method', "astar")
    nodeset = check_param(kargs, 'nodeset', "astar")
    dist_measure = check_param(kargs, 'dist_measure', "", False)
    cls_tbl = {'astar': astar.AStar, 'bfs': bfs_dfs.BFS, 'dfs': bfs_dfs.DFS, 'dijkstra': dijkstra.Dijkstra }
    if searching_method not in cls_tbl:
        print "Fail to find specified searching approach!"
        return False
    cls = cls_tbl[searching_method]
    pfo = cls(nodeset, **kargs) 
    path = pfo.find_path()
    print path
    return path
Beispiel #3
0
def find_path(**kargs):
    """
       find path from begin point to end one in data map.
       searching_method: "bfs, dfs, dijkstra, astar" 
       nodeset: node map
       dist_measure: euclidean, chebyshev, manhatton
    """
    searching_method = check_param(kargs, "searching_method", "astar")
    nodeset = check_param(kargs, "nodeset", "astar")
    dist_measure = check_param(kargs, "dist_measure", "", False)
    cls_tbl = {"astar": astar.AStar, "bfs": bfs_dfs.BFS, "dfs": bfs_dfs.DFS, "dijkstra": dijkstra.Dijkstra}
    if searching_method not in cls_tbl:
        print "Fail to find specified searching approach!"
        return False
    cls = cls_tbl[searching_method]
    pfo = cls(nodeset, **kargs)
    path = pfo.find_path()
    print path
    return path