R/convert_adj_to_edges.R

Defines functions convert_adj_to_edges

Documented in convert_adj_to_edges

#' @title Convert an adjacency matrix to an edge list
#' @description This function takes an adjacency matrix and
#' transforms it into an edge list
#' @param adj the adjacency matrix
#' @author Ilias Moutsopoulos
#' @export

convert_adj_to_edges <- function(adj){
  add_names_to_matrix(adj)
  data.frame(
    from = rep(rownames(adj), times = ncol(adj)),
    to = rep(colnames(adj), each = nrow(adj)),
    value = as.vector(adj)
  ) |>
    poorman::filter(value != 0)
}
drostlab/edgynode documentation built on March 29, 2024, 10:36 a.m.