Skip to content

Commit

Permalink
Remove visited as the info is in colormap
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Aug 28, 2021
1 parent 0dcc84d commit 3549fec
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/a_star.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ function a_star_algorithm(g::LightGraphs.AbstractGraph{U}, # the g
frontier = DataStructures.PriorityQueue{Tuple{T, U},T}()
frontier[(zero(T), U(s))] = zero(T)
nvg = nv(g)
visited = zeros(Bool, nvg)
dists = fill(typemax(T), nvg)
parents = zeros(U, nvg)
colormap = zeros(UInt8, nvg)
Expand All @@ -70,12 +69,12 @@ function a_star_algorithm(g::LightGraphs.AbstractGraph{U}, # the g
(cost_so_far, u) = dequeue!(frontier)
u == t && (return OpenStreetMapX.extract_a_star_route(parents,s,u), cost_so_far)
for v in LightGraphs.outneighbors(g, u)
if get(colormap, v, 0) < 2
col = get(colormap, v, UInt8(0))
if col < UInt8(2)
dist = distmx[u, v]
colormap[v] = 1
path_cost = cost_so_far + dist
if !visited[v]
visited[v] = true
if iszero(col)
parents[v] = u
dists[v] = path_cost
enqueue!(frontier,
Expand Down Expand Up @@ -111,4 +110,4 @@ function a_star_algorithm(m::MapData,
t::Integer)
heuristic(u,v) = OpenStreetMapX.get_distance(u, v, m.nodes, m.n)
OpenStreetMapX.a_star_algorithm(m.g,s,t,m.w,heuristic)
end
end

0 comments on commit 3549fec

Please sign in to comment.