function [Z, H] = comp_dendro_matrix(D, fontS, lineW, gLabels)
cnt = 1;
for i=1:size(D,1),
  for j=i+1:size(D,2),
     Y(cnt) = D(i,j);
     cnt = cnt + 1;
  end
end

Z = linkage(Y);
H =dendrogram(Z,0);
if (size(H,1) >0) 
  set(get(H(1),'Parent'),'FontSize',[fontS]);
  txx=get(get(H(1),'Parent'),'XTickLabel');
  yy = gLabels;
  if size(txx,1) ~= length(yy),
    disp([sprintf('The length of given labels %d should be %d.', length(yy), size(txx,1))]);
  else 
    for i=1:size(txx,1),
      yy(i)=gLabels(str2num(txx(i,:)));
    end
    tyy=num2str(yy');
    set(get(H(1),'Parent'),'XTickLabel',tyy);
  end
end
for i=1:size(H,1),
  set(H(i),'LineWidth',[lineW]);
end

return
