2

I want to draw a diagram in TikZ which looks as follows:

enter image description here

I am not sure of what type of diagram it would classify as (not commutative?), my first thought was something similar to the example on page 7 of the tikz-cd manual:

enter image description here

but it doesn't feel like the most appropriate method. Any pointers?

3

2 Answers 2

3
\documentclass[tikz, border=1 cm]{standalone}
\begin{document}
\begin{tikzpicture}[->, shorten <=0.2 cm, shorten >=0.3 cm]
\coordinate (A) at (0,0);
\coordinate (B) at (2,4);
\coordinate (C) at (4,0);
\fill (A) circle[radius=0.1 cm];
\fill (B) circle[radius=0.1 cm];
\fill (C) circle[radius=0.1 cm];
\draw (A) to[out=80,in=50,min distance=5cm] (A);
\draw (C) to[out=130,in=100,min distance=5cm] (C);
\draw (A) to[bend left] (C);
\draw (C) to[bend left] (A);
\draw (A) to[out=130,in=230,min distance=1.5cm] (A);
\draw (C) to[out=50,in=-50,min distance=1.5cm] (C);
\end{tikzpicture}
\end{document}

Diagram with three nodes and looped arrows

Edit:

Just to show one of the curves with explicit control points:

\documentclass[tikz, border=1 cm]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\tikzset{%
  show curve controls/.style={
    postaction={
      decoration={
        show path construction,
        curveto code={
          \draw [blue, >=\empty, shorten <=0 cm, shorten >=00 cm] 
            (\tikzinputsegmentfirst) -- (\tikzinputsegmentsupporta)
            (\tikzinputsegmentlast) -- (\tikzinputsegmentsupportb);
          \fill [red, opacity=0.5] 
            (\tikzinputsegmentsupporta) circle [radius=.5ex]
            (\tikzinputsegmentsupportb) circle [radius=.5ex];
            \coordinate (ConA) at (\tikzinputsegmentsupporta);
            \coordinate (ConB) at (\tikzinputsegmentsupportb);
        }
      },
      decorate
}}}
\begin{document}
\begin{tikzpicture}[->, shorten <=0.2 cm, shorten >=0.3 cm]
\coordinate (A) at (0,0);
\coordinate (B) at (2,4);
\coordinate (C) at (4,0);
\fill (A) circle[radius=0.1 cm];
\fill (B) circle[radius=0.1 cm];
\fill (C) circle[radius=0.1 cm];
\draw[thick, show curve controls] (A) to[out=80,in=50,min distance=5cm] (A); %Original curve
\draw[red] (A) .. controls +(ConA) and +(ConB) .. (A); %The same curve with control points
\end{tikzpicture}
\end{document}

One curve with control points

The same control point can also be calculated:

\draw (A) .. controls ({5*cos(80)},{5*sin(80)}) and ({5*cos(50)},{5*sin(50)}) .. (A);

A better way to draw the complete diagram would be to use calc to calculate the control points symmetrically in the desired direction. -I did not do this to keep the code simple and readable.

6
  • it is the right use of 'min distance' here
    – Black Mild
    Oct 4, 2021 at 4:49
  • @hpekkristiansen In this figure, without [min distance] of the to operation, it seems hard to control distance from node to a desired distance.
    – Black Mild
    Oct 4, 2021 at 5:13
  • @hpekkristiansen Never mind! perhaps I have not realized [min distance] until seeing your code. I often use .. controls +(P) and +(Q) .. by my habit
    – Black Mild
    Oct 4, 2021 at 5:26
  • 1
    @BlackMild: This is just an alternative way of setting the control points with angles and distance instead of coordinates. Oct 4, 2021 at 5:29
  • do you mind drawing the same figure using .. controls +(P) and +(Q) .. ?
    – Black Mild
    Oct 4, 2021 at 5:56
1

With tikz-cd:

\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}[
    column sep=6pt, 
    every matrix/.append style={name=mycd},  
    execute at end picture={
        \draw [->] plot [smooth, tension=3] coordinates { (mycd-2-1.80) (mycd-1-2.-135) (mycd-2-1.50)};
        \draw [->] plot [smooth, tension=3] coordinates { (mycd-2-3.130) (mycd-1-2.-45) (mycd-2-3.100)};
        }
    ] 
& A & \\[10pt]
B \ar[rr, bend right]\ar[loop left, <-] & & C \ar[ll, bend right]\ar[loop right]
\end{tikzcd}
\end{document}

enter image description here

And in case your node are all black points:

\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}[column sep=6pt, 
    every matrix/.append style={
        name=mycd, 
        nodes={circle, fill=black, outer sep= 2pt, inner sep=3pt}
        },  
    execute at end picture={
        \draw [->] plot [smooth, tension=3] coordinates { (mycd-2-1.80) (mycd-1-2.-135) (mycd-2-1.50)};
        \draw [->] plot [smooth, tension=3] coordinates { (mycd-2-3.130) (mycd-1-2.-45) (mycd-2-3.100)};
       }
    ] 
& {} & \\[10pt]
{} \ar[rr, bend right]\ar[loop left, <-] & & {} \ar[ll, bend right]\ar[loop right]
\end{tikzcd}
\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 .