R/similarity_aa.R

Defines functions similarity_aa

# Adamic-Adar index
#
# Similarity measure counting common neighbors weighted by their degrees.
#
# Adamic-Adar Index counts common neighbors with weigths equal to logarithms of
#   neighbors degrees. This is a wrapper to an \pkg{igraph} function
#   \code{\link[igraph]{similarity.invlogweighted}}.
#


similarity_aa <- function(graph, v1, v2, ...){
  all_v <- unique(c(v1, v2))
  score <- igraph::similarity(
    graph, 
    vids=all_v, 
    method="invlogweighted",
    ... 
    )
  r <- match(v1, all_v)
  k <- match(v2, all_v)
  score[r, k]
}
recon-icm/linkprediction documentation built on Jan. 19, 2024, 2:14 p.m.