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:

53514774888
436849148766
39173650479
6838576577
3765717396
83733853218

Subtract row minima

We subtract the row minimum from each row:

4809724383(-5)
29543507352(-14)
35133246075(-4)
6508273274(-3)
3210666891(-5)
75653045130(-8)

Subtract column minima

We subtract the column minimum from each column:

1909724383
0543507352
6133246075
3608273274
310666891
46653045130
(-29)

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

1909724383
0543507352  x
6133246075  x
3608273274
310666891  x
46653045130  x
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:

1707704181
0563507352
6153246075
3408071072
330666891
46673045130

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

1707704181
0563507352  x
6153246075
3408071072
330666891  x
46673045130  x
xx

Create additional zeros

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

1101644175
0623507952
0152640069
2807465066
390667491
46733045190

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

1101644175  x
0623507952  x
0152640069  x
2807465066  x
390667491  x
46733045190  x

The optimal assignment

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

1101644175
0623507952
0152640069
2807465066
390667491
46733045190

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

53514774888
436849148766
39173650479
6838576577
3765717396
83733853218

The optimal value equals 76.