# Draw a quiver diagram with TikZ

I would like to know how to draw a quiver diagram like this one. I know there exists TikZ or something like that, but I don't know the commands or packages necessary to draw it.

As you want the arrows close to the nodes I think that you need to use a decoration. Here is one way to do it:

and here is the code:

\documentclass[border=5mm,tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.markings}

\begin{document}

\tikzset{% arrow close to the source: the 0.2 determines where the arrow is drawn
->-/.style={decoration={markings, mark=at position 0.2 with {\arrow{stealth}}},
postaction={decorate}},
}

\begin{tikzpicture}[every node/.style={circle,draw},thick]
\node(NL) at (0,0){$N$};
\node(NR) at (2,0){$N$};
\draw[->-](NL.north east)--(NR.north west);
\draw[->-](NR.south west)--(NL.south east);
\end{tikzpicture}

\end{document}

• you can set outer sep=0 of the nodes for better merging. – percusse Oct 17 '14 at 9:12
• Thanks for your help. I have an extra question... In your code (that works), how can I enlarge the circles... I mean, the whole figure?. – Patrick El Pollo Oct 21 '14 at 4:21
• @user133596 Adding scale=3 to the tikzpicture environment (that is, \begin{tikzpicture}[scale=3, every node...]') will make the picture three times larger. Adding minimum size to the node specifications will make the nodes bigger (so every node/.style={circle,draw,minimum size=16mm} or \node[minimum size=20mm](NR)...). – Andrew Oct 21 '14 at 11:18

An answer using TikZ version 3:

\documentclass[border=5mm,tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}

\pgfarrowsdeclare{:}{:}{}{}

\begin{document}

\begin{tikzpicture}[
->-/.style={arrows={:Stealth[reversed,sep=1.5ex]-}},
every node/.style={circle,draw,outer sep=0},
thick
]
\node(NL) at (0,0){$N$};
\node(NR) at (2,0){$N$};
\draw[->-](NR.north west)--(NL.north east);
\draw[->-](NL.south east)--(NR.south west);
\end{tikzpicture}

\end{document}


The line \pgfarrowsdeclare{:}{:}{}{} is used to create a "no-tip" arrow spec (see this answer). Then the special arrows are generated using arrows={:Stealth[reversed,sep=1.5ex]-} which reads as

put no tip, then a reversed Stealth tip separated by 1.5ex space from the previous and then complete the arrow with a line to destination

This style is then aliased to ->- for better readability and reusability, similarly to @Andrew's answer.

A somewhat similar PSTricks solution:

\documentclass{article}

\usepackage{xfp}

\def\quiver[#1,#2]#3#4{
\begin{figure}
\centering
\begin{pspicture}(\fpeval{2*#1+#2},\fpeval{2*#1})
\rput(#1,#1){#3}
\rput(\fpeval{#1+#2},#1){#4}
\cnode(#1,#1){#1}{A}
\cnode(\fpeval{#1+#2},#1){#1}{B}
\psset{
offset = -8pt,
nodesep = -3pt, % adjust manually
ArrowInside = ->,
ArrowInsidePos = 0.25,
arrowsize = 0.2
}
\ncline{A}{B}
\ncline{B}{A}
\end{pspicture}
\caption{A quiver diagram between #1 and #2.} % I have no idea if it's called that...
\end{figure}
}

\begin{document}

\quiver[0.5, 3.5]{$N$}{$M$}

\end{document}


All you have to do is choose the radius of the circles and the distance between them, and choose what to write in the circles (as the arguments to the \quiver command).

The "or something like that" in the OP includes Metapost, the Knuth-Hobby drawing language. Here's my attempt at your quiver diagram.

prologues := 3;
outputtemplate := "%j%c.eps";

beginfig(1);

-z1 = z2 = 40 right;

path c[];
c1 = fullcircle scaled 20 shifted z1;
c2 = fullcircle scaled 20 shifted z2;

draw c1; draw c2;
label(btex $N$ etex, z1);
label(btex $N$ etex, z2);

path a[];
s = 2/3; % 8 points in a "fullcircle" so 2/3 == 30°
a1 = point 0-s of c1 -- point 4+s of c2;
a2 = point 4-s of c2 -- point 0+s of c1;

r = 1/5;
drawarrow subpath(0,r) of a1; draw subpath (r,1) of a1;
drawarrow subpath(0,r) of a2; draw subpath (r,1) of a2;

endfig;
end.


Another PSTricks one:

\documentclass{article}

\newcommand*\quiver[3][2cm]{%
\cnodeput(0,0){A}{\strut#2}\cnodeput(#1,0){B}{\strut#3}%
\ncline[offset=-1ex,nodesep=-1pt,ArrowInside=->,ArrowInsidePos=0.3,arrowsize=0.2]{A}{B}%
\ncline[offset=-1ex,nodesep=-1pt,ArrowInside=->,ArrowInsidePos=0.3,arrowsize=0.2]{B}{A}%
\hspace{#1}}

\begin{document}

\quiver{$N$}{$n$} \par\bigskip
\quiver[3cm]{$N$}{$n$}

\end{document}


A short solution with \pstricks-add. The nodesep parameter has been adjusted manually:

\documentclass[pdf]{article}

\begin{document}

$\psset{ArrowInside=->, ArrowInsidePos=0.25, arrowinset=0.25 , linewidth=0.6pt, nodesep=-1.5pt, colsep=1.2cm, offset=1ex} \begin{psmatrix}[mnode = circle] N & N %%% \ncline{1,1}{1,2}\ncline{1,2}{1,1} \end{psmatrix}$

\end{document}


• What does the pdf option do for article in this case exactly? Does it load some package? – skpblack Oct 17 '14 at 10:47
• @skpblack: it allows for compiling directly with pdflatex, provided you use the -shell-escape (TeX Live, MacTeX) switch, or --enable-write18(MiKTeX). It tells pstricks to load the auto-pst-pdf package, whch does the job. – Bernard Oct 17 '14 at 10:53

Just for fun with TikZ.

\documentclass[tikz,border=12pt,12pt]{standalone}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}
\draw (-2,0) circle (12pt) (2,0) circle (12pt);
\draw[->] (60:12pt)++(-2,0) -- +(1,0);
\draw (60:12pt) ++(-1,0) ++ (-2pt,0) -- ($(120:12pt)+(2,0)$);
\draw[->] (-120:12pt) ++(2,0) -- +(-1,0);
\draw (-120:12pt) ++(1,0) ++ (2pt,0) -- ($(-60:12pt)+(-2,0)$);
\node at (-2,0) {A};
\node at (2,0) {B};
\end{tikzpicture}
\end{document}
`