adjacency_similarity: Calculate Similarity Between Two Graphs via Adjacency...

View source: R/8.net_compare.R

adjacency_similarityR Documentation

Calculate Similarity Between Two Graphs via Adjacency Matrices

Description

Computes the similarity between two igraph objects using their adjacency matrices. Supports Frobenius norm-based similarity and cosine similarity.

Usage

adjacency_similarity(g1, g2, method = "frobenius")

Arguments

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".

Value

A numeric value between 0 (no similarity) and 1 (identical graphs).

Examples

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

MetaNet documentation built on June 26, 2025, 5:07 p.m.