for k:=1 to n do for i:=1 to n do if i<>k then for j:=1 to n do if j<>k then if ut[i,j]>ut[i,k]+ut[k,j] then begin ut[i,j]:=ut[i,k]+ut[k,j]; for l:=1 to n do cs[i,j][l]:=(cs[i,k][l]) or (cs[k,j][l]); end else if ut[i,j]=ut[i,j]+ut[k,j] then for l:=1 to n do cs[i,j][l]:=(cs[i,j][l]) or (cs[k,j][l]);