Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove next_row function. #34

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions R/next-row.R
Original file line number Diff line number Diff line change
@@ -1,42 +1,3 @@
#' Find a compatible row for extending a latin rectangle
#'
#' Given an input latin rectangle this function will
#' generate a new row that can be added to the latin
#' rectangle.
#'
#' 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.
#'
#' @param R A latin square
#' @param l_order The order of the input latin square
#'
#' @return A bipartite graph.
next_row <- function(R, l_order) {
bg <- to_tidygraph(R, l_order)

m <- igraph::max_bipartite_match(bg)

# names of edges in the matching
matching_names <- match(m$matching, names(m$matching))

# add a matching indicator to the edges
bg <- bg |>
tidygraph::activate(edges) |>
dplyr::mutate(
matching = to == matching_names[from]
)

# just the matching itself, as a graph
mg <- bg |>
tidygraph::activate(edges) |>
dplyr::filter(matching)

EE <- igraph::ends(mg, igraph::E(mg))
return(as.numeric(gsub("s", "", EE[,2])))
}

#' Find a random new row for a latin rectangle
#'
#' @param R A latin rectangle
Expand Down
27 changes: 0 additions & 27 deletions man/next_row.Rd

This file was deleted.