Dijkstra's algorithm: Difference between revisions

Content added Content deleted
(→‎{{header|Tailspin}}: Update to stricter typing)
(→‎{{header|Tailspin}}: Update to stricter typing)
Line 5,615: Line 5,615:
templates shortestPaths&{graph:}
templates shortestPaths&{graph:}
@: {||};
@: {||};
{| {to: $, distance: 0, path:[]} |} -> #
{| {to: $, distance: 0"1", path:[]} |} -> #
when <?($::count <=0>)> do $@ !
when <?($::count <=0>)> do $@ !
otherwise
otherwise
Line 5,628: Line 5,628:


def edges: {|
def edges: {|
{ from: 'a', to: 'b', cost: 7 },
{ from: 'a', to: 'b', cost: 7"1" },
{ from: 'a', to: 'c', cost: 9 },
{ from: 'a', to: 'c', cost: 9"1" },
{ from: 'a', to: 'f', cost: 14 },
{ from: 'a', to: 'f', cost: 14"1" },
{ from: 'b', to: 'c', cost: 10 },
{ from: 'b', to: 'c', cost: 10"1" },
{ from: 'b', to: 'd', cost: 15 },
{ from: 'b', to: 'd', cost: 15"1" },
{ from: 'c', to: 'd', cost: 11 },
{ from: 'c', to: 'd', cost: 11"1" },
{ from: 'c', to: 'f', cost: 2 },
{ from: 'c', to: 'f', cost: 2"1" },
{ from: 'd', to: 'e', cost: 6 },
{ from: 'd', to: 'e', cost: 6"1" },
{ from: 'e', to: 'f', cost: 9 }
{ from: 'e', to: 'f', cost: 9"1" }
|};
|};