function ASP=avg_short_path(M)
%function ASP=avg_short_path(M) calculates the average short path in the graph.
% M(n,n) - adj matrix of a graph.
%!!!This function needed Diikstra algorithm diik(Matr,i,j) in a file diik.h

% ============= Input data validation ==================
if nargin<1,
  error('There are no input data!')
end
sz=size(M);
if sz(1) ~= sz(2),
    error('Matrix should be square!')
end
n=sz(1);% n - размерность матрицы (dimmension of the matrix)
%============== Calculations ==================
%[m,n,E]=mat2list(M);
%ShP=ones(n,n)*inf;
%for i=1:n
%    for j=1:n
%        ShP(i,j)=dijk(M,i,j);%use Diikstra algorythm to find the shortest path (dijk.m)
%    end
%end
ShP=F
sz=size(ShP);
ni=sz(1);
nj=sz(2);
s=0;
for i=1:ni,
    for j=1:nj,
        s=s+ShP(i,j);%Sum of all the lenghts
    end
end
ASP=s/(ni*nj);%Average value
end
