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:

78482936473942
5822399989594151
7639331256307060
1965173422922243
3577465837335124
677645815679258
653385544536061
2923419529241586

Subtract row minima

We subtract the row minimum from each row:

76462716271920(-2)
360177767371929(-22)
642721044185848(-12)
248017575526(-17)
11532234139270(-24)
07158529618652(-6)
620355241505758(-3)
1482680149071(-15)

Subtract column minima

We subtract the column minimum from each column:

76462715762920
360177762281929
64272103995848
248017066526
1153223480270
07158524528652
620355236415758
148268090071
(-5)(-9)

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

76462715762920  x
360177762281929
64272103995848  x
248017066526  x
1153223480270  x
07158524528652  x
620355236415758
148268090071  x
x

Create additional zeros

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

76632715762920
1900604511212
64442103995848
265017066526
1170223480270
08858524528652
450183519244041
1425268090071

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

76632715762920  x
1900604511212  x
64442103995848  x
265017066526  x
1170223480270  x
08858524528652  x
450183519244041  x
1425268090071  x

The optimal assignment

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

76632715762920
1900604511212
64442103995848
265017066526
1170223480270
08858524528652
450183519244041
1425268090071

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

78482936473942
5822399989594151
7639331256307060
1965173422922243
3577465837335124
677645815679258
653385544536061
2923419529241586

The optimal value equals 132.