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:

23412188487
23820375419
2953878440
134627887092
731060753931
213127805290

Subtract row minima

We subtract the row minimum from each row:

15331307679(-8)
15012294611(-8)
2620848137(-3)
03314755779(-13)
63050652921(-10)
0106593169(-21)

Subtract column minima

We subtract the column minimum from each column:

15331304768
1501229170
2620845226
03314752868
6305065010
010659258
(-29)(-11)

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

15331304768  x
1501229170  x
2620845226  x
03314752868
6305065010  x
010659258
x

Create additional zeros

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

17331304768
1701229170
2820845226
03112732666
6505065010
08457056

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

17331304768  x
1701229170  x
2820845226  x
03112732666  x
6505065010  x
08457056  x

The optimal assignment

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

17331304768
1701229170
2820845226
03112732666
6505065010
08457056

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

23412188487
23820375419
2953878440
134627887092
731060753931
213127805290

The optimal value equals 105.