Learn R Programming

BiRewire (version 3.2.1)

birewire.similarity: 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.

Description

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.

Usage

birewire.similarity( m1,m2)

Arguments

m1
First matrix or graph;
m2
Second matrix or graph.

Value

  • Returns the Jaccard similarity index between the objects.

encoding

UTF-8

Details

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{\sum N_{i,j} \wedge M_{i,j}}{ \sum N_{i,j} \vee M_{i,j}}.$$ The Jaccard index ranges between 0 and 1.

Examples

Run this code
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)

Run the code above in your browser using DataLab