1

我想链接数字 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}

这是输出: 图形

4

1 回答 1

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}

在此处输入图像描述

于 2019-03-01T13:18:26.387 回答