增加边长

增加边长
\begin{figure}[H]
\centering
\begin{tikzpicture}[every tree node/.style={draw,circle},edge from parent path={(\tikzparentnode) -- (\tikzchildnode)},baseline]
\Tree [.\node(first) [draw, align=center] {\textbf{A} \\ \textit{\footnotesize{100 }}};
        \node(second) [draw, align=center] {\textbf{B} \\ \textit{\footnotesize{20 }}};
        \node(third) [draw, align=center, fill=orange] {\textbf{C} \\ \textit{\footnotesize{40 }}};
        \node(fourth) [draw, align=center] {\textbf{D} \\ \textit{\footnotesize{35 }}};
      ]
\begin{scope}[xshift=3in,every tree node/.style={},edge from parent path={}]
\end{scope}
\node[below]at(current bounding box.south){\textbf{Figura 2. Exemplo de Árvore Resultante}};
\end{tikzpicture}
\end{figure}

如何增加从 A 到 C 的边长?

在此处输入图片描述

答案1

您可以通过更改 来控制边的长度sibling distance。也left=, right=, above=, below=可以使用。

\begin{figure}
\centering
\begin{tikzpicture}[every tree node/.style={draw,circle}, level 1/.style={sibling distance=20mm},level 2/.style={sibling distance=20mm},edge from parent path={(\tikzparentnode) -- (\tikzchildnode)},baseline
]
\Tree [.\node(first) [draw, align=center] {\textbf{A} \\ \textit{\footnotesize{100 }}};
        \node(second) [draw, align=center] {\textbf{B} \\ \textit{\footnotesize{20 }}};
        \node(third) [draw, align=center, fill=orange,below=7mm] {\textbf{C} \\ \textit{\footnotesize{40 }}};
        \node(fourth) [draw, align=center] {\textbf{D} \\ \textit{\footnotesize{35 }}};
      ]
\begin{scope}[xshift=3in,every tree node/.style={},edge from parent path={}]
\end{scope}
\node[below]at(current bounding box.south){\textbf{Figura 2. Exemplo de Árvore Resultante}};
\end{tikzpicture}
\end{figure}

在此处输入图片描述

相关内容