View source: R/8.net_compare.R
adjacency_similarity | R Documentation |
Computes the similarity between two igraph objects using their adjacency matrices. Supports Frobenius norm-based similarity and cosine similarity.
adjacency_similarity(g1, g2, method = "frobenius")
g1 |
An igraph object representing the first graph. |
g2 |
An igraph object representing the second graph. |
method |
A character string specifying the similarity method: "frobenius" (default) or "cosine". |
A numeric value between 0 (no similarity) and 1 (identical graphs).
library(igraph)
g1 <- graph_from_edgelist(matrix(c(1, 2, 2, 3), ncol = 2, byrow = TRUE), directed = FALSE)
g2 <- graph_from_edgelist(matrix(c(1, 2, 2, 4), ncol = 2, byrow = TRUE), directed = FALSE)
adjacency_similarity(g1, g2, method = "frobenius") # Output: 0.5
adjacency_similarity(g1, g2, method = "cosine") # Output: 0.5
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.