On the Wikipedia page for Dijkstra's algorithm, they mark visited nodes so they wouldn't be added to the queue again. However, if a node is visited then there can be no distance to that node that is shorter, so doesn't the check alt < dist[v]
already account for visited nodes? Am I misunderstanding something about the visited set?
for each neighbor v of u:
alt := dist[u] + dist_between(u, v); // accumulate shortest dist from source
if alt < dist[v] && !visited[v]:
dist[v] := alt; // keep the shortest dist from src to v
previous[v] := u;
insert v into Q; // Add unvisited v into the Q to be processed
end if
end for