[Tex/LaTex] Drawing string diagrams with TikZ

tikz-pgf

I want to lern typing string diagrams using TikZ. More detailled I want to type the following diagram with tikz. Is this possible? If so, how or what are the most important ingredients?

Best Answer

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{positioning,intersections}
\begin{document}
\begin{tikzpicture}
\node (B1) {B};
\node[right=1cm of B1] (B2) {B};
\node[right=2cm of B2] (B3) {B};
\node[below=5cm of B3] (B6) {B};
\node[left=1cm of B6] (B5) {B};
\node[left=1.2cm of B5] (B4) {B};
\draw (B3) -- (B6) coordinate[pos=0.3] (H1);
\draw[-latex,name path=path1] (B1)--++(0,-3cm)coordinate[pos=0.3] (H3) arc[start angle=-180,end angle=0,radius=0.8] to
[out=90,in=225] (H1) ;
\draw (B2) to[out=-90,in=90] (B5);
\path[name path=path2] (B4)--++(0,4cm);
\path[name intersections={of=path1 and path2,by=H2}];
\draw (B4)--(H2) node[circle,fill]{};
\draw (H3)to[out=0,in=90]++(0.5,-0.5)node[draw,below]{x};       
\end{tikzpicture}
\end{document}

enter image description here

EDIT: Just for fun: without intersections.

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\node (B1) {B};
\node[right=1cm of B1] (B2) {B};
\node[right=2cm of B2] (B3) {B};
\node[below=5cm of B3] (B6) {B};
\node[left=1cm of B6] (B5) {B};
\draw (B3) -- (B6) coordinate[pos=0.3] (H1);
\draw[-latex] (B1)--++(0,-3cm)coordinate[pos=0.3] (H3) arc[start angle=-180,end angle=0,radius=0.8] 
coordinate[midway](H2) to [out=90,in=225](H1) ;
\node at (H2|-B5) (B4) {B};
\draw (B2) to[out=-90,in=90] (B5);
\draw (B4)--(H2);
\draw (H3)to[out=0,in=90]++(0.5,-0.5)node[draw,below]{x};
\foreach \i in {2,3} \draw[fill] (H\i) circle(2pt);       
\end{tikzpicture}
\end{document}

enter image description here

Related Question