dijksrtas(algorithm)
Mon Nov 18 2024 15:17:34 GMT+0000 (Coordinated Universal Time)
Saved by
@wtlab
ShortestPaths(v, cost, dist, n)
{
for i = 1 to n do
{
S[i] = false
dist[i] = cost[v, i]
}
S[v] = true
dist[v] = 0.0
for num = 2 to n - 1 do
{
Choose u from vertices not in S such that dist[u] is minimum
S[u] = true
for each w adjacent to u with S[w] = false do
{
if (dist[w] > dist[u] + cost[u, w]) then
dist[w] = dist[u] + cost[u, w]
}
}
}
content_copyCOPY
Comments