Icon representing a recipe

Recipe: TESTCATTRAP

created by Vincera

Profile


Name
TESTCATTRAP
ID
105257
Shared with
Public
Parent
None
Children
None
Created on
October 06, 2021 at 22:10 PM UTC
Updated on
December 30, 2024 at 19:30 PM UTC
Description

...

Best for


Code


1 function Dijkstra(Graph, source): 2 dist[source] ? 0 3 4 create vertex priority queue Q 5 6 for each vertex v in Graph: 7 if v ? source 8 dist[v] ? INFINITY 9 prev[v] ? UNDEFINED 10 11 Q.add_with_priority(v, dist[v]) 12 13 14 while Q is not empty: 15 u ? Q.extract_min() 16 for each neighbor v of u: 17 alt ? dist[u] + length(u, v) 18 if alt < dist[v] 19 dist[v] ? alt 20 prev[v] ? u 21 Q.decrease_priority(v, alt) 22 23 return dist, prev

Comments