function B = to_mat(A, frac)
n = size(A,1);
I = triu(ones(n),1)==1;
val = A(I(:));
[v, I] = sort(val);
%indx=max(find(v,1,'first'),round(length(v)*frac));
indx=round(length(v)*(frac));
B = A > v(indx);
B = B - diag(diag(B));
end