%M=count_all_3nodes_motifs(A)
%This code counts the occurence of 13 3-node motifs, indexed by Uri Alon
%auto-regualtion is automatically removed...
function M=count_all_3nodes_motifs(A)
A=A-diag(diag(A));
Ac=(A==0).*(A'==0);%1-A is not enough, we need to make sure bi-dir empty..
Ac=Ac-diag(diag(Ac));
Ab=A.*A';

M=sparse(238,1);
M(6)=trace(A*Ac*A')/2;
M(36)=trace(A*A'*Ac)/2;
M(12)=trace(A*A*Ac);
M(74)=trace(A*Ab*Ac);
M(14)=trace(Ab*A*Ac);
M(78)=trace(Ab*Ab*Ac)/2;
M(38)=trace(A*A*A');
M(98)=trace(A*A*A)/3;
M(108)=trace(A*Ab*A')/2;
M(46)=trace(Ab*A*A')/2;
M(102)=trace(A*A*Ab);
M(110)=trace(Ab*Ab*A);
M(238)=trace(Ab*Ab*Ab);

end

