Пример #1
0
        print "Time taken: " +str(time.time()-startTimeA)
        vrtInfo=graph.getVertex(vrtx[2])
        print "Total cost: " +str(vrtInfo[4])
        pathFound=True
        
    if(pathFound==True):
        break

    #mark vertex as closed
    VertexInfo=graph.getVertex(vrtx[2])
    VertexInfo[2]=0
    graph.setVertex(vrtx[2], VertexInfo)

    #get the neighbors
    ngbrs=[]
    ngbrs=graph.neighbourOf(vrtx[2])
    #print "neighbors: " + str(ngbrs)
    #loop through neighbors
    for i in range (len(ngbrs)):
        checkNeighbor=graph.getVertex(ngbrs[i])
        if(checkNeighbor[2]==1):
            if(checkNeighbor[3]==0):
                pathCost[ngbrs[i]]=1000000000
                parent[ngbrs[i]]=-1
            cpyFringe=fringe
            fringe=UpdateVertex(vrtx[2],ngbrs[i], cpyFringe)

if(pathFound!=True):
    print "A* did not find path!"

#-------------------------------------------------------------