Dijkstra's algorithm: Difference between revisions

m
removed bragging
m (removed bragging)
Line 2,150:
=={{header|Phix}}==
I didn't really copy any other code/pseudocode, just followed the basic concept of (update costs) (select lowest cost unvisited) until target reached.<br>
Apart from the one glaring slipup (left in), and the original not coping at all with the "no path" case, it pretty much worked fine first time.<br>
Selects the shortest path from A to B only. As for time complexity, it looks plenty efficient enough to me, though it clearly is O(V^2).<br>
Written after the task was changed to be a directed graph, and shows the correct solution for that.
Line 2,214 ⟶ 2,213:
end for
if visited[start] then return -1 end if
-- if start=finish then return {backtrack(finish,start),cost[finish]} end if (oops, me clobbered start...)
if start=finish then return cost[finish] end if
end while
7,818

edits