birewire.similarity {BiRewire} | R Documentation |
Compute the Jaccard similarity index between two binary matrices with the same number of non-null entries and the sam row- and column-wise sums. The function accept also two igraph objects.
birewire.similarity( m1,m2)
m1 |
First matrix or graph; |
m2 |
Second matrix or graph. |
The Jaccard index between two sets M and N is defined as:
{|M \cup N|}/{|M \cap N |}
With M and N binary matrices, the Jaccard index is computed as:
\frac{∑ N_{i,j} \wedge M_{i,j}}{ ∑ N_{i,j} \vee M_{i,j}}.
The Jaccard index ranges between 0 and 1 and since 3.6.0 can be computed also among matrix with NAs.
Returns the Jaccard similarity index between the objects.
Andrea Gobbi
Maintainer: Andrea Gobbi <gobbi.andrea@mail.com>
library(igraph) library(BiRewire) g <- graph.bipartite( rep(0:1,length=10), c(1:10)) g2=birewire.rewire.bipartite(g) birewire.similarity(get.incidence(g,sparse=FALSE),get.incidence(g2,sparse=FALSE)) birewire.similarity(g,g2)