Dijkstra's algorithm: Difference between revisions

m
Line 1,590:
-- Get the current best distance for a particular vertex s.
eq currDist s nilE = inf .
eq currDist s (t :e permanent) = if ((1* t) == s) then (4* t ) else (currDist s permanent) fi .
(currDist s permanent) fi .
 
 
Line 1,597 ⟶ 1,598:
 
eq connectedList nilE s permanent = nilE .
eq connectedList (t :e graph) s permanent = if (connectedTo s permanent) then
(t :e (connectedList graph s permanent))
else (connectedList graph s permanent) fi .
 
 
eq unvisitedList nilE permanent = nilE .
eq unvisitedList (t :e graph) permanent = if not(connectedTo (2* t) permanent) then (t :e (unvisitedList graph permanent)) else (unvisitedList graph permanent) fi .
then (t :e (unvisitedList graph permanent))
else (unvisitedList graph permanent) fi .
 
 
Line 1,613 ⟶ 1,616:
vars start end : Character
eq SP start end nilE = nilP .
eq SP start end (currentTuple :e eList) = if (end == (1* currentTuple)) then (end :p (SP start (2* currentTuple) eList)) else (SP start end eList) fi .
(end :p (SP start (2* currentTuple) eList))
else (SP start end eList) fi .
 
 
101

edits