function d=diameter(M)
%function d=diameter(M)calculates the max path path in the graph.
% M(n,n) - matrix of the short paths in 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=M;

%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
sz=size(ShP);
ni=sz(1);
nj=sz(2);
max=0;
for i=1:ni,
    for j=1:nj,
        s=ShP(i,j);
        if (s>max),max=s;
        end
    end
end
d=max;%Average value
end
