我想绘制这样的二叉树:
我已经想出了下面的代码,但是圆的尺寸太大了。我试图减小尺寸,但是失败了,有人能告诉我怎么做吗?
\usetikzlibrary{shapes,arrows,positioning}
\usepackage{wrapfig}
\usepackage{graphicx}
\resizebox{.4\textwidth}{!}{\begin{tikzpicture}[
block/.style = {circle, draw,
text width=2em,align=center,radius=.05cm},
line/.style = {draw,thick, -latex'},
node distance=0.9cm and 0.4cm
]
% Place nodes
\node [block] (a) {a};
\node [block, below left of=a,xshift=-1.0cm, yshift=-0.3cm] (b) {b};
\node [block, below right of=a,xshift=1.0cm, yshift=-0.3cm] (c) {c};
% Draw edges
\path [line] (a) -- (b);
\path [line] (a) -- (c);
\end{tikzpicture}}
答案1
根据 Jake 评论中的建议,我替换了半径=0.05厘米比如文字宽度 = 0.05厘米。以下是您修改后的代码。
\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning}
\usepackage{wrapfig}
\usepackage{graphicx}
\begin{document}
\resizebox{.4\textwidth}{!}{\begin{tikzpicture}[
block/.style = {circle, draw,
align=center,text width = 0.1cm, inner sep = 0.1cm},
line/.style = {draw,thick, -latex'},
node distance=0.9cm and 0.4cm
]
% Place nodes
\node [block] (a) {a};
\node [block, below left of=a,xshift=-1.0cm, yshift=-0.3cm] (b) {b};
\node [block, below right of=a,xshift=1.0cm, yshift=-0.3cm] (c) {c};
% Draw edges
\path [line] (a) -- (b);
\path [line] (a) -- (c);
\end{tikzpicture}}
\end{document}
您应该得到以下输出。