Closed fengxiaohu closed 4 years ago
I believe it's correct as is. A vertex is not reachable from s if and only if both edgeTo[v] = null and distTo[v] = infinity. So, if edgeTo[v] is null but distTo[v] is finite, something went wrong.
Got it,thank you very much
I am confusing about the judgement of consitency of edgeTo[v] and distTo[v] Here is the code:
I think
if (edgeTo[v] == null && distTo[v] != Double.POSITIVE_INFINITY)
should beif (edgeTo[v] == null && distTo[v] == Double.POSITIVE_INFINITY)