Solve an assignment problem online

Fill in the cost matrix of an assignment problem and click on 'Solve'. The optimal assignment will be determined and a step by step explanation of the hungarian algorithm will be given.

Fill in the cost matrix (random cost matrix):

Size: 3x3 4x4 5x5 6x6 7x7 8x8 9x9 10x10

Don't show the steps of the Hungarian algorithm
Maximize the total cost

This is the original cost matrix:

3188613921244277
7440567536496525
3450424786336441
27083708274152
6131663684203752
45628487959063
5869433758907983
3233133149473056

Subtract row minima

We subtract the row minimum from each row:

10674018032156(-21)
491531501124400(-25)
117914530318(-33)
16982698173051(-1)
411146166401732(-20)
39022421898457(-6)
21326021534246(-37)
192001836341743(-13)

Subtract column minima

We subtract the column minimum from each column:

9674018032156
481531501124400
017914530318
06982698173051
401146166401732
38022421898457
20326021534246
182001836341743
(-1)

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

9674018032156  x
481531501124400  x
017914530318  x
06982698173051  x
401146166401732  x
38022421898457  x
20326021534246  x
182001836341743  x

The optimal assignment

Because there are 8 lines required, the zeros cover an optimal assignment:

9674018032156
481531501124400
017914530318
06982698173051
401146166401732
38022421898457
20326021534246
182001836341743

This corresponds to the following optimal assignment in the original cost matrix:

3188613921244277
7440567536496525
3450424786336441
27083708274152
6131663684203752
45628487959063
5869433758907983
3233133149473056

The optimal value equals 157.