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:

8324603524949
20391046809475
6460312382715
168785542654
1544174849065
12385628735332
42521763579130

Subtract row minima

We subtract the row minimum from each row:

8122583304747(-2)
1029036708465(-10)
615709352412(-3)
102724936048(-6)
1103770808661(-4)
0264416614120(-12)
2535046407413(-17)

Subtract column minima

We subtract the column minimum from each column:

8122582404735
1029027708453
61570035240
102724036036
1103761808649
02644761418
253503740741
(-9)(-12)

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

8122582404735  x
1029027708453
61570035240  x
102724036036  x
1103761808649  x
02644761418  x
253503740741
x

Create additional zeros

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

8122592404735
928026698352
61571035240
102734036036
1103861808649
02645761418
243403639730

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

8122592404735  x
928026698352  x
61571035240  x
102734036036  x
1103861808649  x
02645761418  x
243403639730  x

The optimal assignment

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

8122592404735
928026698352
61571035240
102734036036
1103861808649
02645761418
243403639730

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

8324603524949
20391046809475
6460312382715
168785542654
1544174849065
12385628735332
42521763579130

The optimal value equals 76.