-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathredblack.tex
122 lines (116 loc) · 2.78 KB
/
redblack.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
\documentclass[margin=0.5cm]{standalone}
\usepackage{varwidth}
%
% Cooper Pierce <[email protected]>
%
% For use in the book,
% 1. compile with latexmk,
% 2. use dvisvgm
% E.g., latexmk redblack
% && dvisvgm --no-fonts --clipjoin --bbox=papersize redblack
% && mv redblack-1.svg redblack.svg
% (for whatever reason my version of pdflatex makes a two page dvi)
%
%
\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage{forest}
\begin{document}
\pagecolor{white}
\tikzset{%
/forest,
forest node/.style={circle, inner sep=0pt, text centered},
arn n/.append style={
text=white,
font=\sffamily\bfseries,
draw=black,
fill=black,
text width=1.5em,
},
arn r/.append style={%
text=white,
font=\sffamily\bfseries,
draw=red,
fill=red,
text width=1.5em,
},
}
\forestset{%
default preamble={
for tree={
font=\sffamily,
forest node,
edge path={
\noexpand\path[color=black, -stealth', \forestoption{edge}]
(!u.parent anchor) -- (.child anchor)\forestoption{edge label};
},
l sep+=.25cm,
s sep+=.25cm,
fit=band,
}
}
}
\begin{varwidth}{\textwidth}
\begin{forest}
[, arn n
[, arn r
[+, arn r,
[a]
[b]
]
[c]
]
[d]
]
\node at (current bounding box.north west)
[draw,aspect=6]
{\emph{Case 1}};
\end{forest}\hspace{3em}
\begin{forest}
[, arn n
[, arn r
[a]
[+, arn r,
[b]
[c]
]
]
[d]
]
\node at (current bounding box.north west)
[draw,aspect=6]
{\emph{Case 2}};
\end{forest}
\vspace{2em}
\begin{forest}
[, arn n
[a]
[, arn r
[b]
[+, arn r,
[c]
[d]
]
]
]
\node at (current bounding box.north east)
[draw,aspect=6]
{\emph{Case 3}};
\end{forest}\hspace{3em}
\begin{forest}
[, arn n
[a]
[, arn r
[+, arn r,
[b]
[c]
]
[d]
]
]
\node at (current bounding box.north east)
[draw,aspect=6]
{\emph{Case 4}};
\end{forest}
\end{varwidth}
\end{document}