使用绘图库插入箭头
Insert arrows using graphdrawing library
我想 link 数字 6 -> 5 和 5 -> 4 但我不知道该怎么做。
我的代码如下
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{graphs}
\usegdlibrary{trees}
\begin{document}
\begin{tikzpicture}[>=stealth, every node/.style={rectangle, rounded corners, draw, minimum size=0.75cm}]
\graph [tree layout, grow=down, fresh nodes, level distance=0.5in, sibling distance=0.5in]
{
Flight 0 -> {
Flight 1 -> { 4 -> , 5},
Flight 2 -> { 6 },
Flight 3 -> { 7,8 }
}
};
\end{tikzpicture}
\end{document}
这是输出:
可以通过名称访问节点,因此您可以简单地在它们之间绘制箭头:
% !TeX TS-program = lualatex
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{graphs}
\usegdlibrary{trees}
\begin{document}
\begin{tikzpicture}[>=stealth, every node/.style={rectangle, rounded corners, draw, minimum size=0.75cm}]
\graph [tree layout, grow=down, fresh nodes, level distance=0.5in, sibling distance=0.5in]
{
Flight 0 -> {
Flight 1 -> { 4 , 5},
Flight 2 -> { 6 },
Flight 3 -> { 7,8 }
}
};
\draw[->] (6) -- (5);
\draw[->] (5) -- (4);
\end{tikzpicture}
\end{document}
我想 link 数字 6 -> 5 和 5 -> 4 但我不知道该怎么做。
我的代码如下
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{graphs}
\usegdlibrary{trees}
\begin{document}
\begin{tikzpicture}[>=stealth, every node/.style={rectangle, rounded corners, draw, minimum size=0.75cm}]
\graph [tree layout, grow=down, fresh nodes, level distance=0.5in, sibling distance=0.5in]
{
Flight 0 -> {
Flight 1 -> { 4 -> , 5},
Flight 2 -> { 6 },
Flight 3 -> { 7,8 }
}
};
\end{tikzpicture}
\end{document}
这是输出:
可以通过名称访问节点,因此您可以简单地在它们之间绘制箭头:
% !TeX TS-program = lualatex
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{graphs}
\usegdlibrary{trees}
\begin{document}
\begin{tikzpicture}[>=stealth, every node/.style={rectangle, rounded corners, draw, minimum size=0.75cm}]
\graph [tree layout, grow=down, fresh nodes, level distance=0.5in, sibling distance=0.5in]
{
Flight 0 -> {
Flight 1 -> { 4 , 5},
Flight 2 -> { 6 },
Flight 3 -> { 7,8 }
}
};
\draw[->] (6) -- (5);
\draw[->] (5) -- (4);
\end{tikzpicture}
\end{document}