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:

78607445736
34117453694
57914915304
1184779275
76282638255
90306586744

Subtract row minima

We subtract the row minimum from each row:

74567005332(-4)
2856847088(-6)
53874511260(-4)
740738871(-4)
74262436053(-2)
83235879037(-7)

Subtract column minima

We subtract the column minimum from each column:

67527005332
2116847088
46834511260
000738871
67222436053
76195879037
(-7)(-4)

Cover all zeros with a minimum number of lines

There are 4 lines required to cover all zeros:

67527005332  x
2116847088
46834511260  x
000738871  x
67222436053
76195879037
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:

67527005432
2006746087
46834511270
000738971
66212335052
75185778036

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

67527005432  x
2006746087  x
46834511270  x
000738971  x
66212335052
75185778036
x

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:

67527007232
20067461887
46834511450
0007310771
483517034
5703960018

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

67527007232  x
20067461887
46834511450  x
0007310771  x
483517034
5703960018
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:

67577007732
15062411882
46884511500
0507311271
433012029
5203455013

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

67577007732  x
15062411882  x
46884511500  x
0507311271  x
433012029  x
5203455013  x

The optimal assignment

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

67577007732
15062411882
46884511500
0507311271
433012029
5203455013

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

78607445736
34117453694
57914915304
1184779275
76282638255
90306586744

The optimal value equals 63.