%!TEX root = main.tex
%\def\myscale{0.7}%{0.75}
%{Another example: From $11010$ to a perfect matching}
% begin snake graph 11010 (with 1 0 signs in interior)
 \begin{tikzpicture}[xscale=0.65, yscale=0.65,font=\scriptsize]
\newcommand\macrotile[1]{
     \def\south{}
     \def\east{}
     \def\north{}
     \def\west{} 
     \draw (\x + 0, \y) --  (\x+1,\y) node [pos=0.5,above] {\south} -- (\x+1,\y+1) node [pos=0.5,left] {\east} -- (\x+0,\y+1) node [pos=0.5,above] {\north} --  (\x + 0, \y)  node [pos=0.5,left] {\west};
}
%\newcommand\macropositivetileBinary{
%     \def\south{$0$}
%     \def\east{$0$}
%     \def\north{$1$}
%     \def\west{$1$} 
%     \draw (\x + 0, \y) --  (\x+1,\y) node [pos=0.5,above] {\south} -- (\x+1,\y+1) node [pos=0.5,left] {\east} -- (\x+0,\y+1) node [pos=0.5,above] {\north} --  (\x + 0, \y)  node [pos=0.5,left] {\west};
%}
\newcommand\macropositivetileBinaryWestEast{
     \def\south{}
     \def\east{\textcolor{blue}{\circled{$0$}}}
     \def\north{}
     \def\west{\textcolor{blue}{\circled{$1$}}}
     \draw (\x + 0, \y) --  (\x+1,\y) node [pos=0.5] {\south} -- (\x+1,\y+1) node [pos=0.5] {\east} -- (\x+0,\y+1) node [pos=0.5] {\north} --  (\x + 0, \y)  node [pos=0.5] {\west};
}
\newcommand\macropositivetileBinaryWest{
     \def\south{}
     \def\east{{$0$}}
     \def\north{}
     \def\west{\textcolor{blue}{\circled{$1$}}}
     \draw (\x + 0, \y) --  (\x+1,\y) node [pos=0.5] {\south} -- (\x+1,\y+1) node [pos=0.5] {\east} -- (\x+0,\y+1) node [pos=0.5] {\north} --  (\x + 0, \y)  node [pos=0.5] {\west};
}
\newcommand\macropositivetileBinaryEast{
     \def\south{}
     \def\east{\textcolor{blue}{\circled{$0$}}}
     \def\north{}
     \def\west{{$1$}} 
     \draw (\x + 0, \y) --  (\x+1,\y) node [pos=0.5] {\south} -- (\x+1,\y+1) node [pos=0.5] {\east} -- (\x+0,\y+1) node [pos=0.5] {\north} --  (\x + 0, \y)  node [pos=0.5] {\west};
}
\newcommand\macropositivetileBinaryWestNorth{
     \def\south{}
     \def\east{}
     \def\north{\textcolor{blue}{\circled{$1$}}}
     \def\west{\textcolor{blue}{\circled{$1$}}} 
     \draw (\x + 0, \y) --  (\x+1,\y) node [pos=0.5] {\south} -- (\x+1,\y+1) node [pos=0.5] {\east} -- (\x+0,\y+1) node [pos=0.5] {\north} --  (\x + 0, \y)  node [pos=0.5] {\west};
}
\newcommand\macropositivetileBinarySouthEast{
     \def\south{\textcolor{blue}{\circled{$0$}}}
     \def\east{\textcolor{blue}{\circled{$0$}}}
     \def\north{}
     \def\west{} 
     \draw (\x + 0, \y) --  (\x+1,\y) node [pos=0.5] {\south} -- (\x+1,\y+1) node [pos=0.5] {\east} -- (\x+0,\y+1) node [pos=0.5] {\north} --  (\x + 0, \y)  node [pos=0.5] {\west};
}
\newcommand\macropositivetileBinarySouth{
     \def\south{\textcolor{blue}{\circled{$0$}}}
     \def\east{}%{\textcolor{blue}{\circled{$0$}}}
     \def\north{}
     \def\west{} 
     \draw (\x + 0, \y) --  (\x+1,\y) node [pos=0.5] {\south} -- (\x+1,\y+1) node [pos=0.5] {\east} -- (\x+0,\y+1) node [pos=0.5] {\north} --  (\x + 0, \y)  node [pos=0.5] {\west};
}
\newcommand\macropositivetileBinarySouthNorth{
     \def\south{\textcolor{blue}{\circled{$0$}}}
     \def\east{}
     \def\north{\textcolor{blue}{\circled{$1$}}}
     \def\west{} 
     \draw (\x + 0, \y) --  (\x+1,\y) node [pos=0.5] {\south} -- (\x+1,\y+1) node [pos=0.5] {\east} -- (\x+0,\y+1) node [pos=0.5] {\north} --  (\x + 0, \y)  node [pos=0.5] {\west};
}

\newcommand\macronegativetileBinary{
     \def\south{$1$}
     \def\east{$1$}
     \def\north{$0$}
     \def\west{$0$} 
     \draw (\x + 0, \y) --  (\x+1,\y) node [pos=0.5] {\south} -- (\x+1,\y+1) node [pos=0.5] {\east} -- (\x+0,\y+1) node [pos=0.5] {\north} --  (\x + 0, \y)  node [pos=0.5] {\west};
}
\newcommand\macronegativetileBinaryWestEast{
     \def\south{}
     \def\east{\textcolor{blue}{\circled{$1$}}}
     \def\north{}
     \def\west{\textcolor{blue}{\circled{$0$}}}
     \draw (\x + 0, \y) --  (\x+1,\y) node [pos=0.5] {\south} -- (\x+1,\y+1) node [pos=0.5] {\east} -- (\x+0,\y+1) node [pos=0.5] {\north} --  (\x + 0, \y)  node [pos=0.5] {\west};
}
\newcommand\macronegativetileBinaryEast{
     \def\south{}
     \def\east{\textcolor{blue}{\circled{$1$}}}
     \def\north{}
     \def\west{{$0$}}
     \draw (\x + 0, \y) --  (\x+1,\y) node [pos=0.5] {\south} -- (\x+1,\y+1) node [pos=0.5] {\east} -- (\x+0,\y+1) node [pos=0.5] {\north} --  (\x + 0, \y)  node [pos=0.5] {\west};
}
\newcommand\macronegativetileBinaryWestNorth{
     \def\south{}
     \def\east{}
     \def\north{\textcolor{blue}{\circled{$0$}}}
     \def\west{\textcolor{blue}{\circled{$0$}}}
     \draw (\x + 0, \y) --  (\x+1,\y) node [pos=0.5] {\south} -- (\x+1,\y+1) node [pos=0.5] {\east} -- (\x+0,\y+1) node [pos=0.5] {\north} --  (\x + 0, \y)  node [pos=0.5] {\west};
}
\newcommand\macronegativetileBinarySouthEast{
     \def\south{\textcolor{blue}{\circled{$1$}}}
     \def\east{\textcolor{blue}{\circled{$1$}}}
     \def\north{}
     \def\west{} 
     \draw (\x + 0, \y) --  (\x+1,\y) node [pos=0.5,above] {\south} -- (\x+1,\y+1) node [pos=0.5,left] {\east} -- (\x+0,\y+1) node [pos=0.5,above] {\north} --  (\x + 0, \y)  node [pos=0.5,left] {\west};
}
\newcommand\macronegativetileBinarySouthEastNotcircled{
     \def\south{\textcolor{black}{{$1$}}}
     \def\east{\textcolor{black}{{$1$}}}
     \def\north{}
     \def\west{} 
     \draw (\x + 0, \y) --  (\x+1,\y) node [pos=0.5,above] {\south} -- (\x+1,\y+1) node [pos=0.5] {\east} -- (\x+0,\y+1) node [pos=0.5,above] {\north} --  (\x + 0, \y)  node [pos=0.5] {\west};
}

\newcommand\macronegativetileBinarySouthNorth{
     \def\south{\textcolor{blue}{\circled{$1$}}}
     \def\east{}
     \def\north{\textcolor{blue}{\circled{$0$}}}
     \def\west{} 
     \draw (\x + 0, \y) --  (\x+1,\y) node [pos=0.5] {\south} -- (\x+1,\y+1) node [pos=0.5] {\east} -- (\x+0,\y+1) node [pos=0.5] {\north} --  (\x + 0, \y)  node [pos=0.5] {\west};
}
\newcommand\macronegativetileBinaryNorthNotcircled{
     \def\south{\textcolor{black}{{$1$}}}
     \def\east{}
     \def\north{\textcolor{black}{{$0$}}}
     \def\west{} 
     \draw (\x + 0, \y) --  (\x+1,\y) node [pos=0.5] {\south} -- (\x+1,\y+1) node [pos=0.5] {\east} -- (\x+0,\y+1) node [pos=0.5] {\north} --  (\x + 0, \y)  node [pos=0.5] {\west};
}
\newcommand\macronegativetileBinaryWest{ % for a last tile
     \def\south{}
     \def\east{}
     \def\north{}
     \def\west{\textcolor{blue}{\circled{$0$}}}
     \draw (\x + 0, \y) --  (\x+1,\y) node [pos=0.5] {\south} -- (\x+1,\y+1) node [pos=0.5] {\east} -- (\x+0,\y+1) node [pos=0.5] {\north} --  (\x + 0, \y)  node [pos=0.5] {\west};
}
\newcommand\macronegativetileBinaryWestNotcircled{ % for a last tile
     \def\south{}
     \def\east{}
     \def\north{}
     \def\west{\textcolor{black}{{$0$}}}
     \draw (\x + 0, \y) --  (\x+1,\y) node [pos=0.5] {\south} -- (\x+1,\y+1) node [pos=0.5] {\east} -- (\x+0,\y+1) node [pos=0.5] {\north} --  (\x + 0, \y)  node [pos=0.5] {\west};
}


 \foreach \x in {0,1,...,2} % bottom row 
 {
\def\y{0}
     \ifthenelse{\x = 0}{\macropositivetileBinaryWest      \draw (\x + 0.5, \y+0.5) node {$\boxed{a}$};}{}
     \ifthenelse{\x = 1}{\macronegativetileBinaryEast}{}
     \ifthenelse{\x =2}{\macrotile{} %\macropositivetileBinaryWestNorth 
     \draw (\x + 0.5, \y+0.5) node {$\boxed{c}$};}{}
 }

\def\y{1}
 \foreach \x in {2,...,5} % second from bottom row
 {
     \ifthenelse{\x = 2}
     {\macronegativetileBinarySouthEastNotcircled }{}
     \ifthenelse{\x = 3}
     {\macropositivetileBinaryEast}{}
     \ifthenelse{\x = 4}
     {\macronegativetileBinaryWestEast}{}
     \ifthenelse{\x = 5}
     {\macrotile{} %\macropositivetileBinaryWestNorth 
     \draw (\x + 0.5, \y+0.5) node {$\boxed{g}$};
     }{}
 } 
 
\def\y{2}
 \foreach \x in {5} % third from bottom row
 {
     \macronegativetileBinaryNorthNotcircled{} %\macronegativetileBinarySouthNorth
 }  

\def\y{3}
\foreach \x in {5,6} % fourth from bottom row
{
     \ifthenelse{\x = 5}{\macropositivetileBinarySouth
     \draw (\x + 0.5, \y+0.5) node {$\boxed{i}$};}{}
     \ifthenelse{\x = 6}{\macronegativetileBinaryWestNotcircled }{}
 } 
 
\end{tikzpicture}