6

In this directed graph, I would like to make the downward 'b' edges "tuck behind" the upward 'b' edges.

Something similar to, make a vertex where the 'b' edges intersect, and fill it white, but put it behind the upward 'b' edge. The appearance would essentially be a small break in the downward 'b' edge around where it is about to intersect the other 'b' edge.

Is there a simple way to accomplish this?

enter image description here

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}

\begin{scope}[every node/.style={fill=black,circle,thin,draw}]
\node (a1) at  (2,2) {};
\node (a2) at  (4,2) {};
\node (a3) at  (6,2) {};
\node (a4) at  (8,2) {};
\node (a5) at  (10,2) {};
\node (a6) at  (12,2) {};

\node (b1) at  (2,8) {};
\node (b2) at  (4,8) {};
\node (b3) at  (6,8) {};
\node (b4) at  (8,8) {};
\node (b5) at  (10,8) {};
\node (b6) at  (12,8) {};
\end{scope}]

\begin{scope}[every node/.style={draw=none}]
\node (a0) at  (0,2) {};
\node (b0) at  (0,8) {};
\node (a7) at  (14,2) {};
\node (b7) at  (14,8) {};
\end{scope}

\begin{scope}[>={Stealth[black]},
              every node/.style={fill=white,circle},
              every edge/.style={draw=black}]
    \path [->] (a1) edge node {$a$} (a2);
    \path [->] (a2) edge (a3);
    \path [->] (a3) edge  (a4);
    \path [->] (a4) edge  (a5);
    \path [->] (a5) edge  (a6);
    \path [->] (b1) edge node {$a$}  (b2);
    \path [->] (b2) edge (b3);
    \path [->] (b3) edge (b4);
    \path [->] (b4) edge  (b5);
    \path [->] (b5) edge  (b6);
    \path [->>] (a1) edge node {$b$}  (b2);
    \path [->>] (a2) edge (b3);
    \path [->>] (a3) edge (b4);
    \path [->>] (a4) edge  (b5);
    \path [->>] (a5) edge  (b6);  
    \path [->>] (b1) edge (a3);
    \path [->>] (b2) edge  (a4);
    \path [->>] (b3) edge  (a5);
    \path [->>] (b4) edge node {$b$}   (a6);
\end{scope}

\begin{scope}[>={Stealth[black]},
              every edge/.style={draw=black}]
    \path (a0) edge [dashed] node {} (a1);
    \path (b0) edge [dashed] node {} (b1);
    \path (a6) edge [dashed] node {} (a7);
    \path (b6) edge [dashed] node {} (b7);  
    \path (a0) edge [dashed] node {} (b1);
    \path (a6) edge [dashed] node {} (b7);   
    \path (b0) edge [dashed] node {} (a2);   
    \path (b5) edge [dashed] node {} (a7);
 \end{scope}

\end{tikzpicture}
\end{document}
1
  • 1
    Looks like something that either the knots or spath3 tikz libraries would be useful for. Mar 19, 2022 at 20:02

2 Answers 2

12

This can be done with tikz-cd, using crossing over.

enter image description here

\documentclass{article}

\usepackage{tikz-cd}

\begin{document}

\begin{tikzcd}[cells={nodes={fill, circle, inner sep=.7mm}}, row sep=3cm, >={stealth}]
|[fill=none]|\arrow[r,dashed,-] \arrow[drr,dashed,-]
     & ||\arrow[r,->, "a" description] \arrow[drr,->>]
     & ||\arrow[r,->] \arrow[drr,->>]
     & ||\arrow[r,->] \arrow[drr,->>]
     & ||\arrow[r,->] \arrow[drr,->>,"b" description]
     & ||\arrow[r,->] \arrow[drr,dashed,-]
     & ||\arrow[r,dashed,-] 
     & |[fill=none]|\\
|[fill=none]|\arrow[r,dashed,-] \arrow[ur,dashed,-,crossing over]
    & ||\arrow[r,->, "a" description] \arrow[ur,->>,crossing over,"b" description]
    & ||\arrow[r,->] \arrow[ur,->>,crossing over]
    & ||\arrow[r,->] \arrow[ur,->>,crossing over]
    & ||\arrow[r,->] \arrow[ur,->>,crossing over]
    & ||\arrow[r,->] \arrow[ur,->>,crossing over]
    & ||\arrow[r,dashed,-] \arrow[ur,dashed,-,crossing over]
    & |[fill=none]|
\end{tikzcd}

\end{document}
6

I propose this pstricks solution:

\documentclass[pstricks, border=6pt]{standalone}AS
\usepackage{pst-node, multido}

\begin{document}

    \begin{pspicture}(0,1)(14,8.5) 
    \psset{linejoin=1, arrowinset=0.1, dotscale=2}
    \multido{\i=1+1, \I=2+2}{6}{\dotnode(\I,2){a\i}\dotnode(\I, 8){b\i}}
    \pnodes(0,2){a0}(0,8){b0}(14,2){a7}(14,8){b7}
    \psset{arrows=->}
    \ncline{a1}{a2}\ncput*{$a$}
    \ncline{b1}{b2}\ncput*{$a$}
    \ncline[linewidth=0pt]{a1}{b2}\ncput*{$b$}
    \multido{\i=2+1,\I=3+1}{4}{\ncline{a\i}{a\I}\ncline{b\i}{b\I}}%
    \foreach \s/\t in {b1/a3, b2/a4, b3/a5, b4/a6}{\ncline{->>}{\s}{\t}} \ncput*{$b$}
    \foreach \s/\t in {a2/b3, a3/b4, a4/b5, a5/b6, a1/b2}{\ncline[border=2pt]{->>}{\s}{\t}} \ncput*{$b$}
    \psset{linestyle=dashed, arrows=-}
    \psline(b1)(b0)(a2)\psline(a1)(a0)(b1)
    \psline(b6)(b7)(a6)\psline(a6)(a7)(b5)
    \end{pspicture}

\end{document} 

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .