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:

79178479725984
1371463017984
2320515192731
46334231772248
1817799865883
25291977108591
25984091604926

Subtract row minima

We subtract the row minimum from each row:

6206762554267(-17)
1270452907883(-1)
1613444485024(-7)
241120955026(-22)
98700774974(-9)
151996707581(-10)
073156635241(-25)

Subtract column minima

We subtract the column minimum from each column:

6205862554266
1270362907882
1613354485023
241111955025
98610774973
151906707580
07366635240
(-9)(-1)

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

6205862554266  x
1270362907882  x
1613354485023
241111955025
98610774973  x
151906707580  x
07366635240  x
x

Create additional zeros

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

6205862555166
1270362908782
74263576014
1522046016
98610775873
151906708480
07366635330

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

6205862555166  x
1270362908782  x
74263576014
1522046016
98610775873
151906708480  x
07366635330  x
xx

Create additional zeros

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

6205864555366
1270363108982
52243574012
1300044014
76590755871
151906908680
07366835350

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

6205864555366
1270363108982
52243574012
1300044014
76590755871
151906908680
07366835350  x
xxxxx

Create additional zeros

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

5705864555361
770363108977
0224357407
80004409
26590755866
101906908675
078117340400

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

5705864555361  x
770363108977  x
0224357407  x
80004409  x
26590755866  x
101906908675  x
078117340400  x

The optimal assignment

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

5705864555361
770363108977
0224357407
80004409
26590755866
101906908675
078117340400

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

79178479725984
1371463017984
2320515192731
46334231772248
1817799865883
25291977108591
25984091604926

The optimal value equals 117.