% A diagram of 81 different ways (topologies) to connect two proteins. Every connection can be
% positive, negative or absent. Disconnected topologies are shaded gray.
% Author: Karthik Raman
\documentclass{article}
\usepackage{fullpage}
\usepackage{pgf}
\usepackage{etoolbox}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,backgrounds}
\usepackage{verbatim}
\newcommand{\topology}[4]{%Four arguments, for each entry of a 2x2 adjacency matrix describing
%the network between two proteins
\begin{tikzpicture}[->,auto,node distance=0.625cm,very thick,
absreg/.style={opacity=0}, %regulation absent: maintains uniform box size by having an invisible arrow
negreg/.style={-|,red}, %negative regulation: red coloured arrow ending with a minus
posreg/.style={->,blue} %positive regulation: blue coloured arrow
]
  %two nodes representing two proteins
  \node[fill=black,circle]         (A) {};
  \node[fill=black,circle,xshift=10mm]         (B) [below of=A] {};
  \path %style the paths based on the input arguments
  (A) edge [loop above,min distance=5mm,in=120,out=60,#1]  (A)
  (A) edge [bend right,out=-45,in=-135,#2]  (B)
  (B) edge [bend left,out=-45,in=-135,#3]  (A)
  (B) edge [loop  below,min distance=5mm,out=-120,in=-60,#4]  (B)
  ;
  \begin{scope}[on background layer]%gray out topologies where both #2 and #3 are absent
  \ifboolexpr{%
    test {\expandafter\ifstrequal\expandafter{#2}{absreg}} 
    and
    test{\expandafter\ifstrequal\expandafter{#3}{absreg}}
   }{\draw [ultra thin,fill=black!10] (current bounding box.north east) rectangle (current bounding box.south west);}{\draw [ultra thin] (current bounding box.north east) rectangle (current bounding box.south west);}
  \end{scope}
\end{tikzpicture}
}
\begin{document}
\thispagestyle{empty}
%A two node network can be represented by a 2x2 adjacency matrix.
%Each entry of the matrix can be negative, positive or zero (absent).
%We loop through these, to generate the array of all possible two-node networks.
\foreach \ab in {absreg,posreg,negreg}
 \foreach \aa in {absreg,posreg,negreg} 
 {
  \foreach \ba in {absreg,posreg,negreg} 
   \foreach \bb in {absreg,posreg,negreg} 
  {\topology{\aa}{\ab}{\ba}{\bb}\hspace{-1.3ex}}
  
 }
\end{document}