diplomat.utils.graph_ops.min_cost_matching

diplomat.utils.graph_ops.min_cost_matching(cost_matrix: ndarray, mode: str = 'scipy') Tuple[ndarray, ndarray][source]

Solve the minimum assignment problem. Given a cost matrix, find the optimal assignment of workers (rows) to jobs (columns).

Parameters:
  • cost_matrix – The cost matrix to find an optimal matching for.

  • mode – Backend to use “scipy” to use scipy’s solver, otherwise “internal” for internal solver.

Returns:

A tuple of 2 numpy arrays, first representing row assignments (row -> column) and second column assignments (column -> row). Note, these are inversions of each other.