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:

2498919635
5471329925
2352949952
9485234217
5614877767

Subtract row minima

We subtract the row minimum from each row:

074677211(-24)
29467740(-25)
029717629(-23)
77686250(-17)
420736353(-14)

Subtract column minima

We subtract the column minimum from each column:

074614711
29461490
029655129
7768000
420673853
(-6)(-25)

Cover all zeros with a minimum number of lines

There are 4 lines required to cover all zeros:

074614711
29461490  x
029655129
7768000  x
420673853  x
x

Create additional zeros

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

06350360
40461490
018544018
8868000
530673853

Cover all zeros with a minimum number of lines

There are 4 lines required to cover all zeros:

06350360
40461490
018544018
8868000  x
530673853  x
xx

Create additional zeros

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

06249350
40450480
017533918
8968001
540673854

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

06249350  x
40450480  x
017533918  x
8968001  x
540673854  x

The optimal assignment

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

06249350
40450480
017533918
8968001
540673854

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

2498919635
5471329925
2352949952
9485234217
5614877767

The optimal value equals 146.