function [res] = time_series_random_degree( input_matrix, total, interval ,r)
% Generate time series degree plot
%   input_matrix: the imported dataset, in matrix form
%   total: the total number of nodes
%   interval: the time interval to be used, in seconds
%   r: node ID

maxt = max(input_matrix);
maxt = maxt(4);
maxt = uint32(maxt);

mint = min(input_matrix);
mint = mint(3);
mint = uint32(mint);

interv = maxt - mint;
interv = uint32(ceil(interv / interval));

array = zeros(1,interv);


s = size(input_matrix);

nrows = s(1);

cont = 1;

while (cont<=interv)
    deg = zeros(1,total);
    for ii = 1:nrows
       if (input_matrix(ii,1) == r) || (input_matrix(ii,2) == r) && (input_matrix(ii,1) <= total) && (input_matrix(ii,2) <= total)
            avg = (input_matrix(ii,3)+input_matrix(ii,4))/2;   
            if (avg >= mint) && (avg <= (mint+interval))
                if (input_matrix(ii,1) == r)
                deg(input_matrix(ii,2)) = 1;
                end
                if (input_matrix(ii,2) == r)
                deg(input_matrix(ii,1)) = 1;
                end
            end
       end
    end
    array(cont) = sum(deg);
    mint = mint + interval;
    cont = cont +1;
    deg = zeros(1,total);
end



plot(array, '-ob', 'MarkerFaceColor','b', 'MarkerSize', 3);

total_degrees = sum(array)

t = strcat('Degree for Node ', num2str(r));

xlabel('Time interval');
ylabel('Degree');
legend('Data','7-point moving average');

title(t);

return;
end


