以下是一个例子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}
以下是一个例子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}
为什么装饰路径无法正确渲染?我保证我没有混淆snake
和的图像zigzag
。尝试自己渲染它们。
答案1
删除rounded corners
即可解决问题:
\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}
\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}
这是一个基本的演示,它没有使用库只是为了展示这是使用依赖于短线段的装饰graphdrawing
的效果(我认为):rounded corners
\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}