% script to fin diameter of a
% graph. Graph should be given
% as an adjancy matrix

function d=diameter(G)
V=size(G,1);
H=zeros(V);
for k=1:V
H=H+G^k;
if min(min(H))>0
break;
end
end % for k
d=k;
return