%  Script file: gr02.m
%
%  Purpose: 
%    This Program plotting unemployment time series and 
%    creating adjacency matrix of this time series.
%
%  Record of Revisions:
%      Date       Programmer          Description of change
%      ====       ==========          =====================
%    6July2014    Komeil Mazraee        Original code 
%
% Define variables:
%   y            -- 785 monthly value of percent of unemployment.
%   z            -- number of months.
%   k            -- counter of row in unemployment matrix.
%   j            -- elements of  unemployment matrix.
%   l            -- counter of adjacency matrix.
%   c            -- matrix of fixed and positive data of unemployment.
%   d            -- adjacency matrix of unemployment time series.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
clear

% Craeting unemployment data matrix
[y]=textread('unemployment.txt', '%f', 785);

% Plot unemployment time series
figure(3)
plot(y, 'r') 
title('time series of Unemployment') 
xlabel('Percent of Unemployment') 
ylabel('Scaling') 
axis([0 785 -3 15])
axis on
hold on

% Scaling
z=0:785;
  for i=-3:0.25:15 %devisioning of Y axis
      w=i;
      plot(z,w) %horizental line plot.
      hold on
   %   print -depsc unemployment_time_series.tiff
  end

% Creating unemployment matrix of nodes
c=zeros(1,785);
  for k=1:785
      j=y(k);
      c(1,k)= fix((j+3)*4)+1;
  end
 
% Creating adjacency matrix of unemployment
d=zeros(72);
 for l=1:784
     d(c(1,l), c(1, l+1))=d(c(1,l), c(1, l+1))+1;
 end
 
% Plotting graph that related to adjacency matrix
 figure(4)
 drawCircGraph(d)
 %%%%%%%%%%%%%%%%%%%%%%%%%Basic Charachteristics%%%%%%%%%%%%%%%%%%%%%%%%%
% Number of nodes
 num_nodes=numNodes(d);
 
% Number of Edges(not correct)
 number_edges=num_edges(d);
 
