Dijkstra 用来求图的单源最短路。它基于 BFS。时间复杂度为 $O(n \log{n} + m)$
初始化 $dis(r)$ 为 $0$
对于源 $r$ 和每个节点 $p$ 及其 BFS 的节点集合 $d_i$,有如下过程: