|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Hungarian (Munkres) algorithm for the assignment problem. More...
#include <limits>#include <type_traits>#include <utility>#include <initializer_list>#include <tpl_dynMat.H>#include <tpl_array.H>#include <htlist.H>#include <ah-errors.H>#include <ahFunction.H>Go to the source code of this file.
Classes | |
| struct | Aleph::Hungarian_Result< Cost_Type > |
| Result of the Hungarian assignment algorithm. More... | |
| class | Aleph::Hungarian_Assignment< Cost_Type > |
| Hungarian (Munkres) algorithm for optimal assignment. More... | |
Namespaces | |
| namespace | Aleph |
| Main namespace for Aleph-w library functions. | |
Functions | |
| template<typename Cost_Type > | |
| Hungarian_Result< Cost_Type > | Aleph::hungarian_assignment (const DynMatrix< Cost_Type > &cost) |
| Compute minimum-cost assignment (free function). | |
| template<typename Cost_Type > | |
| Hungarian_Result< Cost_Type > | Aleph::hungarian_max_assignment (const DynMatrix< Cost_Type > &cost) |
| Compute maximum-profit assignment (free function). | |
Hungarian (Munkres) algorithm for the assignment problem.
This file implements the Hungarian algorithm, also known as the Kuhn-Munkres algorithm, for solving the assignment problem: given an m x n cost matrix, find a minimum-cost assignment of rows to columns.
The implementation uses the shortest augmenting paths variant with dual variables (potentials). For each row, a Dijkstra-like scan finds the shortest augmenting path using reduced costs c[i][j] - u[i] - v[j], then augments and updates potentials. This avoids the classical cover-lines/find-zeros Munkres steps and yields a clean, efficient O(n^3) implementation.
| Metric | Value |
|---|---|
| Time | O(n^3) where n = max(rows, cols) |
| Space | O(n^2) for the padded cost matrix |
Definition in file Hungarian.H.