我想链接数字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}
这是输出:
答案 0 :(得分:1)
可以通过节点的名称访问节点,因此您可以在它们之间简单地绘制箭头:
% !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}