bipartite.match: Bipartite graph matching

Description Usage Arguments Details Value Examples

View source: R/bipartite.match.R

Description

Hungarian algorithm for matching samples in a bipartite graph from a distance ("cost") matrix

Usage

1
bipartite.match(costMatrix)

Arguments

costMatrix

A distance matrix giving the cost of each possible pairing

Details

This algorithm was cloned from RcppHungarian, an Rcpp wrapper for the original C implementation by Cong Ma (2016).

Value

List of components "cost" and "parings", with pairings given as an n x 2 matrix

Examples

1
2
3
4
5
6
7
8
/dontrun{
data(moca7k)
model1 <- lsmf(moca7k[,1000:2000], k = 10)
model2 <- lsmf(moca7k[,2000:300], k = 10)
costMatrix <- 1 + 1e-10 - sparse.cos(model1$W, model2$W)
matched <- bipartite.match(costMatrix)
model2W.reordered <- model2$W[,matched$pairs[,2]]
}

zdebruine/LSMF documentation built on Jan. 1, 2021, 1:50 p.m.