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:

447985225966
14656147921
924388303964
904331614756
658167226034
136896588281

Subtract row minima

We subtract the row minimum from each row:

22576303744(-22)
10615707517(-4)
6213580934(-30)
59120301625(-31)
43594503812(-22)
05583456968(-13)

Subtract column minima

We subtract the column minimum from each column:

22456302832
1049570665
621580022
590030713
4347450290
04383456056
(-12)(-9)(-12)

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

22456302832
1049570665
621580022  x
590030713  x
4347450290  x
04383456056  x
x

Create additional zeros

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

17405802327
544520610
621585022
590035713
4347455290
04383506056

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

17405802327
544520610
621585022  x
590035713  x
4347455290
04383506056  x
xx

Create additional zeros

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

12355301827
039470560
6215810027
590040718
3842405240
04383556061

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

12355301827
039470560
6215810027  x
590040718  x
3842405240
04383556061
xxx

Create additional zeros

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

1217350027
021290380
8015828045
770058736
382422560
02565554261

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

1217350027
021290380
8015828045
770058736  x
382422560
02565554261
xxxx

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:

1216340027
020280380
8005728045
780059837
382321560
02464554261

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

1216340027  x
020280380  x
8005728045  x
780059837  x
382321560  x
02464554261  x

The optimal assignment

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

1216340027
020280380
8005728045
780059837
382321560
02464554261

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

447985225966
14656147921
924388303964
904331614756
658167226034
136896588281

The optimal value equals 184.