function degsout = plotdegs(G, symbol)
% PLOTDEGS : log-log plot of degree distribution of graph 
%
% degs = plotdegs(G);
% degs = plotdegs(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);

loglog(1:length(degs),degs,symbol);
title('Degree distribution');
xlabel('Degree');
ylabel('Frequency');

if nargout > 0
    degsout = degs;
end;