Tracing the Route
Dijkstra gives the cost of the best route. To show the route itself, use the same trick as with BFS: remember where each node was reached from.
One more map
Whenever Dijkstra finds a cheaper way to a node, it records both the new cost and the node it came from:
if old, seen := best[e.To]; !seen || m < old {
best[e.To] = m
from[e.To] = cur.place
heap.Push(q, visit{e.To, m})
}
A node can be improved several times before it's settled, and each time from is overwritten. That's what you want: when the search ends, from holds the last improvement, which belongs to the best route.
Walking back and turning around
Follow from from the goal to the start, collecting the nodes, then reverse the slice:
route := []string{goal}
for p := goal; p != start; p = from[p] {
route = append(route, from[p])
}
slices.Reverse(route)
Reversing by hand is a short loop too: swap the first and last, then move both indexes inwards until they meet.
As with BFS, check first that the goal was reached at all. If it wasn't, from[goal] is the empty string and the loop never finds the start.
Ties
When two routes cost exactly the same, which one Dijkstra keeps depends on the order of the edges and of the heap. This lesson's map has a single best route, so every correct program prints the same answer. Puzzles that care about ties say how to break them.
Task
This lesson's input starts with a line route <from> <to>, followed by roads with their minutes. Roads go both ways. The queue type and the parsing are ready.
Print the best route as the places joined by ->, then a line with the total, such as 22 minutes. The output must match the expected output exactly.