Use this if you are using igraph from R
These functions calculates similarity scores for vertices based on their connection patterns.
similarity(graph, vids = V(graph), mode = c("all", "out", "in", "total"), loops = FALSE, method = c("jaccard", "dice", "invlogweighted"))
The input graph.
The vertex ids for which the similarity is calculated.
The type of neighboring vertices to use for the calculation,
possible values: ‘
Whether to include vertices themselves in the neighbor sets.
The method to use.
The Jaccard similarity coefficient of two vertices is the number of common
neighbors divided by the number of vertices that are neighbors of at least
one of the two vertices being considered. The
calculates the pairwise Jaccard similarities for some (or all) of the
The Dice similarity coefficient of two vertices is twice the number of
common neighbors divided by the sum of the degrees of the vertices.
dice calculates the pairwise Dice similarities for some
(or all) of the vertices.
The inverse log-weighted similarity of two vertices is the number of their common neighbors, weighted by the inverse logarithm of their degrees. It is based on the assumption that two vertices should be considered more similar if they share a low-degree common neighbor, since high-degree common neighbors are more likely to appear even by pure chance. Isolated vertices will have zero similarity to any other vertex. Self-similarities are not calculated. See the following paper for more details: Lada A. Adamic and Eytan Adar: Friends and neighbors on the Web. Social Networks, 25(3):211-230, 2003.
length(vids) numeric matrix
containing the similarity scores. This argument is ignored by the
Tamas Nepusz email@example.com and Gabor Csardi firstname.lastname@example.org for the manual page.
Lada A. Adamic and Eytan Adar: Friends and neighbors on the Web. Social Networks, 25(3):211-230, 2003.
g <- make_ring(5) similarity(g, method = "dice") similarity(g, method = "jaccard")