Hungarian

org.appliedtopology.tda4j.Hungarian
object Hungarian

Minimum-cost perfect matching on a square matrix of finite costs (the Hungarian algorithm, O(n³), by shortest augmenting paths with potentials), for BarcodeDistance.wassersteinDistance.

Attributes

Experimental
true
Source
BipartiteMatching.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Hungarian.type

Members list

Value members

Concrete methods

def minCostPerfectMatching(cost: Array[Array[Double]]): (Array[Int], Double)

cost must be square (n x n), all entries finite. Returns (assignment, totalCost) where assignment(j) is the row matched to column j, and totalCost = sum_j cost(assignment(j))(j).

cost must be square (n x n), all entries finite. Returns (assignment, totalCost) where assignment(j) is the row matched to column j, and totalCost = sum_j cost(assignment(j))(j).

Classic 1-indexed potential formulation (row/column 0 are sentinels): u/v are the row/column potentials, p(j) is the row currently assigned to column j (0 = none yet), way(j) records the augmenting path taken to reach column j so the final augmentation can be replayed.

Attributes

Source
BipartiteMatching.scala