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:

2750455972
6659947688
5373111491
8621351361
15741573

Subtract row minima

We subtract the row minimum from each row:

023183245(-27)
70351729(-59)
42620380(-11)
73822048(-13)
14730472(-1)

Subtract column minima

We subtract the column minimum from each column:

023183216
7035170
42620351
73822019
14730443
(-29)

Cover all zeros with a minimum number of lines

There are 4 lines required to cover all zeros:

023183216  x
7035170  x
42620351
73822019  x
14730443
x

Create additional zeros

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

023213216
7038170
39590048
73825019
11700140

Cover all zeros with a minimum number of lines

There are 4 lines required to cover all zeros:

023213216  x
7038170  x
39590048
73825019
11700140
xx

Create additional zeros

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

023294016
7046250
31510040
65025011
3620132

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

023294016  x
7046250  x
31510040  x
65025011  x
3620132  x

The optimal assignment

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

023294016
7046250
31510040
65025011
3620132

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

2750455972
6659947688
5373111491
8621351361
15741573

The optimal value equals 151.