是的,我认为有一个非常类似的问题,但没有答案。他是如何生成此处概述的论文中的图形的 http://www.cs.princeton.edu/~rs/talks/LLRB/LLRB.pdf
尝试在 TeX 中执行此操作...似乎不可能。这需要多少代码?
更新:更具体。我不想能够生成 pdf 第 3 页和第 4 页中概述的树。
答案1
希望这能帮助你入门
\documentclass[border = 5pt, tikz]{standalone}
\usetikzlibrary{shapes}
\usetikzlibrary{positioning}
\definecolor{mred}{RGB}{178,26,52}
\begin{document}
\begin{tikzpicture}[
font = \itshape,
%
node/.style = {minimum width = 1em, draw = black, circle, line width
= 0.5pt},
%
subtree/.style = {regular polygon, regular polygon sides = 3,
anchor = north, draw = black, line width = 0.5pt,
align = center, rounded corners = 6ex, outer sep = 0pt, outer sep
= 0pt, yshift = 3em, inner sep = 1pt, text
= mred, minimum width = 10em},
%
normal edge/.style = {edge from parent/.style = {black, very thick,
draw}},
%
emph edge/.style = {edge from parent/.style = {mred, line width = 3pt,
draw}},
%
level/.style = {sibling distance = 40mm/#1^0.2}
]
% tree
\node (a) [node]{$a$}
child[normal edge] {node[subtree] {less \\ than a}}
child[emph edge] {node[node] (b) {b}
child[normal edge] {node[subtree] {between \\ a and b}}
child[normal edge] {node[subtree] {greater \\ than b}}
};
% labels
\node[left = 3em, mred] (lbl h) at (a.north west){h};
\draw[->, mred] (lbl h) -- (a);
\node[above = 2em] (a par) at (a.north){};
\draw[] (a par) -- (a);
\node[right = 3em, mred, align = center] (lbl spec) at (a par.north
east){Could be right or left, \\ red or black};
\draw[->, mred] (lbl spec) -- (a par);
\node[right = 3em, mred] (lbl x) at (b.north east){\bf{x}};
\draw[->, mred] (lbl x) -- (b);
\end{tikzpicture}
\end{document}