Learn R Programming

cograph (version 2.7.2)

layer_similarity_matrix: Pairwise Layer Similarities

Description

Computes similarity matrix for all pairs of layers.

Usage

layer_similarity_matrix(
  layers,
  method = c("jaccard", "overlap", "cosine", "pearson")
)

lsim_matrix(layers, method = c("jaccard", "overlap", "cosine", "pearson"))

Value

A symmetric L x L matrix of pairwise similarities with the layer names as dimnames and 1 on the diagonal.

Arguments

layers

Named list of adjacency matrices (one per layer); at least two are required.

method

Comparison method: "jaccard" (default), "overlap", "cosine" or "pearson". Note that "hamming", accepted by layer_similarity, is not available here because it is a distance rather than a similarity.

Examples

Run this code
nodes <- c("A", "B", "C")
t1 <- matrix(c(0, 1, 0, 1, 0, 1, 0, 1, 0), 3, 3, dimnames = list(nodes, nodes))
t2 <- matrix(c(0, 1, 1, 1, 0, 0, 1, 0, 0), 3, 3, dimnames = list(nodes, nodes))
layers <- list(T1 = t1, T2 = t2)

layer_similarity_matrix(layers, "cosine")
layer_similarity_matrix(layers, "jaccard")

Run the code above in your browser using DataLab