function ccdout = plotccd(G, symbol)
% PLOTCCD : log-log plot of clustering coefficient by degree
%
% ccd = plotccd(G);
% ccd = plotccd(G, symbol);   uses given plot symbol, default 'r+'

if nargin < 2
    symbol = 'r+';
end;

G = G + G';
G = spones(G);
G = G - diag(diag(G));
nnodes = size(G,1);
nedges = nnz(G)/2;

fprintf('Number of nodes: %d\n', nnodes);
fprintf('Number of edges: %d\n', nedges);

degs = accumarray(nonzeros(sum(G,2)),1);
maxdegree = find(degs>0,1,'last');

fprintf('Maximum degree: %d\n', maxdegree);

[ccd,gcc] = ccperdeg(G);

fprintf('Global clustering coefficient: %.2f\n', gcc);

semilogx(1:length(ccd),ccd,symbol);
title('Clustering Coefficients by Degree');
xlabel('Degree');
ylabel('Mean CC');

if nargout > 0
    ccdout = ccd;
end;
