Skip to content

Commit

Permalink
feat: allows skipping initial layout precomputation
Browse files Browse the repository at this point in the history
  • Loading branch information
daniloimparato committed Oct 11, 2024
1 parent ea2b645 commit 9a15db1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 8 additions & 1 deletion R/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#' base package itself.
#'
#' @param graph An igraph object representing the network to be laid out.
#' @param layout Optional initial layout supplied by the user.
#' @param precompute Whether or not to skip precomputing the initial layout.
#' @return A two column matrix with XY coordinates and N rows, where N is
#' the number of vertices in the graph.
#' @examples
Expand All @@ -20,7 +22,7 @@
#' plot(g)
#' }
#' @export
easylayout <- function(graph) {
easylayout <- function(graph, layout = NULL, precompute = TRUE) {
# Nodes must have some sort of identifier.
# Falls back to 1, 2, 3... if "name" is not available.
if (is.null(igraph::V(graph)$name)) {
Expand All @@ -40,6 +42,11 @@ easylayout <- function(graph) {
return(start_app(graph, cached_layout$layout))
}

if (!precompute) {
print("Skipping layout precomputation...")
return(start_app(graph))
}

# Magic precomputing
vertices <- igraph::as_data_frame(graph, "vertices")
numeric_columns <- vertices |>
Expand Down
6 changes: 5 additions & 1 deletion man/easylayout.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9a15db1

Please sign in to comment.