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:

809982971847097
8012353465329629
5918388379111254
782733613345350
849394397639386
7787876236268317
31615486044936
9960187718448882

Subtract row minima

We subtract the row minimum from each row:

799881960836996(-1)
680232253208417(-12)
4872772680143(-11)
752403310315047(-3)
041313589558578(-8)
60707045199660(-17)
2509425438870(-6)
81420590267064(-18)

Subtract column minima

We subtract the column minimum from each column:

799881740836896
68023053208317
4872750680043
752401110314947
041311389558478
60707023199650
2509205438860
81420370266964
(-22)(-1)

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

799881740836896
68023053208317  x
4872750680043  x
752401110314947
041311389558478  x
60707023199650  x
2509205438860  x
81420370266964
xx

Create additional zeros

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

688781630725785
68034064208317
4873850790043
64130010203836
0414213100558478
60708123309650
25020206538860
70310260155853

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

688781630725785
68034064208317
4873850790043  x
64130010203836
0414213100558478  x
60708123309650
25020206538860
70310260155853
xxxxx

Create additional zeros

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

598781630634885
59034064117417
48164759880052
55130010112936
0505122109558487
51708123300560
16020206529770
6131026064953

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

598781630634885  x
59034064117417  x
48164759880052  x
55130010112936  x
0505122109558487  x
51708123300560  x
16020206529770  x
6131026064953  x

The optimal assignment

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

598781630634885
59034064117417
48164759880052
55130010112936
0505122109558487
51708123300560
16020206529770
6131026064953

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

809982971847097
8012353465329629
5918388379111254
782733613345350
849394397639386
7787876236268317
31615486044936
9960187718448882

The optimal value equals 119.