Skip to content

Commit

Permalink
finish new figures for chapter 2
Browse files Browse the repository at this point in the history
  • Loading branch information
MHenderson committed May 11, 2023
1 parent 4651969 commit 0c7778c
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 79 deletions.
4 changes: 1 addition & 3 deletions R/one_factorisation_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ one_factorisation_plot <- function() {

g <- igraph::make_full_graph(6)

gt <- tidygraph::as_tbl_graph(g) %>%
tidygraph::activate(edges) %>%
dplyr::mutate(label = rep(1, 15))
gt <- tidygraph::as_tbl_graph(g)

gtc <- gt %>%
tidygraph::activate(edges) %>%
Expand Down
81 changes: 55 additions & 26 deletions R/orthogonal_one_factorisation_plot.R
Original file line number Diff line number Diff line change
@@ -1,36 +1,65 @@
orthogonal_one_factorisation_plot <- function() {

g <- igraph::make_full_graph(6)
g <- igraph::make_full_graph(8)

igraph::V(g)$name <- LETTERS[1:6]
igraph::E(g)$name <- 1:15
gt <- tidygraph::as_tbl_graph(g)

f1 <- c(1, 11, 14)
f2 <- c(3, 6, 15)
f3 <- c(5, 8, 10)
f4 <- c(2, 9, 13)
f5 <- c(4, 7, 12)
gtc1 <- gt %>%
tidygraph::activate(edges) %>%
dplyr::mutate(
f = c(1, 2, 3, 4, 5, 6, 7,
3, 2, 5, 4, 7, 6,
1, 6, 7, 4, 5,
7, 6, 5, 4,
1, 2, 3,
3, 2,
1)
)

igraph::E(g)[f1]$onefactor <- "red"
igraph::E(g)[f2]$onefactor <- "blue"
igraph::E(g)[f3]$onefactor <- "green"
igraph::E(g)[f4]$onefactor <- "orange"
igraph::E(g)[f5]$onefactor <- "black"
gtc2 <- gt %>%
tidygraph::activate(edges) %>%
dplyr::mutate(
f = c(4, 6, 3, 5, 7, 1, 2,
7, 2, 1, 3, 5, 6,
5, 2, 1, 4, 3,
7, 4, 6, 1,
6, 3, 4,
2, 5,
7)
)

p1 <- ggraph::ggraph(g, layout = 'kk') +
ggraph::geom_node_text(ggplot2::aes(label = name), size = 4) +
ggraph::geom_edge_link(ggplot2::aes(label = name, edge_colour = onefactor),
show.legend = FALSE,
angle_calc = 'along',
label_dodge = ggplot2::unit(2.5, 'mm'),
label_push = ggplot2::unit(-6.0, 'mm'),
start_cap = ggraph::circle(4, 'mm'),
end_cap = ggraph::circle(4, 'mm'),
label_colour = "blue") +
ggraph::theme_graph(foreground = 'steelblue', fg_text_colour = 'white')
p1 <- ggraph::ggraph(gtc1, layout = 'circle') +
ggraph::geom_node_point(size = 4) +
ggraph::geom_edge_link(
mapping = ggplot2::aes(label = f, edge_colour = f),
show.legend = FALSE,
angle_calc = 'along',
label_dodge = ggplot2::unit(3.5, 'mm'),
label_push = ggplot2::unit(-6.0, 'mm'),
start_cap = ggraph::circle(4, 'mm'),
end_cap = ggraph::circle(4, 'mm'),
label_colour = "blue",
edge_width = 2,
label_size = 6
) +
ggraph::facet_edges(~f)

p2 <- p1 + ggraph::facet_edges(~factor)
p2 <- ggraph::ggraph(gtc2, layout = 'circle') +
ggraph::geom_node_point(size = 4) +
ggraph::geom_edge_link(
mapping = ggplot2::aes(label = f, edge_colour = f),
show.legend = FALSE,
angle_calc = 'along',
label_dodge = ggplot2::unit(3.5, 'mm'),
label_push = ggplot2::unit(-6.0, 'mm'),
start_cap = ggraph::circle(4, 'mm'),
end_cap = ggraph::circle(4, 'mm'),
label_colour = "blue",
edge_width = 2,
label_size = 6
) +
ggraph::facet_edges(~f)

p1
p1 / p2

}
4 changes: 4 additions & 0 deletions _targets.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ list(
name = orthogonal_one_factorisation_fig,
command = orthogonal_one_factorisation_plot()
),
tar_target(
name = orthogonal_one_factorisation_fig_file,
command = ggplot2::ggsave("figure/orthogonal_one_factorisation.pdf", plot = orthogonal_one_factorisation_fig, width = 8, height = 8)
),
tar_knit(
name = room_tex,
path = "room.Rnw"
Expand Down
13 changes: 7 additions & 6 deletions _targets/meta/meta
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ name|type|data|command|depend|seed|path|time|size|bytes|format|repository|iterat
complete_graph_fig|stem|b99248a09b239f9d|51e25aae93e5c254|e9000e4f304f30b7|-103651696||t19487.7107360239s|2406450afc03cd2b|91087|rds|local|vector|||0.047||
complete_graph_fig_file|stem|06cb0c0f0eca3613|a6e5114b998faa03|4c6c8db2bf0e1aec|-1692498324||t19487.7107473203s|dff9495c51b724c1|77|rds|local|vector|||0.283||
complete_graph_plot|function|a480007d61cb4b10|||||||||||||||
one_factorisation_fig|stem|8a8305b21769122f|1fee88e3d0b170a8|d1dc80e47d787995|-1429099058||t19487.7107376906s|b0398c02170c7a99|143029|rds|local|vector|||0.043||
one_factorisation_fig_file|stem|6ff76b4a23152265|f87cd30b4d121e6a|57fd19cc528dfafc|-1709970623||t19487.7154626834s|6281f79619f6778a|80|rds|local|vector|||0.577|1m22mUsing the size aesthetic in this geom was deprecated in ggplot2 3.4.0.36mℹ39m Please use linewidth in the default_aes field and elsewhere instead.|
one_factorisation_plot|function|fb11b42db7055729|||||||||||||||
orthogonal_one_factorisation_fig|stem|16f26a8a0fcd884d|e0293d63f58739dd|569490652f1e00cc|-1045084297||t19487.7107328295s|8a3557bdef044ce5|151981|rds|local|vector|||0.835||
orthogonal_one_factorisation_plot|function|96cb8e792f30a898|||||||||||||||
room_tex|stem|118c7dc0687dbbfe|c5ef48dde677fb15|ed71f2d40c77d1dd|-23973361|room.tex*room.Rnw|t19487.7181806689s|7b0ccdb3e84de25d|198777|file|local|vector|||1.428||
one_factorisation_fig|stem|84d0239cd9b30827|1fee88e3d0b170a8|1abff12a869d6d87|-1429099058||t19488.4449005607s|257ad5f68254e5b7|142989|rds|local|vector|||0.046||
one_factorisation_fig_file|stem|6ff76b4a23152265|f87cd30b4d121e6a|d853e8f783ef2f03|-1709970623||t19488.4449515332s|6281f79619f6778a|80|rds|local|vector|||0.49||
one_factorisation_plot|function|d64d0ccec9eaa6a2|||||||||||||||
orthogonal_one_factorisation_fig|stem|050a62f87feca6a6|e0293d63f58739dd|b87cd1cfddc5ee8d|-1045084297||t19488.4448983385s|59c0883c7cdd4600|151364|rds|local|vector|||0.849||
orthogonal_one_factorisation_fig_file|stem|8ce309d1de9ee57d|24d4057c9dbebd8e|8ff8ee9b649b8360|-678393291||t19488.4449156534s|e961a0bcff3caad6|91|rds|local|vector|||1.297|Using the size aesthetic in this geom was deprecated in ggplot2 3.4.0.ℹ Please use linewidth in the default_aes field and elsewhere instead.|
orthogonal_one_factorisation_plot|function|dcfe9e030d4e0bb4|||||||||||||||
room_tex|stem|bccb328361466968|1ad8de4483c80f15|4577a5eaaa618f60|-23973361|room.tex*room.Rnw|t19488.4481137253s|14469f93f2512bc3|198301|file|local|vector|||0.966||
two_one_factors_fig|stem|0aa569881d7161eb|f0979edb2f66a5ac|fba3863c64269ef4|346093151||t19487.7107347276s|2a4504ccf4b024bc|96128|rds|local|vector|||0.081||
two_one_factors_fig_file|stem|908f9011dd2e1f04|17167c0ed623ae6b|41f5107a467f936c|-202751565||t19487.710743987s|c852eab37a726e04|78|rds|local|vector|||0.533|1m22mUsing the size aesthetic in this geom was deprecated in ggplot2 3.4.0.36mℹ39m Please use linewidth in the default_aes field and elsewhere instead.|
two_one_factors_plot|function|66584c000622211f|||||||||||||||
24 changes: 13 additions & 11 deletions chapters/02_graph_theoretic.Rnw
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ means being connected by an edge. The
$K_n$ is the graph on $n$ vertices in which all distinct
vertices are adjacent.

<<complete-graph, fig.cap = "$K_4$ and $K_5$">>=
targets::tar_read("complete_graph_fig")
@
\begin{figure}
\begin{centering}
\includegraphics[width=0.8\textwidth, center]{figure/complete_graph.pdf}
\end{centering}
\end{figure}

A
\emph{one-factor}
Expand All @@ -27,9 +29,11 @@ Two possible one-factors of $K_4$ are:
$$f_1 = \{12,34\},\, f_2 = \{13,24\}$$
\end{example}

<<two-one-factors, fig.cap = "Two one-factors of $K_{4}$">>=
targets::tar_read("two_one_factors_fig")
@
\begin{figure}
\begin{centering}
\includegraphics[width=0.8\textwidth, center]{figure/two_one_factors.pdf}
\end{centering}
\end{figure}

A
\emph{one-factorisation}
Expand Down Expand Up @@ -66,10 +70,6 @@ $G$,
shown in Figure~\ref{fig:one-factorisation}.
\end{example}

<<one-factorisation, fig.cap = "One-factorisation of $K_6$", warning=FALSE, message=FALSE>>=
targets::tar_read("orthogonal_one_factorisation_fig")
@

Two one factors $f$ and $l$ are said to be
\emph{orthogonal}
if $f \cap l$ contains at most one edge. Two one-factorisations
Expand Down Expand Up @@ -112,7 +112,9 @@ in
\eqref{eq:roomsquare}

\begin{figure}
\label{fig:orthogonal}
\begin{centering}
\includegraphics[width=0.8\textwidth, center]{figure/orthogonal_one_factorisation.pdf}
\end{centering}
\end{figure}

\section{Hill-Climbing Algorithm for Room Squares}
Expand Down
Binary file removed figure/K6-1.pdf
Binary file not shown.
Binary file removed figure/complete-graph-1.pdf
Binary file not shown.
Binary file removed figure/one-factorisation-1.pdf
Binary file not shown.
Binary file modified figure/one_factorisation.pdf
Binary file not shown.
Binary file added figure/orthogonal_one_factorisation.pdf
Binary file not shown.
Binary file removed figure/two-one-factors-1.pdf
Binary file not shown.
44 changes: 11 additions & 33 deletions room.tex
Original file line number Diff line number Diff line change
Expand Up @@ -371,18 +371,12 @@ \section{Graph factorisations}
$K_n$ is the graph on $n$ vertices in which all distinct
vertices are adjacent.

\begin{knitrout}
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{figure}

{\centering \includegraphics[width=\maxwidth]{figure/complete-graph-1}

}

\caption[$K_4$ and $K_5$]{$K_4$ and $K_5$}\label{fig:complete-graph}
\begin{figure}
\begin{centering}
\includegraphics[width=0.8\textwidth, center]{figure/complete_graph.pdf}
\end{centering}
\end{figure}

\end{knitrout}

A
\emph{one-factor}
$f_i$ is a set of edges in which each vertex
Expand All @@ -393,18 +387,12 @@ \section{Graph factorisations}
$$f_1 = \{12,34\},\, f_2 = \{13,24\}$$
\end{example}

\begin{knitrout}
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{figure}

{\centering \includegraphics[width=\maxwidth]{figure/two-one-factors-1}

}

\caption[Two one-factors of $K_{4}$]{Two one-factors of $K_{4}$}\label{fig:two-one-factors}
\begin{figure}
\begin{centering}
\includegraphics[width=0.8\textwidth, center]{figure/two_one_factors.pdf}
\end{centering}
\end{figure}

\end{knitrout}

A
\emph{one-factorisation}
of the complete graph is a set of
Expand Down Expand Up @@ -440,18 +428,6 @@ \section{Graph factorisations}
shown in Figure~\ref{fig:one-factorisation}.
\end{example}

\begin{knitrout}
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{figure}

{\centering \includegraphics[width=\maxwidth]{figure/one-factorisation-1}

}

\caption[One-factorisation of $K_6$]{One-factorisation of $K_6$}\label{fig:one-factorisation}
\end{figure}

\end{knitrout}

Two one factors $f$ and $l$ are said to be
\emph{orthogonal}
if $f \cap l$ contains at most one edge. Two one-factorisations
Expand Down Expand Up @@ -494,7 +470,9 @@ \section{Graph factorisations}
\eqref{eq:roomsquare}

\begin{figure}
\label{fig:orthogonal}
\begin{centering}
\includegraphics[width=0.8\textwidth, center]{figure/orthogonal_one_factorisation.pdf}
\end{centering}
\end{figure}

\section{Hill-Climbing Algorithm for Room Squares}
Expand Down

0 comments on commit 0c7778c

Please sign in to comment.