Skip to content

Commit

Permalink
Merge pull request #18 from MHenderson/chapter2
Browse files Browse the repository at this point in the history
corrections to chapter 2
  • Loading branch information
MHenderson committed Jul 1, 2023
2 parents 9d40c5c + 0c7778c commit b773f76
Show file tree
Hide file tree
Showing 17 changed files with 329 additions and 217 deletions.
30 changes: 25 additions & 5 deletions R/one_factorisation_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,28 @@ one_factorisation_plot <- function() {

g <- igraph::make_full_graph(6)

ggraph::ggraph(g, layout = 'circle') +
ggraph::geom_edge_link() +
ggraph::geom_node_point()

}
gt <- tidygraph::as_tbl_graph(g)

gtc <- gt %>%
tidygraph::activate(edges) %>%
dplyr::mutate(
f = c(1, 4, 2, 5, 3, 2, 5, 3, 4, 3, 1, 5, 4, 1, 2)
)

ggraph::ggraph(gtc, 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)

}
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

}
15 changes: 9 additions & 6 deletions R/two_one_factors_plot.R
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
two_one_factors_plot <- function() {

gm <- matrix( c(1, 2, 3, 4), nc = 2, byrow = TRUE)
hm <- matrix( c(1, 3, 2, 4), nc = 2, byrow = TRUE)
g <- tidygraph::tbl_graph(nodes = tibble::tibble(name = c(1, 2, 3, 4)),
edges = tibble::tibble(from = c(1, 3), to = c(2, 4)))

g <- igraph::graph_from_edgelist(gm, directed = FALSE)
h <- igraph::graph_from_edgelist(hm, directed = FALSE)
h <- tidygraph::tbl_graph(nodes = tibble::tibble(name = c(1, 2, 3, 4)),
edges = tibble::tibble(from = c(1, 2), to = c(3, 4)))

gp <- ggraph::ggraph(g, layout = 'circle') +
ggraph::geom_edge_link() +
ggraph::geom_node_point()
ggraph::geom_node_point() +
ggraph::geom_node_label(aes(label = name))

hp <- ggraph::ggraph(h, layout = 'circle') +
ggraph::geom_edge_link() +
ggraph::geom_node_point()
ggraph::geom_node_point() +
ggraph::geom_node_label(aes(label = name))

gp + hp

}


16 changes: 16 additions & 0 deletions _targets.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,34 @@ list(
name = complete_graph_fig,
command = complete_graph_plot()
),
tar_target(
name = complete_graph_fig_file,
command = ggplot2::ggsave("figure/complete_graph.pdf", plot = complete_graph_fig, width = 2, height = 2)
),
tar_target(
name = two_one_factors_fig,
command = two_one_factors_plot()
),
tar_target(
name = two_one_factors_fig_file,
command = ggplot2::ggsave("figure/two_one_factors.pdf", plot = two_one_factors_fig, width = 6, height = 3)
),
tar_target(
name = one_factorisation_fig,
command = one_factorisation_plot()
),
tar_target(
name = one_factorisation_fig_file,
command = ggplot2::ggsave("figure/one_factorisation.pdf", plot = one_factorisation_fig, width = 5, height = 4)
),
tar_target(
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
21 changes: 12 additions & 9 deletions _targets/meta/meta
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
name|type|data|command|depend|seed|path|time|size|bytes|format|repository|iteration|parent|children|seconds|warnings|error
complete_graph_fig|stem|d7f756a1837c813d|51e25aae93e5c254|e9000e4f304f30b7|-103651696||t19486.6920742588s|54ef969d5ea32844|91088|rds|local|vector|||0.037||
complete_graph_figure|function|a480007d61cb4b10|||||||||||||||
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|aa6939de52207209|1fee88e3d0b170a8|e1e06292af9ba234|-1429099058||t19486.6920752773s|542062d09a35de2f|86133|rds|local|vector|||0.02||
one_factorisation_plot|function|790fdd285708dd6b|||||||||||||||
orthogonal_one_factorisation_fig|stem|5a198482c41f2197|e0293d63f58739dd|569490652f1e00cc|-1045084297||t19486.6920712958s|8a3557bdef044ce5|151981|rds|local|vector|||0.825||
orthogonal_one_factorisation_plot|function|96cb8e792f30a898|||||||||||||||
room_tex|stem|432d48f4610f8646|d16ca72643af0c32|e686f1d9d75ea008|-23973361|room.tex*room.Rnw|t19487.3554344618s|86b3ee2b5d760fea|198349|file|local|vector|||1.565||
two_one_factors_fig|stem|62dd37e48ddfc46a|f0979edb2f66a5ac|ee00e06580ba06e1|346093151||t19486.6920730551s|6ca6e3393dbb23e8|90585|rds|local|vector|||0.053||
two_one_factors_plot|function|43c7d164ec277730|||||||||||||||
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|||||||||||||||
2 changes: 1 addition & 1 deletion chapters/01_introduction.Rnw
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Fifteen young ladies of a school walk out three abreast for seven days in succes
In solving this problem Kirkman discovered the following square array, which he observed was a ``very curious arrangement''.

\begin{equation}
\label{eq:roomsquare}
\begin{bmatrix}
& & & hi & kl & mn & op \\
& il & mo & & np & hk & \\
Expand All @@ -21,6 +20,7 @@ In solving this problem Kirkman discovered the following square array, which he
ho & km & & ln & & ip & \\
kn & hp & & & io & & lm
\end{bmatrix}
\label{eq:roomsquare}
\end{equation}

The curiosity of this square is that each of the letters
Expand Down
Loading

0 comments on commit b773f76

Please sign in to comment.