| munkres {truecluster} | R Documentation |
Rows and columns of a cost matrix are matched such that the trace costs are minimized.
munkres(x, tieorder = TRUE, tiebreak = TRUE, decreasing = FALSE)
x |
numeric cost matrix |
tieorder |
default TRUE to order the diagonal |
tiebreak |
default TRUE to break ties at random when ordering the diagonal |
decreasing |
TRUE to order decreasing (default FALSE) |
The is a version of Munkres' hungarian method, which allows for non-square rectangular cost matrices.
A list
row |
index for reordering the rows |
col |
index for reordering the columns |
Jens Oehlschlägel
xx
tieorder, matchindex, solve_LSAP, matchClasses
rows <- 4
cols <- 6
mat <- matrix(runif(rows*cols), nrow=rows, ncol=cols)
cat("find the matching minimizing costs\n")
ind <- munkres(mat); mat[ind$row, ind$col]
cat("the same with decreasing order\n")
ind <- munkres(mat, decreasing=TRUE); mat[ind$row, ind$col]
cat("find the matchings maximizing costs\n")
ind <- munkres(-mat); mat[ind$row, ind$col]