assignment.greedy_assignment
def greedy_assignment(cost_matrix: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]Assign rows to columns by repeatedly picking the cheapest free pair.
Sorts the flattened cost matrix once and walks it in ascending order,
claiming each ``(row, col)`` whose endpoints are still free. Non-finite
entries terminate the scan, so callers can mark forbidden pairs by
setting them to ``inf``.
Parameters
| Name | Type | Description |
|---|---|---|
| cost_matrix | torch.Tensor | ``(N, M)`` 2-D cost matrix. |
Returns
torch.Tensor — ``(K, 2)`` long tensor of matched ``(row, col)`` indices.
Source: unitrack/assignment/_greedy.py:36