Package 'keedwell'

Title: Latin Squares in R
Description: Completion and embedding of latin squares in R.
Authors: Matthew Henderson [aut, cre]
Maintainer: Matthew Henderson <[email protected]>
License: MIT + file LICENSE
Version: 0.2.0
Built: 2024-11-01 04:23:59 UTC
Source: https://github.com/MHenderson/keedwell

Help Index


Add new columns to a latin rectangle

Description

Add new columns to a latin rectangle

Usage

add_cols(R, cols, l_order, strategy = next_col_matching)

Arguments

R

A latin rectangle

cols

Indices of columns to add

l_order

Dimension of latin square

strategy

Strategy for filling columns

Value

A latin rectangle


Embed latin rectangle in a latin square

Description

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.

Usage

add_rows(R, rows, strategy = next_row_matching)

Arguments

R

latin rectangle

rows

empty rows to be filled

strategy

row filling strategy

Details

Use can optionally provide a vector of row indices. Only those rows will be filled if that optional vector is provided.

Value

A latin rectangle


Symbols missing from columns edge data frame

Description

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.

Usage

edge_tbl(R, i, l_order = 3)

Arguments

R

latin rectangle

i

column

l_order

size of latin square R is going to be embedded into

Details

Acutally, this is just for one column.

Value

The edge data frame.


Symbols missing from rows data frame

Description

Symbols missing from rows data frame

Usage

edge_tbl_2(R, i, l_order = 3)

Arguments

R

latin rectangle

i

row index

l_order

size of latin square R is going to be embedded into

Value

The edge data frame.


First row in in natural order

Description

First row in in natural order

Usage

first_row_natural(n)

Arguments

n

Number of columns

Value

A 1 x n latin rectangle with first row 1,...,n


Matching strategy for adding new columns

Description

Matching strategy for adding new columns

Usage

next_col_matching(R, i, l_order)

Arguments

R

a latin rectangle

i

column index

l_order

dimension

Value

a latin rectangle with more columns


Random strategy for choosing a new columns

Description

Random strategy for choosing a new columns

Usage

next_col_random(R, i, l_order)

Arguments

R

a latin rectangle

i

column index

l_order

dimension

Value

A latin rectangle with more columns


Find a compatible row for extending a latin rectangle

Description

Given an input latin rectangle this function will generate a new row that can be added to the latin rectangle.

Usage

next_row_matching(R, i, l_order)

Arguments

R

A latin rectangle

i

Number of columns to add

l_order

Order of R

Details

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.

Value

A latin rectangle with more rows.


Find a random new row for a latin rectangle

Description

Find a random new row for a latin rectangle

Usage

next_row_random(R, i, l_order)

Arguments

R

A latin rectangle

i

Number of columns to add

l_order

Order of R

Value

A latin square with more rows.


Symbols missing from columns bipartite graph

Description

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.

Usage

to_tidygraph(R, l_order = 3)

Arguments

R

A latin rectangle.

l_order

Order of R.

Value

A bipartite graph.


Symbols missing from rows bipartite graph

Description

Symbols missing from rows bipartite graph

Usage

to_tidygraph_2(R, l_order, n_rows, n_cols)

Arguments

R

A latin rectangle.

l_order

Order of R.

n_rows

Number of rows.

n_cols

Number of columns.

Value

A bipartite graph.