R/map_layout_matching.R

Defines functions layout_tbl_graph_matching

Documented in layout_tbl_graph_matching

#' Matching layout
#' @description
#'   This layout works to position nodes opposite their matching nodes.
#'   See `manynet::to_matching()` for more details on the matching procedure.
#' @param .data Some `{manynet}` compatible network data.
#' @param center,circular,times Extra parameters required for `{tidygraph}`
#'   compatibility.
#' @returns Returns a table of nodes' x and y coordinates.
#' @export
layout_tbl_graph_matching <- function(.data,
                                      center = NULL,
                                      circular = FALSE,
                                      times = 1) {
  hlay <- manynet::layout_tbl_graph_hierarchy(.data)
  matchd <- manynet::as_edgelist(manynet::to_unnamed(manynet::to_matching(.data)))
  hlay[matchd$to,"x"] <- hlay[matchd$from,"x"]
  hlay
}

Try the autograph package in your browser

Any scripts or data that you put into this service are public.

autograph documentation built on July 2, 2025, 5:09 p.m.