Figure1=figure(1);
clf;

F_in=0.8:0.01:1;

% %%%%%% N=3,M=2
% N=3;
% M=2;
% F_out_LQNC= Calculate_fidelity_LQNC_N_hop_M_pair(F_in,N,M);
% F_out_ES= Calculate_fidelity_ES_N_hop_M_pair(F_in,N,M);
% number_of_pairs_LQNC=3*M +M*N/2;
% F_improvement_normalised = 100*(F_out_LQNC-F_out_ES)./(F_out_ES*number_of_pairs_LQNC);
% plot(F_in,F_improvement_normalised,'b-+','LineWidth',1,'MarkerSize', 10,'DisplayName',['N=' num2str(N) 'hops, M=' num2str(M) ' pairs']);
% set(gca,'FontSize',14);
% hold on;
% grid on;
%%%%%%%%%%%%%%%
N=3;
M=4;
F_out_LQNC= Calculate_fidelity_LQNC_N_hop_M_pair(F_in,N,M);
F_out_ES= Calculate_fidelity_ES_N_hop_M_pair(F_in,N,M);
number_of_pairs_LQNC=3*M +M*N/2;
F_improvement_normalised = 100*(F_out_LQNC-F_out_ES)./(F_out_ES*number_of_pairs_LQNC);
plot(F_in,F_improvement_normalised,'b-o','LineWidth',1,'MarkerSize', 10,'DisplayName',['N=' num2str(N) 'hops, M=' num2str(M) ' pairs']);
set(gca,'FontSize',14);
hold on;
%grid on;
%%%%%%%%%%%%%%%
N=4;
M=8;
F_out_LQNC= Calculate_fidelity_LQNC_N_hop_M_pair(F_in,N,M);
F_out_ES= Calculate_fidelity_ES_N_hop_M_pair(F_in,N,M);
number_of_pairs_LQNC=3*M +M*N/2;
F_improvement_normalised = 100*(F_out_LQNC-F_out_ES)./(F_out_ES*number_of_pairs_LQNC);
plot(F_in,F_improvement_normalised,'b-+','LineWidth',1,'MarkerSize', 10,'DisplayName',['N=' num2str(N) 'hops, M=' num2str(M) ' pairs']);
set(gca,'FontSize',14);
hold on;
%grid on;
%%%%%%%%%%%%%%%
N=8;
M=12;
F_out_LQNC= Calculate_fidelity_LQNC_N_hop_M_pair(F_in,N,M);
F_out_ES= Calculate_fidelity_ES_N_hop_M_pair(F_in,N,M);
number_of_pairs_LQNC=3*M +M*N/2;
F_improvement_normalised = 100*(F_out_LQNC-F_out_ES)./(F_out_ES*number_of_pairs_LQNC);
plot(F_in,F_improvement_normalised,'b->','LineWidth',1,'MarkerSize', 10,'DisplayName',['N=' num2str(N) 'hops, M=' num2str(M) ' pairs']);
set(gca,'FontSize',14);
hold on;
%grid on;
%%%%%%%%%%%%%%%
N=10;
M=14;
F_out_LQNC= Calculate_fidelity_LQNC_N_hop_M_pair(F_in,N,M);
F_out_ES= Calculate_fidelity_ES_N_hop_M_pair(F_in,N,M);
number_of_pairs_LQNC=3*M +M*N/2;
F_improvement_normalised = 100*(F_out_LQNC-F_out_ES)./(F_out_ES*number_of_pairs_LQNC);
plot(F_in,F_improvement_normalised,'b-s','LineWidth',1,'MarkerSize', 10,'DisplayName',['N=' num2str(N) 'hops, M=' num2str(M) ' pairs']);
set(gca,'FontSize',14);
hold on;
%grid on;
h_legend=legend('show');
set(h_legend,'FontSize',16);
set(Figure1,'defaulttextinterpreter','latex');
title(['Normalised Fidelity Improvement: LQNC vs. ES '],'fontsize',20)
xlabel('Input Fidelity ($F_{in}$)','fontsize',20) % x-axis label
ylabel('$\frac{F^{LQNC}_{out} - F^{ES}_{out}}{F^{ES}_{out}Y_{LQNC}}100$[\%]','fontsize',20) % y-axis label
ylim ([0 10]);
xlim ([0.8 1]);