| Title: | Latin Squares in R |
|---|---|
| Description: | Completion and embedding of latin squares in R. |
| Authors: | Matthew Henderson [aut, cre] (ORCID: <https://orcid.org/0000-0001-7949-8208>) |
| Maintainer: | Matthew Henderson <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.0 |
| Built: | 2026-05-25 09:03:20 UTC |
| Source: | https://github.com/MHenderson/keedwell |
Add new columns to a latin rectangle
add_cols(R, cols, l_order, strategy = next_col_matching)add_cols(R, cols, l_order, strategy = next_col_matching)
R |
A latin rectangle |
cols |
Indices of columns to add |
l_order |
Dimension of latin square |
strategy |
Strategy for filling columns |
A latin rectangle
Input is a latin rectangle as a data frame with variables for row, column and symbol. Output is a latin square in the same format which contains the given latin rectangle in the first rows.
add_rows(R, rows, strategy = next_row_matching)add_rows(R, rows, strategy = next_row_matching)
R |
latin rectangle |
rows |
empty rows to be filled |
strategy |
row filling strategy |
Use can optionally provide a vector of row indices. Only those rows will be filled if that optional vector is provided.
A latin rectangle
Constructs a data frame representing the edges of a bipartite graph based on a latin rectangle where the graph has an edge for every symbol not already used in a column.
edge_tbl(R, i, l_order = 3)edge_tbl(R, i, l_order = 3)
R |
latin rectangle |
i |
column |
l_order |
size of latin square R is going to be embedded into |
Acutally, this is just for one column.
The edge data frame.
Symbols missing from rows data frame
edge_tbl_2(R, i, l_order = 3)edge_tbl_2(R, i, l_order = 3)
R |
latin rectangle |
i |
row index |
l_order |
size of latin square R is going to be embedded into |
The edge data frame.
First row in in natural order
first_row_natural(n)first_row_natural(n)
n |
Number of columns |
A 1 x n latin rectangle with first row 1,...,n
Matching strategy for adding new columns
next_col_matching(R, i, l_order)next_col_matching(R, i, l_order)
R |
a latin rectangle |
i |
column index |
l_order |
dimension |
a latin rectangle with more columns
Random strategy for choosing a new columns
next_col_random(R, i, l_order)next_col_random(R, i, l_order)
R |
a latin rectangle |
i |
column index |
l_order |
dimension |
A latin rectangle with more columns
Given an input latin rectangle this function will generate a new row that can be added to the latin rectangle.
next_row_matching(R, i, l_order)next_row_matching(R, i, l_order)
R |
A latin rectangle |
i |
Number of columns to add |
l_order |
Order of R |
The method used is to create a bipartite graph with vertex partitions for columns and symbols missing from columns and then find a maximum matching in that bipartite graph.
A latin rectangle with more rows.
Find a random new row for a latin rectangle
next_row_random(R, i, l_order)next_row_random(R, i, l_order)
R |
A latin rectangle |
i |
Number of columns to add |
l_order |
Order of R |
A latin square with more rows.
Input is a latin rectangle as a data frame with variables for row, column and symbol. Output is a tidygraph representing the bipartite graph with vertices for columns and symbols and edges representing symbols missing from columns.
to_tidygraph(R, l_order = 3)to_tidygraph(R, l_order = 3)
R |
A latin rectangle. |
l_order |
Order of R. |
A bipartite graph.
Symbols missing from rows bipartite graph
to_tidygraph_2(R, l_order, n_rows, n_cols)to_tidygraph_2(R, l_order, n_rows, n_cols)
R |
A latin rectangle. |
l_order |
Order of R. |
n_rows |
Number of rows. |
n_cols |
Number of columns. |
A bipartite graph.