/
get_mean_distance_matrix.R
33 lines (32 loc) · 1.3 KB
/
get_mean_distance_matrix.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#' @title Mean distance matrix
#'
#' @description
#' Given a sequence of distance matrices, expected to correspond to sequential increasing values of time, calculate the average distance between any pairs of nodes
#' shortest-path (or geodesic) distance
#' @param DM_list list of distance matrices
#' @return mean-distance matrix
#' @keywords distance
#' @seealso \code{\link{get_diffusion_probability_matrix}}, \code{\link{get_distance_matrix}}
#' @references
#' De Domenico, M. (2017). Diffusion Geometry Unravels the Emergence of
#' Functional Clusters in Collective Phenomena. Physical Review Letters.
#' \doi{10.1103/PhysRevLett.118.168301}
#'
#' Bertagnolli, G., & De Domenico, M. (2020). Diffusion Geometry of Multiplex
#' and Interdependent Systems.
#' \href{https://arxiv.org/abs/2006.13032}{arxiv preprint arxiv:2006.13032}
#' @export
get_mean_distance_matrix <- function(DM_list){
#DM.list is a simple list, where each element is a distance matrix
M <- length(DM_list)
DM <- Reduce('+', DM_list) / M
class(DM) <- c("diffudist", class(DM))
return(DM)
}
#' @describeIn get_mean_distance_matrix Old deprecated function
#' @usage getMeanDistanceMatrix(DM_list)
#' @export
getMeanDistanceMatrix <- function(DM_list) {
.Deprecated("get_mean_distance_matrix")
return(get_mean_distance_matrix(DM_list))
}