%% CODE DESCRIPTION

% This code plots the exact steady distribution for macro model (Markov process)

% List of parameters
% n: number of nodes
% N: number of possible edges
% c_1: birth rate
% c_2: death rate
% c_3: triadic closure constant


clear all
clc


n=100;
N=n*(n-1)*0.5;
ratio=zeros(N,1);


 
c_1=0.025;
c_2=0.25;
c_3 = 0.91;
 
%birth-death rates
r_birth = zeros(N,1);
r_death = zeros(N,1);
for i = 1:N                %ignore state zero
    p = i/N; 
    r_birth(i) = c_1*(1-p) + c_3*p*(1-p)*(p-1/N);
    r_death(i) = c_2*p;
end

ratio = r_birth(1:end-1)./r_death(2:end);


%% Plot
pval = [1:N]/(N+1);
yvals = cumprod([1;ratio]);  %cummulative product
%plot(pval(1:end),yvals/sum(yvals),'Linewidth',2)   % steady state with logarithmically scaled  y axis
figure(4)
c1 = trapz(pval,yvals);
plot(pval,yvals/c1)