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:

391163858331
672471809661
855446215984
104662634959
308910495091
64663644756

Subtract row minima

We subtract the row minimum from each row:

28052747220(-11)
43047567237(-24)
64332503863(-21)
03652533949(-10)
20790394081(-10)
04057584150(-6)

Subtract column minima

We subtract the column minimum from each column:

2805274340
43047563417
6433250043
0365253129
2079039261
0405758330
(-38)(-20)

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

2805274340  x
43047563417  x
6433250043  x
0365253129
2079039261  x
0405758330
x

Create additional zeros

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

2905274340
44047563417
6533250043
0355152028
2179039261
0395657229

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

2905274340  x
44047563417  x
6533250043  x
0355152028  x
2179039261  x
0395657229  x

The optimal assignment

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

2905274340
44047563417
6533250043
0355152028
2179039261
0395657229

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

391163858331
672471809661
855446215984
104662634959
308910495091
64663644756

The optimal value equals 141.