Dijkstra's algorithm: Difference between revisions

Content added Content deleted
Line 3,323: Line 3,323:
.
.
read
read
#
#
len cost[] n
len cost[] n
len prev[] n
len prev[] n
#
#
proc dijkstra . .
proc dijkstra . .
for i = 2 to len cost[]
for i = 2 to len cost[]
Line 3,356: Line 3,356:
.
.
dijkstra
dijkstra
#
#
func$ gpath nd$ .
func$ gpath nd$ .
nd = strcode nd$ - 96
nd = strcode nd$ - 96
while nd <> 1
while nd <> 1
s$ = " -> " & strchar nd + 96 & s$
s$ = " -> " & strchar (nd + 96) & s$
nd = prev[nd]
nd = prev[nd]
.
.
Line 3,367: Line 3,367:
print gpath "e"
print gpath "e"
print gpath "f"
print gpath "f"
#
#
input_data
input_data
a b 7
a b 7