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:

144139936
2692514491
52364542
661218625
6933809495

Subtract row minima

We subtract the row minimum from each row:

10099532(-4)
066251865(-26)
50162520(-2)
650208524(-1)
360476162(-33)

Subtract column minima

We subtract the column minimum from each column:

10007732
06616065
50153340
650116724
360384362
(-9)(-18)

Cover all zeros with a minimum number of lines

There are 4 lines required to cover all zeros:

10007732  x
06616065  x
50153340  x
650116724
360384362
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:

101107732
07716065
501253340
54005613
250273251

Cover all zeros with a minimum number of lines

There are 4 lines required to cover all zeros:

101107732
07716065  x
501253340  x
54005613
250273251
xx

Create additional zeros

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

01106722
08726065
502263340
4400463
150272241

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

01106722  x
08726065  x
502263340  x
4400463  x
150272241  x

The optimal assignment

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

01106722
08726065
502263340
4400463
150272241

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

144139936
2692514491
52364542
661218625
6933809495

The optimal value equals 114.