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:

77530101369
629857402820
47638677068
454515467
793229668414
361590662559

Subtract row minima

We subtract the row minimum from each row:

068233662(-7)
4278372080(-20)
41032616462(-6)
410475023(-4)
65181552700(-14)
21075511044(-15)

Subtract column minima

We subtract the column minimum from each column:

06880462
4278221760
41017586262
410324703
6518049680
2106048844
(-15)(-3)(-2)

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

06880462  x
4278221760  x
41017586262
410324703  x
6518049680  x
2106048844
x

Create additional zeros

The number of lines is smaller than 6. The smallest uncovered number is 8. We subtract this number from all uncovered elements and add it to all elements that are covered twice:

07680462
4286221760
3309505454
418324703
6526049680
1305240036

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

07680462  x
4286221760  x
3309505454
418324703
6526049680  x
1305240036
xx

Create additional zeros

The number of lines is smaller than 6. The smallest uncovered number is 3. We subtract this number from all uncovered elements and add it to all elements that are covered twice:

07980762
4289221790
3006475451
388294400
6529049710
1004937033

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

07980762  x
4289221790
3006475451
388294400
6529049710  x
1004937033
xxx

Create additional zeros

The number of lines is smaller than 6. The smallest uncovered number is 6. We subtract this number from all uncovered elements and add it to all elements that are covered twice:

085801368
3689161190
2400415451
328233800
6535049776
404331033

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

085801368  x
3689161190
2400415451
328233800
6535049776
404331033
xxxx

Create additional zeros

The number of lines is smaller than 6. The smallest uncovered number is 4. We subtract this number from all uncovered elements and add it to all elements that are covered twice:

0891201772
328916790
2000375451
288233400
6135045776
004327033

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

0891201772  x
328916790  x
2000375451  x
288233400  x
6135045776  x
004327033  x

The optimal assignment

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

0891201772
328916790
2000375451
288233400
6135045776
004327033

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

77530101369
629857402820
47638677068
454515467
793229668414
361590662559

The optimal value equals 107.