Skip to content

Commit

Permalink
Define nvg earlier to cover two more uses (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Aug 29, 2021
1 parent 87ce7e4 commit 456ab87
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/a_star.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ function a_star_algorithm(g::LightGraphs.AbstractGraph{U}, # the g
t::Integer, # the end vertex
distmx::AbstractMatrix{T}=LightGraphs.weights(g),
heuristic::Function = (u,v) -> zero(T)) where {T, U}
checkbounds(distmx, Base.OneTo(nv(g)), Base.OneTo(nv(g)))
nvg = nv(g)
checkbounds(distmx, Base.OneTo(nvg), Base.OneTo(nvg))
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)
Expand Down Expand Up @@ -111,4 +111,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 456ab87

Please sign in to comment.