2

Here's an example with snake:

\documentclass{standalone}

%======================================
\usepackage{tikz}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{arrows}
\usetikzlibrary{graphs}
\usetikzlibrary{decorations.pathmorphing}
\usegdlibrary{force, layered, trees}
%======================================

\begin{document}

\tikz [rounded corners]
    \graph [spring layout, node distance=25mm]
    {
        a ->[decorate, decoration=snake]
        b -> 
        c ->
        a ->
        e -> 
        b
    };

\end{document}

snake

Here's an example with zigzag:

\documentclass{standalone}

%======================================
\usepackage{tikz}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{arrows}
\usetikzlibrary{graphs}
\usetikzlibrary{decorations.pathmorphing}
\usegdlibrary{force, layered, trees}
%======================================

\begin{document}

\tikz [rounded corners]
    \graph [spring layout, node distance=25mm]
    {
        a ->[decorate, decoration=zigzag]
        b -> 
        c ->
        a ->
        e -> 
        b
    };

\end{document}

enter image description here

Why are the decorated paths not rendered correctly? I promise I have not mixed up the images for snake and zigzag. Try rendering them yourself.

bzm3r
  • 3,196

1 Answers1

3

Removing rounded corners solves the problem:

\documentclass{standalone}

%======================================
\usepackage{tikz}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{arrows}
\usetikzlibrary{graphs}
\usetikzlibrary{decorations.pathmorphing}
\usegdlibrary{force, layered, trees}
%======================================

\begin{document}

\tikz %[rounded corners] remove this
    \graph [spring layout, node distance=25mm]
    {
        a ->[decorate, decoration=snake]
        b ->
        c ->
        a ->
        e ->
        b
    };

\end{document}

snake

\documentclass{standalone}

%======================================
\usepackage{tikz}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{arrows}
\usetikzlibrary{graphs}
\usetikzlibrary{decorations.pathmorphing}
\usegdlibrary{force, layered, trees}
%======================================

\begin{document}

\tikz %[rounded corners] remove this
    \graph [spring layout, node distance=25mm]
    {
        a ->[decorate, decoration=zigzag]
        b ->
        c ->
        a ->
        e ->
        b
    };

\end{document}

zigzag

Here's a basic demonstration which doesn't use the graphdrawing library just to show this is an effect of using rounded corners with decorations which rely on short line segments (I think):

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}

\begin{document}

\begin{tikzpicture} 
    \draw (0,0) [decorate, decoration=snake] -> (1,0);
    \draw (0,-.25) [decorate, decoration=zigzag] -> (1,-.25);
    \draw (0,-.5) [decorate, decoration=snake, rounded corners] -> (1,-.5);
    \draw (0,-.75) [decorate, decoration=zigzag, rounded corners] -> (1,-.75);
\end{tikzpicture}

\end{document}

Minimal demo

cfr
  • 198,882
  • Why does removing rounded corners solve the issue? – bzm3r May 20 '14 at 18:53
  • @user89 I'm not sure but on pp 151-2 of the tikz manual it mentions that rounded corners has pitfalls. One of these is that if the line segments are very short, it may cause 'inadvertent effects' which I suspect is what you are seeing ;). By the way, it has nothing to do with use of the graphdrawing library. You can reproduce it using just the decorations.pathmorphing library and drawing a couple of horizontal lines. If you want to keep rounded corners for the picture, you can use sharp corners when you need to switch the effect off temporarily. – cfr May 20 '14 at 22:25
  • Ah! I will try to rename the question then so that the focus isn't on the graphdrawing library. – bzm3r May 20 '14 at 22:38
  • 1
    @user89 I've also added an example which doesn't load any other tikz libraries but demonstrates the difference rounded corners makes. – cfr May 20 '14 at 22:42
  • 1
    if the path that needs to be rounded is shorter than the radius of the corner then an arc is drawn blindly and the path jumps back to the original corner. – percusse May 20 '14 at 22:43