Nothing
# R/compute_distance.R
#' Compute the Manhattan Norm Distance Between Two Graphs
#'
#' This function calculates the Manhattan norm (L1 norm) distance between two
#' adjacency matrices representing brain networks.
#'
#' @param G A square adjacency matrix representing a brain network.
#' @param M A square adjacency matrix representing the central brain network.
#'
#' @return A numeric value representing the Manhattan distance between G and M.
#' @details The distance is \code{sum(abs(G - M))} over all matrix entries.
#' For symmetric matrices with zero diagonal, each undirected edge is
#' counted twice. This convention also sets the scale of the reported T
#' statistic; using only the upper triangle would divide both values by two.
#' @export
#'
#' @importFrom stats rbinom
#' @examples
#' # Generate synthetic data
#' G1 <- generate_random_graph(n_nodes = 5, edge_prob = 0.1)
#' G2 <- generate_random_graph(n_nodes = 5, edge_prob = 0.1)
#' central_graph <- compute_central_graph(list(G1, G2))
#' distance <- compute_distance(G1, central_graph)
compute_distance <- function(G, M) {
if (!is.matrix(G) || !is.matrix(M)) {
stop("Both G and M must be matrices.")
}
if (!all(dim(G) == dim(M))) {
stop("G and M must have the same dimensions.")
}
return(sum(abs(G - M)))
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.