function y = f(x,k,K,fun)
% k: size of hyperedge
% K: max size of hyperedge allowed in the hypergraph
% The size information matters only to build a collective infection model.
% fun: String indicating which infection model to consider




if strcmp(fun,'collective')
    c=zeros(2,K);
    c(1,:) = [0:1:K-1];
    c(2,:) = [0:1:K-1];
    c=c-ones(2,K);
    %['size(x)= ' num2str(size(x))]
    %['x= ' num2str(x)]
    %['size(k)= ' num2str(size(k))]
    %['k= ' num2str(k)]
    %['size(x>=c(1,k))= ' num2str(size(x>=c(1,k)))]
    y = c(2,k).*(x>=c(1,k));
    y(k==2)=x(k==2);
else
switch fun
    %case 'collective'
    %% collective infection model
    %c=zeros(2,K);
    %c(1,:) = [0:1:K-1];
    %c(2,:) = [0:1:K-1];
    %y = c(2,k).*(x>=c(1,k));
    case 'atan'
        y=atan(x);
        y(k==2)=x(k==2);
    case 'log'
        y=log(1+x);
        %y(k==2)=x(k==2);
    case '2log'
        y=2*log(1+x);
        y(k==2)=x(k==2);
    case 'min'
        c=3;
        y=min(x,c);

%y=x;
%y=x+1;
%y=2.*x;
%y=x./2;
%c = 3;
%epsilon=0.1;
%y=max(0,x-c);
%y=max(epsilon,x-c);
%y=x.^2;

end
end

end