Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hungarian algorithm in Python

Is there good implementation of Hungarian algorithm in standard python libraries?

like image 503
Ante Avatar asked Nov 02 '10 07:11

Ante


People also ask

How do you code Hungarian algorithm?

1) Find the minimum number in each row and subtract it from all elements in the row. 2) Find the minimum number in each column and subtract it from all elements in the column. 3) Cover all zeroes with minimum number of vertical and/or horizontal lines.

Why is Hungarian algorithm used?

The Hungarian Algorithm is used to find the minimum cost in assignment problems that involve assigning people to activities. To use this algorithm, we start by organizing our data into a matrix with people as the rows and activities as the columns.

Is Hungarian algorithm optimal?

This association problem can be optimally solved using the Hungarian algorithm. The Hungarian algorithm allows you to select n elements from an n by n matrix so that there is exactly one element in each row and one in each column, and the sum of the related costs is either minimized or maximized.

What do you mean by Hungarian method of assignment?

The Hungarian Method is based on the principle that if a constant is added to every element of a row and/or a column of cost matrix, the optimum solution of the resulting assignment problem is the same as the original problem and vice versa.


1 Answers

I just tried:


pip install munkres

and it worked. Here you can find a short explanation on how to use it.

I got an error trying to install "hungarian".

like image 154
jcomeau_ictx Avatar answered Sep 17 '22 00:09

jcomeau_ictx