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:

4660772
18746135
4192242
74937244

Subtract row minima

We subtract the row minimum from each row:

4458750(-2)
0564317(-18)
3990220(-2)
3049280(-44)

Subtract column minima

We subtract the column minimum from each column:

449530
072117
394100
30060
(-49)(-22)

Cover all zeros with a minimum number of lines

There are 4 lines required to cover all zeros:

449530  x
072117  x
394100  x
30060  x

The optimal assignment

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

449530
072117
394100
30060

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

4660772
18746135
4192242
74937244

The optimal value equals 137.