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:

948578348579370
915856276387485
571148033777384
901655664467068
781458263596627
356640296999175
51819671123465
2017665428614268

Subtract row minima

We subtract the row minimum from each row:

039487439488461(-9)
865305771336980(-5)
560137932767283(-1)
861251620426664(-4)
69549172605718(-9)
336438094978973(-2)
50709570113364(-1)
30493711442551(-17)

Subtract column minima

We subtract the column minimum from each column:

039487439485943
865305771334462
560137932764765
861251620424146
6954917260320
336438094976455
5070957011846
3049371144033
(-25)(-18)

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

039487439485943  x
865305771334462
560137932764765  x
861251620424146  x
6954917260320  x
336438094976455  x
5070957011846
3049371144033  x
x

Create additional zeros

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

039557439485943
794605064263755
560207932764765
861258620424146
6955617260320
336445094976455
430088634139
3056371144033

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

039557439485943  x
794605064263755
560207932764765
861258620424146  x
6955617260320  x
336445094976455  x
430088634139
3056371144033  x
xx

Create additional zeros

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

040567439485943
784604963253654
550207831754664
861359620424146
6965717260320
336546094976455
420087623038
3157371144033

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

040567439485943  x
784604963253654
550207831754664
861359620424146  x
6965717260320  x
336546094976455  x
420087623038
3157371144033
xxx

Create additional zeros

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

043597439486243
754604660223651
520207528724661
861662620424446
6996017260350
336849094976755
390084590035
015734841030

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

043597439486243  x
754604660223651  x
520207528724661  x
861662620424446  x
6996017260350  x
336849094976755  x
390084590035  x
015734841030  x

The optimal assignment

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

043597439486243
754604660223651
520207528724661
861662620424446
6996017260350
336849094976755
390084590035
015734841030

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

948578348579370
915856276387485
571148033777384
901655664467068
781458263596627
356640296999175
51819671123465
2017665428614268

The optimal value equals 102.