Shortest Paths on a DAG
In short: on a directed acyclic graph (DAG) — where legs only ever point "forward", with no way back to a stop already visited — one sweep in topological order finds every cheapest cost, even with negative edges, in O(V + E). Process stops in an order where every leg into a stop comes from an earlier stop, and by the time you reach a stop every leg that could lower its cost has already run. No heap, no settling order to argue about: the order itself is the proof.

Meridian has a model of the city. This section routes things through it and builds the router, starting with the night timetable. After midnight, shuttles run between depots on fixed times, and time only moves forward, so no chain of shuttles can bring you back to where you started. The timetable is a directed acyclic graph, a DAG.
The twist: some legs carry return freight that Meridian is paid for, so on the books they have a negative cost, a credit. You saw a negative edge fool Dijkstra in the graphs section. On a DAG you don't need Dijkstra at all: one sweep through the stops, in the right order, finds every cheapest cost, credits included, in O(V + E).
Where Dijkstra goes wrong
Dijkstra settles the cheapest unsettled stop and never looks at it again. The promise behind that is "nothing found later can be cheaper", and a credit breaks it. Here the mill is settled at 2, but the route through the quay reaches it for 5 − 4 = 1:
import heapq
legs = {"depot": [("mill", 2), ("quay", 5)], "quay": [("mill", -4)],
"mill": [("harbour", 3)], "harbour": []}
settled = set()
best = {"depot": 0}
heap = [(0, "depot")]
while heap:
cost, stop = heapq.heappop(heap)
if stop in settled:
continue
settled.add(stop)
for nxt, step in legs[stop]:
if nxt not in settled and cost + step < best.get(nxt, float("inf")):
best[nxt] = cost + step
heapq.heappush(heap, (cost + step, nxt))
print(best["harbour"])Dijkstra guessed which stop was final from costs. With no cycles there is a better source of truth: the order of the stops.