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
Run the code above in your browser using DataLab