Skip to content

Commit

Permalink
tweak TikZ config for vertices, labels and trees, improve the picture…
Browse files Browse the repository at this point in the history
…s code
  • Loading branch information
wojtask committed Dec 25, 2024
1 parent cbde6b6 commit fc96091
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 37 deletions.
2 changes: 1 addition & 1 deletion appendixb/problems/3/figures/b.tikz
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
\begin{tikzpicture}[
every node/.style = {tan vertex},
level/.append style = {sibling distance=30mm/2^#1}
level/.append style = {sibling distance=6\vertexsize/2^#1}
]
\node {}
child {node {}
Expand Down
10 changes: 6 additions & 4 deletions appendixb/sections/5/1.tex
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
See \refFigure{B.5-1}.
\begin{figure}[htb]
\subcaptionbox{\label{fig:B.5-1a}}[0.15\textwidth]{\subimport{figures/1/}{a.tikz}}
\subcaptionbox{\label{fig:B.5-1b}}[0.25\textwidth]{\subimport{figures/1/}{b.tikz}}
\subcaptionbox{\label{fig:B.5-1c}}[0.35\textwidth]{\subimport{figures/1/}{c.tikz}}
\begin{figure}[!htb]
\subcaptionbox{\label{fig:B.5-1a}}[0.5\textwidth]{\subimport{figures/1/}{a.tikz}}
\subcaptionbox{\label{fig:B.5-1b}}[0.5\textwidth]{\subimport{figures/1/}{b.tikz}}
\par\vspace{10mm}
\subcaptionbox{\label{fig:B.5-1c}}[\textwidth]{\subimport{figures/1/}{c.tikz}}
\par\vspace{10mm}
\subcaptionbox{\label{fig:B.5-1d}}[\textwidth]{\subimport{figures/1/}{d.tikz}}
\caption{\textbf{(a)}\, All the free trees with vertices $x$, $y$, and $z$.\,
\textbf{(b)}\, All the rooted trees with nodes $x$, $y$, and $z$ with $x$ as the root.\,
Expand Down
4 changes: 2 additions & 2 deletions appendixb/sections/5/figures/1/a.tikz
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
\node (root1) {$x$}
child {node {$y$}
child {node {$z$}}};
\node[right=5mm of root1] (root2) {$x$}
\node[right=1.5\vertexsize of root1] (root2) {$x$}
child {node {$z$}
child {node {$y$}}};
\node[right=5mm of root2] {$y$}
\node[right=1.5\vertexsize of root2] {$y$}
child {node {$x$}
child {node {$z$}}};
\end{tikzpicture}
4 changes: 2 additions & 2 deletions appendixb/sections/5/figures/1/b.tikz
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
\node (root1) {$x$}
child {node {$y$}
child {node {$z$}}};
\node[right=5mm of root1] (root2) {$x$}
\node[right=1.5\vertexsize of root1] (root2) {$x$}
child {node {$z$}
child {node {$y$}}};
\node[right=12mm of root2] {$x$}
\node[right=3\vertexsize of root2] {$x$}
child {node {$y$}}
child {node {$z$}};
\end{tikzpicture}
6 changes: 3 additions & 3 deletions appendixb/sections/5/figures/1/c.tikz
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
\node (root1) {$x$}
child {node {$y$}
child {node {$z$}}};
\node[right=5mm of root1] (root2) {$x$}
\node[right=1.5\vertexsize of root1] (root2) {$x$}
child {node {$z$}
child {node {$y$}}};
\node[right=12mm of root2] (root3) {$x$}
\node[right=3\vertexsize of root2] (root3) {$x$}
child {node {$y$}}
child {node {$z$}};
\node[right=20mm of root3] {$x$}
\node[right=4\vertexsize of root3] {$x$}
child {node {$z$}}
child {node {$y$}};
\end{tikzpicture}
18 changes: 9 additions & 9 deletions appendixb/sections/5/figures/1/d.tikz
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,43 @@
child {node {$y$}
child[missing]
child {node {$z$}}};
\node[right=15mm of root1] (root2) {$x$}
\node[right=3\vertexsize of root1] (root2) {$x$}
child[missing]
child {node {$y$}
child {node {$z$}}
child[missing]};
\node[right=20mm of root2] (root3) {$x$}
\node[right=4\vertexsize of root2] (root3) {$x$}
child {node {$y$}}
child {node {$z$}};
\node[right=20mm of root3] (root4) {$x$}
\node[right=4\vertexsize of root3] (root4) {$x$}
child {node {$y$}
child[missing]
child {node {$z$}}}
child[missing];
\node[right=15mm of root4] (root5) {$x$}
\node[right=3\vertexsize of root4] (root5) {$x$}
child {node {$y$}
child {node {$z$}}
child[missing]}
child[missing];
\node[below=25mm of root1] (root6) {$x$}
\node[below=5\vertexsize of root1] (root6) {$x$}
child[missing]
child {node {$z$}
child[missing]
child {node {$y$}}};
\node[right=15mm of root6] (root7) {$x$}
\node[right=3\vertexsize of root6] (root7) {$x$}
child[missing]
child {node {$z$}
child {node {$y$}}
child[missing]};
\node[right=20mm of root7] (root8) {$x$}
\node[right=4\vertexsize of root7] (root8) {$x$}
child {node {$z$}}
child {node {$y$}};
\node[right=20mm of root8] (root9) {$x$}
\node[right=4\vertexsize of root8] (root9) {$x$}
child {node {$z$}
child[missing]
child {node {$y$}}}
child[missing];
\node[right=15mm of root9] {$x$}
\node[right=3\vertexsize of root9] {$x$}
child {node {$z$}
child {node {$y$}}
child[missing]}
Expand Down
2 changes: 1 addition & 1 deletion appendixb/sections/5/figures/1/main.tikz
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\tikzset{
every node/.style = {tan vertex},
level/.append style = {sibling distance=30mm/2^#1}
level/.append style = {sibling distance=6\vertexsize/2^#1}
}
6 changes: 3 additions & 3 deletions chapter4/problems/3/figures/d.tikz
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
\begin{tikzpicture}[
level/.style = {level distance=3\vertexsize, sibling distance=16\vertexsize/2^#1},
level/.style = {level distance=2\vertexsize, sibling distance=14\vertexsize/2^#1},
level 3/.style = {edge from parent/.style = {transition edge={solid}{very densely dashed}{0.7}}},
level arrow/.style = {->, thick, blue},
total node/.style = {align=right, text width=10mm},
Expand Down Expand Up @@ -39,8 +39,8 @@
}

\node[total node, right=of leaf m] (level h total) {$\Theta(\lg n)$};
\node[total node] at (level h total |- 22) (level 2 total) {$c\lg n$};
\node[total node] at (level h total |- 2) (level 1 total) {$c\lg n$};
\node[total node] at (level h total |- 11) (level 2 total) {$c\lg n$};
\node[total node] at (level h total |- 1) (level 1 total) {$c\lg n$};
\node[total node] at (level h total |- root) (level 0 total) {$c\lg n$};

\path (level 2 total.east) -- (level h total.east) node[midway, xshift=-5mm, font=\bfseries] {$\vdots$};
Expand Down
2 changes: 1 addition & 1 deletion chapter4/sections/4/figures/1/b.tikz
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
\subimport{}{main.tikz}
\begin{tikzpicture}[
level/.append style = {sibling distance=18\vertexsize/4^#1},
level/.append style = {sibling distance=16\vertexsize/4^#1},
total node/.append style={text width=15mm}
]

Expand Down
2 changes: 1 addition & 1 deletion chapter4/sections/4/figures/1/c.tikz
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
\subimport{}{main.tikz}
\begin{tikzpicture}[
level/.append style = {sibling distance=18\vertexsize/4^#1},
level/.append style = {sibling distance=16\vertexsize/4^#1},
total node/.append style={text width=10mm}
]

Expand Down
2 changes: 1 addition & 1 deletion chapter4/sections/4/figures/1/d.tikz
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
\subimport{}{main.tikz}
\begin{tikzpicture}[
level/.append style = {sibling distance=18\vertexsize/3^#1},
level/.append style = {sibling distance=16\vertexsize/3^#1},
total node/.append style={text width=8mm}
]

Expand Down
2 changes: 1 addition & 1 deletion chapter4/sections/4/figures/1/main.tikz
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
\tikzset{
level/.style = {level distance=3\vertexsize},
level/.style = {level distance=2.5\vertexsize},
level 3/.style = {edge from parent/.style = {transition edge={solid}{very densely dashed}{0.7}}},
level arrow/.style = {->, thick, blue},
total node/.style = {align=right},
Expand Down
2 changes: 1 addition & 1 deletion chapter4/sections/4/figures/4.tikz
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
\begin{tikzpicture}[
level/.style = {level distance=3\vertexsize, sibling distance=16\vertexsize/2^#1},
level/.style = {level distance=2\vertexsize, sibling distance=14\vertexsize/2^#1},
level 3/.style = {edge from parent/.style = {transition edge={solid}{very densely dashed}{0.7}}},
level arrow/.style = {->, thick, blue},
total node/.style = {align=right, text width=10mm},
Expand Down
14 changes: 7 additions & 7 deletions clrs4e-solutions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
\setlength{\parindent}{1em}
\setlength{\labelsep}{1em}
\setlength{\marginparsep}{-40pt}
\newlength{\vertexsize}\setlength{\vertexsize}{1.3em}
\newlength{\vertexsize}\setlength{\vertexsize}{1.5em}
\newlength{\cellsize}\setlength{\cellsize}{1.3em}
%

Expand Down Expand Up @@ -323,15 +323,15 @@
font=\footnotesize,
>={Stealth[scale length=1.5, scale width=1.25]},
element/.style = {text height=1ex, text depth=.1ex, inner sep=1pt},
index/.style = {font=\scriptsize, text depth=.5ex, inner sep=0pt},
vertex/.style = {element, circle, minimum size=\vertexsize},
index/.style = {font=\scriptsize, rectangle, draw=none, fill=none, inner sep=0pt, minimum size=1ex},
vertex/.style = {element, circle, minimum size=\vertexsize, label distance=1pt},
tan vertex/.style = {vertex, fill=tan, draw=orange},
orange vertex/.style = {vertex, fill=orange, draw=darkorange},
light blue vertex/.style = {vertex, node, fill=lightblue, draw=blue},
red vertex/.style = {vertex, node, fill=red, draw=darkred},
light blue vertex/.style = {vertex, fill=lightblue, draw=blue},
red vertex/.style = {vertex, fill=red, draw=darkred},
cell/.style = {element, draw, minimum size=\cellsize},
array/.style = {matrix of nodes, column sep=-\pgflinewidth, row 1/.style={nodes=index}, row 2/.style={nodes=cell}, nodes in empty cells},
level/.style = {level distance=2\vertexsize, sibling distance=12\vertexsize/2^#1},
array/.style = {matrix of nodes, column sep=-\pgflinewidth, row 1/.style={nodes=index, row sep=.5ex}, row 2/.style={nodes=cell}, nodes in empty cells},
level/.style = {level distance=1.7\vertexsize, sibling distance=12\vertexsize/2^#1},
transition edge/.style n args = {3}{decorate, decoration={show path construction,
lineto code={
\draw[#1] (\tikzinputsegmentfirst) -- ($(\tikzinputsegmentfirst) ! #3 ! (\tikzinputsegmentlast)$);
Expand Down

0 comments on commit fc96091

Please sign in to comment.