@@ -94,25 +94,30 @@ pub enum DijkstraEvent<N, E, K> {
9494/// appropriate method.
9595///
9696/// ```norust
97- /// DIJKSTRA(G, source, weight)
98- /// for each vertex u in V
99- /// d[u] := infinity
100- /// p[u] := u
101- /// end for
102- /// d[source] := 0
103- /// INSERT(Q, source)
104- /// while (Q != Ø)
105- /// u := EXTRACT-MIN(Q) discover vertex u
106- /// for each vertex v in Adj[u] examine edge (u,v)
107- /// if (weight[(u,v)] + d[u] < d[v]) edge (u,v) relaxed
108- /// d[v] := weight[(u,v)] + d[u]
109- /// p[v] := u
110- /// DECREASE-KEY(Q, v)
111- /// else edge (u,v) not relaxed
112- /// ...
113- /// if (d[v] was originally infinity)
114- /// INSERT(Q, v)
115- /// end for finish vertex u
97+ /// // G - graph, s - single source node, weight - edge cost function
98+ /// DIJKSTRA(G, s, weight)
99+ /// let score be empty mapping
100+ /// let visited be empty set
101+ /// let Q be a priority queue
102+ /// score[s] := DEFAULT_COST
103+ /// PUSH(Q, (score[s], s)) // only score determines the priority
104+ /// while Q is not empty
105+ /// cost, u := POP-MIN(Q)
106+ /// if u in visited
107+ /// continue
108+ /// PUT(visited, u) // event: Discover(u, cost)
109+ /// for each _, v, w in OutEdges(G, u) // v - target vertex, w - edge weight
110+ /// ... // event: ExamineEdge(u, v, w)
111+ /// if v in visited
112+ /// continue
113+ /// next_cost = cost + weight(w)
114+ /// if {(v is key in score)
115+ /// and (score[v] <= next_cost)} // event: EdgeNotRelaxed(u, v, w)
116+ /// ...
117+ /// else: // v not scored or scored higher
118+ /// score[v] = next_cost // event: EdgeRelaxed(u, v, w)
119+ /// PUSH(Q, (next_cost, v))
120+ /// end for // event: Finish(u)
116121/// end while
117122/// ```
118123///
0 commit comments