[Tex/LaTex] How to get a wavy arrow for an edge


What option do I need to get a wavy arrow between two points:



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

\node[main node=black] (1) {a};
\node[main node=black](2)[right of=1]{b};

  \path[every node/.style={font=\sffamily\small}]
    (1) edge[<<<WAVY ARROW OPTION>>>, very thick, color=blue] node [] {} (2)


I assume the fix is an easy option where I've put <<<WAVY ARROW OPTION>>>.

Best Answer

enter image description here

\documentclass[tikz, border=3mm]{standalone}
\usetikzlibrary{arrows, decorations.pathmorphing}

        ->,    > = stealth',
       shorten > = 1pt,auto,
   node distance = 3cm,
      decoration = {snake,   % <-- added
                    pre length=3pt,post length=7pt,% <-- for better looking of arrow,
main node/.style = {circle,draw,fill=#1,
\node[main node=black]  (1)     {a};
\node[main node=black]  (2) [right of=1]{b};

\path[draw=blue, very thick, decorate] (1) -- node[above] {?} (2);
\draw[red] (1) -- node[below] {straight line} (2);

In your MWE I consider only for image necessary packages, i.e. only TikZ libraries. For better looking of arrow I add "complications" which make begin and end of arrow straight.

Edit: decoration is activated only on path with option decorate. Consequently red line (note: \draw is shorthand for \path[draw]), which does not have the option decorate.