From a5ae8a7fdf3f78f32aa841f88cf851663b6afb15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Sun, 29 Aug 2021 22:33:42 +0200 Subject: [PATCH] Set dists[s] to zero --- src/a_star.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/a_star.jl b/src/a_star.jl index cb5810f..0efd4f2 100644 --- a/src/a_star.jl +++ b/src/a_star.jl @@ -60,8 +60,11 @@ function a_star_algorithm(g::LightGraphs.AbstractGraph{U}, # the g nvg = nv(g) checkbounds(distmx, Base.OneTo(nvg), Base.OneTo(nvg)) frontier = DataStructures.PriorityQueue{U,T}() + # The value should be `heuristic(s, t)` but it does not matter since it will + # be `dequeue!`d in the first iteration independently of the value. frontier[U(s)] = zero(T) dists = fill(typemax(T), nvg) + dists[s] = zero(T) parents = zeros(U, nvg) colormap = zeros(UInt8, nvg) colormap[s] = 1