function mixc=mixing(E)
%function mixc=mixing(E) - assortativity coefficient
% M(n,n) n - number of groups
% M(i,j) - Number of contacts between groops i and j

% ============= Input data validation ==================
if nargin<1,
  error('There are no input data!')
end
sz=size(E);
if sz(1) ~= sz(2),
    error('Matrix should be square!')
end
n=sz(1);
%============ Calculations ============
mixc=(trace(E)-norm(E*E))/(1-norm(E*E))