TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to build a curved edge from s to a named x and a curved edge from s to b named y.

Beside the problem to >>curve<< them properly i want to give them a background like in this question or in this picture picture.

\begin{tikzpicture} [->,>=stealth',shorten >=1pt,auto,node distance=2.5cm,thick,main node/.style={circle,fill=gray!25,draw,font=\sffamily\Large\bfseries}]

    \node[main node] (1)                    {$s$};
    \node[main node] (2) [below of=1]       {a};
    \node[main node] (3) [ right of=2]      {b};
    \node[main node] (4) [below of=2]       {$t$};

    \path[every node/.style={font=\sffamily\small}]
    (2)     edge [bend left=50]     node    {$r^{-1}$}  (3)
    (3) edge [bend left=50,dashed]  node    {$r$}       (2);

    \draw (1)       .. controls +(1, -1)    and +(-1, 1) .. (2) node[midway,above left] {$x$};
    \draw (1) [dashed]  .. controls (1, 2)  and (2,0) ..        (3) node[midway,right]      {$y$};

    % \draw background here ???!


i tried many things like in the linked question but can't get a good solution. any advice?

in the end it should like like in this picture:


share|improve this question
What exactly means "properly" in your "to >>curve<< them properly"? Can you please give an objective description of what you want to achieve? – Gonzalo Medina Jul 16 '14 at 17:48
the path (edge) should be curved like a sinus function to indicate that there could be more than 1 node between the s node and its destination. – Frank Jul 16 '14 at 18:01
up vote 11 down vote accepted

Edit: answer rewritten

After seeing the intended results:

  1. For the "curved" lines, I defined a wavy style which uses snake decoration
  2. For the background grey markings, use a pgfonlayer and redraw those lines with a big line width.



  wavy/.style = {
     decoration = {snake, amplitude=1.5mm, segment length=8mm}
  main node/.style={circle,fill=gray!25,draw,font=\sffamily\Large\bfseries}

\begin{tikzpicture} [->,>=stealth',shorten >=1pt,auto,
    node distance=2.5cm,thick]

    \node[main node] (1)                    {$s$};
    \node[main node] (2) [below of=1]       {a};
    \node[main node] (3) [right of=2]       {b};
    \node[main node] (4) [below of=2]       {$t$};

    \path[every node/.style={font=\sffamily\small}]
    (2) edge [bend left=50]         node    {$r^{-1}$}  (3)
    (3) edge [bend left=50,dashed]  node    {$r$}       (2);

    \path (1)  edge[out=250, in=110, wavy]
               node[inner sep=2mm, above left] {$x$}

    \path (1) edge[out=0, in=80, wavy, dashed]
              node[inner sep=2mm, above right]   {$y$}

    % \draw background here ???!
     \begin{scope}[line width=2mm, black!30, >=, line cap=round,
      shorten >=1mm, shorten <=1mm]
        \path (1)  edge[out=250, in=110, wavy]         (2);
        \path (1) edge[out=0, in=80, wavy, black!20]   (3);



share|improve this answer
perfect! thank you! – Frank Jul 16 '14 at 18:53
Ah, no postaction ? :P – percusse Jul 16 '14 at 19:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.