


\def\notblack{black}
\def\black{black}
\def\notblue{blue}
\def\blue{blue}
      \def\lw{1.2pt}
      \def\lblscl{0.67}

\def\sqlw{0.4pt}

\newcommand\crosssq[5]{
\pgfmathsetmacro{\xR}{#1+1}
\pgfmathsetmacro{\xL}{#1-1}
\pgfmathsetmacro{\yU}{#2+1}
\pgfmathsetmacro{\yD}{#2-1}
\pgfmathsetmacro{\xl}{#1-0.5}
\pgfmathsetmacro{\xr}{#1+0.5}
\pgfmathsetmacro{\yu}{#2+0.5}
\pgfmathsetmacro{\yd}{#2-0.5}
% \node (A) at (#1,#2) {#1,#2,\xR,\xl};
\draw[line width=\sqlw,draw=#3] (\xR,#2)--(#1,\yU)--(\xL,#2)--(#1,\yD)--cycle;
\draw[line width=\lw,draw=#4] (\xl,\yu)--(\xr,\yd);
\draw[line width=\lw,draw=#4] (\xr,\yu)--(\xl,\yd);
\coordinate (LU#5) at (\xl,\yu);
\coordinate (LD#5) at (\xl,\yd);
\coordinate (RU#5) at (\xr,\yu);
\coordinate (RD#5) at (\xr,\yd);
}

\def\ledot#1#2{\draw[fill=black!30] (#1,#2) circle (4pt);}

\newcommand\uncrssq[5]{
\pgfmathsetmacro{\xR}{#1+1}
\pgfmathsetmacro{\xL}{#1-1}
\pgfmathsetmacro{\yU}{#2+1}
\pgfmathsetmacro{\yD}{#2-1}
\pgfmathsetmacro{\xl}{#1-0.5}
\pgfmathsetmacro{\xr}{#1+0.5}
\pgfmathsetmacro{\yu}{#2+0.5}
\pgfmathsetmacro{\yd}{#2-0.5}
% \node (A) at (#1,#2) {#1,#2,\xR,\xl};
\draw[line width=\sqlw,draw=#3] (\xR,#2)--(#1,\yU)--(\xL,#2)--(#1,\yD)--cycle;
\draw[line width=\lw,draw=#4] (\xl,\yu) to[out=-45, in=45] (\xl,\yd);
\draw[line width=\lw,draw=#4] (\xr,\yu) to[out=-135,in=135] (\xr,\yd);
\ledot{#1}{#2}
\coordinate (LU#5) at (\xl,\yu);
\coordinate (LD#5) at (\xl,\yd);
\coordinate (RU#5) at (\xr,\yu);
\coordinate (RD#5) at (\xr,\yd);
}

    \newcommand\drawLe[3]{
\pgfmathtruncatemacro{\xshift}{(#1)*5}
\begin{scope}[xshift=\xshift cm]%\xshift]
  \foreach \i in {1,2,...,5}
  {
\pgfmathtruncatemacro{\xi}{\i+(#1)*5}
    % \node[label=above:{\scalebox{\lblscl}{$\xi$}},draw=#2,  scale=0.3,fill=#2] (u\xi) at (\i,6) {};

    \node[draw=#2,  scale=0.3,fill=#2] (u\xi) at (\i,6) {};
    \node[draw=#2,  scale=0.3,fill=#2] (mm\xi) at (\i,1) {};
    \node[draw=#2,  scale=0.3,fill=#2] (m\xi) at (\i,-1) {};
    \node[label=below:{\scalebox{\lblscl}{$\xi$}},draw=#2,  scale=0.3,fill=#2] (d\xi) at (\i,-6) {};
    \coordinate (ux\xi) at (\i,7.28);
    \node[anchor=north] (XXX) at (ux\xi.90) {\scalebox{\lblscl}{$\xi$}};
  }
  \foreach \i in {3,4,5}
  {
\pgfmathtruncatemacro{\xi}{\i+(#1)*5}
\draw[line width=\lw,draw=#3] (mm\xi) -- (m\xi);
}
\pgfmathtruncatemacro{\one}{1+(#1)*5}
\pgfmathtruncatemacro{\two}{2+(#1)*5}
\pgfmathtruncatemacro{\three}{3+(#1)*5}
\pgfmathtruncatemacro{\four}{4+(#1)*5}
\pgfmathtruncatemacro{\five}{5+(#1)*5}
\crosssq{1.5}{3.5}{#2}{#3}{A}
\crosssq{2.5}{2.5}{#2}{#3}{B}
\crosssq{2.5}{4.5}{#2}{#3}{C}
\crosssq{3.5}{3.5}{#2}{#3}{D}
\crosssq{4.5}{4.5}{#2}{#3}{E}
\draw[line width=\lw,draw=#3] (u\one)--(LUA);
\draw[line width=\lw,draw=#3] (u\two)--(LUC);
\draw[line width=\lw,draw=#3] (u\three)--(RUC);
\draw[line width=\lw,draw=#3] (u\four)--(LUE);
\draw[line width=\lw,draw=#3] (u\five)--(RUE);

\draw[line width=\lw,draw=#3] (mm\one)--(LDA);
\draw[line width=\lw,draw=#3] (mm\two)--(LDB);
\draw[line width=\lw,draw=#3] (mm\three)--(RDB);
\draw[line width=\lw,draw=#3] (mm\four)--(RDD);
\draw[line width=\lw,draw=#3] (mm\five)--(RDE);

\crosssq{1.5}{-3.5}{#2}{#3}{A}
\uncrssq{2.5}{-2.5}{#2}{#3}{B}
\uncrssq{2.5}{-4.5}{#2}{#3}{C}
\uncrssq{3.5}{-3.5}{#2}{#3}{D}
\uncrssq{4.5}{-4.5}{#2}{#3}{E}


\draw[line width=\lw,draw=#3] (d\one)--(LDA);
\draw[line width=\lw,draw=#3] (d\two)--(LDC);
\draw[line width=\lw,draw=#3] (d\three)--(RDC);
\draw[line width=\lw,draw=#3] (d\four)--(LDE);
\draw[line width=\lw,draw=#3] (d\five)--(RDE);

\draw[line width=\lw,draw=#3] (m\one)--(LUA);
\draw[line width=\lw,draw=#3] (m\two)--(LUB);
\draw[line width=\lw,draw=#3] (m\three)--(RUB);
\draw[line width=\lw,draw=#3] (m\four)--(RUD);
\draw[line width=\lw,draw=#3] (m\five)--(RUE);

\end{scope}

}


\newcommand\drawLine[2]{
\pgfmathtruncatemacro{\xshift}{(#1)*5}
\begin{scope}[xshift=\xshift cm]%\xshift]
  \foreach \i in {1,2}
  {
\pgfmathtruncatemacro{\xi}{\i+(#1)*5}
\pgfmathtruncatemacro{\xxi}{\i+(#1+1)*5}
\draw[line width=\lw,draw=#2] (mm\xi) -- (m\xxi);
  }
\end{scope}
}

\def\sqt{0.5}

\newcommand\Lesq[3]{
\pgfmathsetmacro{\xl}{#1-\sqt}
\pgfmathsetmacro{\xr}{#1+\sqt}
\pgfmathsetmacro{\yu}{#2+\sqt}
\pgfmathsetmacro{\yd}{#2-\sqt}
\draw[line width=\sqlw,draw=#3] (\xl,\yu)--(\xr,\yu)--(\xr,\yd)--(\xl,\yd)--cycle;
}

\newcommand\ledott[2]{\draw[fill=black!30] (#1,#2) circle (2.83pt);}


\newcommand\Lesqd[3]{
\pgfmathsetmacro{\xl}{#1-\sqt}
\pgfmathsetmacro{\xr}{#1+\sqt}
\pgfmathsetmacro{\yu}{#2+\sqt}
\pgfmathsetmacro{\yd}{#2-\sqt}
\draw[line width=\sqlw,draw=#3] (\xl,\yu)--(\xr,\yu)--(\xr,\yd)--(\xl,\yd)--cycle;
\draw[fill=black!30] (#1,#2) circle (2.83pt);
}
\newcommand\Lesql[4]{
\Lesq{#1}{#2}{#3}
\node[scale=1] (SSS) at (#1,#2) {$s_{#4}$};
}


\def\figureLe{


\begin{tabular}{ccc}

\begin{tikzpicture}[scale=0.565,baseline=(zero.base)]
\coordinate (zero) at (0,0.5);
\Lesqd{0}{-2}{\black}
\Lesqd{1}{-2}{\black}
\Lesqd{2}{-2}{\black}
\Lesq{0}{-3}{\black}
\Lesqd{1}{-3}{\black}

\Lesql{0}{3}{\black}{2}
\Lesql{1}{3}{\black}{3}
\Lesql{2}{3}{\black}{4}
\Lesql{0}{2}{\black}{1}
\Lesql{1}{2}{\black}{2}
\end{tikzpicture}
& \qquad\qquad\qquad
&
\begin{tikzpicture}[xscale=0.4,yscale=0.4,baseline=(zero.base)]
\coordinate (zero) at (0,0);
   \begin{scope}[even odd rule]
  \clip (-1.4,-7) rectangle (12.4,7);
\drawLe 0{\black}{\blue}
\drawLe 1{\notblack}{\notblue}
\drawLe 2{\notblack}{\notblue}
\drawLe 3{\notblack}{\notblue}
\drawLe{-1}{\notblack}{\notblue}
\drawLine{-1}{\notblue}
\drawLine{0}{\blue}
\drawLine{1}{\notblue}
\drawLine{2}{\notblue}
      \end{scope}
\node[anchor=west,scale=1.2] (A) at (12.6,3.5) {$w^{-1}$};
\node[anchor=west,scale=1.2] (B) at (12.6,0) {$\tl$};
\node[anchor=west,scale=1.2] (C) at (12.6,-3.5) {$v$};
\end{tikzpicture}
\end{tabular}

}


\def\figureFlag{
\def\lw{1.2pt}
\def\lww{1.6pt}
\def\lws{0.6pt}
\def\pointscl{0.3}
\def\pointscll{0.3}
% \def\redx{red!80!black}
\def\redx{red}
\setlength{\tabcolsep}{12pt}
\begin{tabular}{ccc}
\begin{tikzpicture}[scale=2,baseline=(zero.base)]
\coordinate (zero) at (0,0);
\coordinate (ss2) at (-30:1);
\coordinate (ss21) at (150:1);
\draw[dashed, line width=\lw,opacity=0.7] (ss2) to[bend right=-20] (ss21);
% \draw[dashed, line width=\lw,opacity=0.7] (ss2) to[bend=20] (ss21);
\shade [ball color=white,opacity=0.4] (0,0) circle [radius=1];
\draw[line width=\lw] (0,0) circle (1);
\draw[draw=\redx,line width=\lww] (-150:1) arc (-150:-210:1);
\node[label=below:$\id$,draw,circle,fill,scale=\pointscl] (id) at (-90:1) {};
\node[label=-150:$s_1$,draw,circle,fill,scale=\pointscl] (s1) at (-150:1) {};
\node[label=-30:$s_2$,draw,circle,fill,scale=\pointscl] (s2) at (-30:1) {};
\node[label=30:$s_1s_2$,draw,circle,fill,scale=\pointscl] (s12) at (30:1) {};
\node[label=150:$s_2s_1$,draw,circle,fill,scale=\pointscl] (s21) at (150:1) {};
\node[label=above:$w_0$,draw,circle,fill,scale=\pointscl] (w0) at (90:1) {};
% \node[label=above:$s_1s_2s_1{=}s_2s_1s_2$,draw,circle,fill,scale=\pointscl] (w0) at (90:1) {};
\draw[line width=\lw] (s1) to[bend right=20] (s12);
\node[anchor=east,color=\redx] (g) at (180:1) {$\Povtp_g$};
% \draw[line width=\lw] (s1) to[bend right=20] (s12);
\end{tikzpicture}
  & \scalebox{1.3}{$\overset{\isog}{\longrightarrow}$} &
\begin{tikzpicture}[xscale=2.5,yscale=2,baseline=(zero.base)]
\coordinate (zero) at (0,0.5);
\coordinate (w0) at (-0.2,1);
\coordinate (s2) at (0.2,1.3);
\coordinate (s21) at (0.8,1);
\coordinate (id) at (1.2,1.3);
\coordinate (ss1) at (1,0);
\coordinate (ss12) at (0,0);


\fill[opacity=0.1] (w0)--(s2)--(id)--(ss1)--(ss12)--(w0);
\fill[opacity=0.2] (s2) -- (id)--(ss1)--(ss12)--(s2);
\fill[opacity=0.3] (w0) -- (s21)--(ss1)--(ss12)--(w0);

\node[label=below:$s_1$,draw,circle,fill=white,scale=\pointscll] (s1) at (1,0) {};
\node[label=below:$s_2s_1$,draw,circle,fill=white,scale=\pointscll] (s12) at (0,0) {};
\draw[line width=\lww,draw=\redx] (s1)--(s12);
\node[anchor=north,color=\redx] (g) at (0.5,0) {$\Povtp_g$};
\draw[dashed,line width=\lw,opacity=0.7] (s12) -- (w0);
\draw[dashed,line width=\lw,opacity=0.7] (s12) -- (s2);
\draw[dashed,line width=\lw,opacity=0.7] (s1) -- (s21);
\draw[dashed,line width=\lw,opacity=0.7] (s1) -- (id);
\draw[dashed,line width=\lws,opacity=0.2] (w0) -- (s2)--(id)--(s21)--(w0);

\node[anchor=south] (A) at (w0) {$w_0$};
\node[anchor=south] (A) at (s2) {$s_2$};
\node[anchor=south] (A) at (id) {$\id$};
\node[anchor=south] (A) at (s21) {$s_1s_2$};
\end{tikzpicture}

\end{tabular}
\setlength{\tabcolsep}{6pt}
}
