Dijkstra algorithm
When edges have weights, the path with the fewest edges isn't always the cheapest. Dijkstra always takes the cheapest vertex found so far: a priority queue holds (node, cost) pairs and poll() hands back the cheapest. When that vertex is processed, its cost is final.
result holds the cheapest cost found so far for each vertex (∞ until one is found), visited the vertices whose cost is final. For each edge of the polled vertex, insert the neighbour when processNode.cost + edge.weight < result[adjNode]. The text beside a vertex is that check. A vertex can be inserted twice; the older pair (red) is skipped because the vertex is already visited.