You are given a network of `n` nodes, labeled from 1 to `n`. You are also given `times`, a list of travel times as directed edges `times[i] = (u_i, v_i, w_i)`, where `u_i` is the source node, `v_i` is the target node, and `w_i` is the time it takes for a signal to travel from source to target. We will send a signal from a given node `k`. Return the minimum time it takes for all the `n` nodes to receive the signal. If it is impossible for all the `n` nodes to receive the signal, return -1.
Dijkstra's Algorithm (Shortest Path)
This is a classic 'Single Source Shortest Path' problem. Since edge weights are non-negative, Dijkstra's algorithm is ideal. We maintain a min-priority queue of `(time, node)` pairs, always visiting the node with the smallest cumulative time first. When we visit a node, we 'relax' all its neighbors by updating their shortest paths if a quicker way is found.