function [C,T]=hungarian(A) %HUNGARIAN Solve the Assignment problem using the Hungarian method. %通过交替路径的方法来寻找增广路径,并不断更新二分图的匹配信息,直到无法找到增广路径为止 %[C,T]=hungarian(A) %A - a square cost matrix. %C - the optimal assignment. %T - the cost of the optimal assignment. %s.t. T = trace(A(C,:)) is minimized over all possible assignments. % Adapted from the FORTRAN IV code in Carpaneto and Toth, "Algorithm 548: % Solution of the assignment problem [H]", ACM Transactions on % Mathematical Software, 6(1):104-111, 1980. % v1.0 96-06-14. Niclas Borlin, niclas@cs.umu.se. % Department of Computing Science, Umeå University, % Sweden. % All standard disclaimers apply. % A substantial effort was put into this code. If you use it for a % publication or otherwise, please include an acknowledgement or at least % notify me by email. /Niclas
时间: 2024-02-16 08:01:20 浏览: 137
二分图匹配的匈牙利算法
4星 · 用户满意度95%
Borlin/
这是一个用于解决指派问题(Assignment problem)的 MATLAB 函数,实现了匈牙利算法(Hungarian method)。输入参数 A 是一个方阵,表示指派问题的代价矩阵。输出参数 C 是最优指派方案,T 是对应的最小代价。该函数的实现参考了 Carpaneto 和 Toth 的 FORTRAN IV 代码,并经过了作者的改进。
阅读全文