Corrected: Link State (LS) Algorithm:
1 Initialization:
2 N = {A}
3 for all nodes v
4 if v adjacent to A then
5 Dist(v) = c(A,v)
NEW Prev(v) = A
6 else D(v) = infinity
7
8 Loop
9 find w not in N such that D(w) is a minimum
10 add w to N
NEW Update Previous of v if new path is shorter:
NEW if Dist(w) + c (w,v) < Dist(v) then
NEW Prev(v) = w
NEW end if
11 update D(v) for all v adjacent to w and not in N:
12 D(v) = min( D(v), D(w) + c(w,v) )
13 /* new cost to v is either old cost to v or known
14 shortest path cost to w plus cost from w to v */
15 until all nodes in N