Content deleted Content added
m Archiving 2 discussion(s) to Talk:Floyd–Warshall algorithm/Archive 1) (bot |
→Pseudocode contains end-ifs but no end-fors: new section |
||
Line 173:
I am new to wikipedia authoring, but whether or not the article is clear the pseudo-code is incorrect. On line 9 there is a > symbol where there should be a < symbol. Being new I thought I would talk about it on this page before diving in and correcting it
[[User:Philsrice|Philsrice]] ([[User talk:Philsrice|talk]]) 08:28, 14 August 2015 (UTC)
== Pseudocode contains end-ifs but no end-fors ==
The pseudocode contains end-ifs but no end-fors:
I think it makes sense to have it be consistent:
either
no end-fors and no end-ifs
or
every for-loop terminated with an end-for and every if-statement terminated with end-if
1 '''let''' dist be a |V| × |V| array of minimum distances initialized to ∞ (infinity)
2 '''for each''' edge (''u'',''v'')
3 dist[''u''][''v''] ← w(''u'',''v'') ''// the weight of the edge (''u'',''v'')
4 '''for each''' vertex ''v''
5 dist[''v''][''v''] ← 0
6 '''for''' ''k'' '''from''' 1 '''to''' |V|
7 '''for''' ''i'' '''from''' 1 '''to''' |V|
8 '''for''' ''j'' '''from''' 1 '''to''' |V|
9 '''if''' dist[''i''][''j''] > dist[''i''][''k''] + dist[''k''][''j'']
10 dist[''i''][''j''] ← dist[''i''][''k''] + dist[''k''][''j'']
11 '''end if'''
|