2

I'm trying to convert this picture of a Cayley graph into latex, but I'm not sure how to create my own image. Is there any easy-to-use software that allows users to make Cayley diagrams in latex?

Thanks.

Cayley graph

cfr
  • 198,882
Trevor
  • 37
  • 1
    Welcome to TeX.SX! You can certainly use tikz to do this. Some people on this site take exception to questions of the form "Please draw this for me". You will get more help if you post some code showing what you have tried and give a minimal working example. –  Apr 28 '16 at 00:04
  • 1
    Maybe you're right that some would take exception to such a question. But you'll notice that question was not asked here. The question was "Is there any easy-to-use software that allows users to make Cayley diagrams in latex?" – nonremovable Apr 28 '16 at 00:29
  • @nonremovable "easy-to-use" is a bit subjective though, and therefore rather counter to the usual spirit of useful questions on this site. – Thruston Apr 28 '16 at 08:17
  • 1
    There are many Latex-friendly drawing tools - but it's almost impossible for anyone here to guess whether anyone else would find them easy to use. For some people TikZ is very easy, others find it impossible. If you want something point-and-click, then this has been asked before. – Thruston Apr 28 '16 at 08:18

2 Answers2

7

Here's a version of your Cayley diagram done with Metapost and luamplib.

enter image description here

You need to compile the source below with lualatex in order to use the built in Metapost engine. If you are using a different LaTeX engine, you can easily adapt this solution to work with plain Metapost. Follow the links above for details.

Whether this is "easy-to-use" of course depends on your background and skills. The advantages are that you get a very precise result. The only tricky bit of this program is the function to draw the connections, but there's nothing in there that's not explained in the various Metapost tutorials and manuals linked above.

\documentclass[border=5mm]{standalone}
\usepackage{unicode-math}
\setmathfont{TeX Gyre Schola Math}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
    vardef connect(expr a,b, txt, shade) = 
      save p; path p; p = a { (b-a) rotated 24 } .. b;
      save m; numeric m; m = arctime (arclength(p)+ahlength)/2 of p;
      drawarrow subpath(0,m) of p cutbefore fullcircle scaled 20 shifted a withcolor shade;
      draw      subpath(m,1) of p cutafter  fullcircle scaled 20 shifted b withcolor shade;
      label(txt, point m of p shifted (unitvector(direction m of p) rotated 90 scaled 8)) withcolor shade;
    enddef;

    beginfig(1);
       path inside, outside;
       inside = reverse fullcircle scaled 100 rotated 90;
       z0 = point 0   of inside;
       z1 = point 1.6 of inside;
       z2 = point 3.2 of inside;
       z3 = point 4.8 of inside;
       z4 = point 6.4 of inside;

       outside = inside scaled 1.8;
       z10 = point 0   of outside;
       z11 = point 1.6 of outside;
       z12 = point 3.2 of outside;
       z13 = point 4.8 of outside;
       z14 = point 6.4 of outside;

       label("$e$"  , z0);
       label("$r_1$", z1); 
       label("$r_2$", z2); 
       label("$r_3$", z3); 
       label("$r_4$", z4); 

       label("$d_1$", z10);
       label("$d_4$", z11); 
       label("$d_2$", z12); 
       label("$d_5$", z13); 
       label("$d_3$", z14); 

       connect(z0,z1, "$r$", 1/2 red+blue);
       connect(z1,z2, "$r$", 1/2 red+blue);
       connect(z2,z3, "$r$", 1/2 red+blue);
       connect(z3,z4, "$r$", 1/2 red+blue);
       connect(z4,z0, "$r$", 1/2 red+blue);

       connect(z10,z11, "$r$", 1/2 red+blue);
       connect(z11,z12, "$r$", 1/2 red+blue);
       connect(z12,z13, "$r$", 1/2 red+blue);
       connect(z13,z14, "$r$", 1/2 red+blue);
       connect(z14,z10, "$r$", 1/2 red+blue);

       connect(z0,z10, "$d$", 2/3 blue); connect(z10,z0, "$d$", 2/3 blue);
       connect(z1,z11, "$d$", 2/3 blue); connect(z11,z1, "$d$", 2/3 blue);
       connect(z2,z12, "$d$", 2/3 blue); connect(z12,z2, "$d$", 2/3 blue);
       connect(z3,z13, "$d$", 2/3 blue); connect(z13,z3, "$d$", 2/3 blue);
       connect(z4,z14, "$d$", 2/3 blue); connect(z14,z4, "$d$", 2/3 blue);

    endfig;
\end{mplibcode}
\end{document}
Thruston
  • 42,268
7

Probably not perfect, but a step in the right direction:

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{decorations.markings,arrows.meta}
\begin{document}
\begin{tikzpicture}[mid arrow/.style={postaction={
  decoration={markings, mark=at position 0.5 with {\arrow{Triangle}}},
  decorate}},looseness=0.5]
\foreach \i [count=\j, count=\r from 0] in {1, 4, 2, 5, 3}{
   \node (d\j) at (90+72-\j*72:3) {$d_\i$};
   \node (r\j) at (90+72-\j*72:3/2) {$\ifnum\i=1e\else r_\r\fi$};
}
\foreach \i [evaluate={\j=int(mod(\i, 5)+1);}] in {1,...,5}{
  \draw [purple, mid arrow] (d\i) to [bend left] node [auto] {$r_1$} (d\j);
  \draw [purple, mid arrow] (r\i) to [bend left] node [auto] {$r_1$} (r\j);
  \draw [blue, mid arrow]   (r\i) to [bend left] node [auto] {$d_1$} (d\i);
  \draw [blue, mid arrow]   (d\i) to [bend left] node [auto] {$d_1$} (r\i);
} 
\end{tikzpicture}
\end{document}

enter image description here

Mark Wibrow
  • 70,437