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:

249871506360
202847298048
992289255085
539736591725
493195147497
218791835982

Subtract row minima

We subtract the row minimum from each row:

07447263936(-24)
082796028(-20)
7706732863(-22)
3680194208(-17)
35178106083(-14)
06670623861(-21)

Subtract column minima

We subtract the column minimum from each column:

07428263928
08896020
7704832855
368004200
35176206075
06651623853
(-19)(-8)

Cover all zeros with a minimum number of lines

There are 4 lines required to cover all zeros:

07428263928
08896020
7704832855  x
368004200  x
35176206075  x
06651623853
x

Create additional zeros

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

06620183120
00015212
8504832855
448004200
43176206075
05843543045

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

06620183120
00015212  x
8504832855  x
448004200  x
43176206075  x
05843543045
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:

04820132
180015212
10304832855
628004200
61176206075
04025361227

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

04820132
180015212  x
10304832855  x
628004200  x
61176206075
04025361227
xx

Create additional zeros

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

04600110
200035212
10504852855
648004400
61156005873
03823361025

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

04600110  x
200035212  x
10504852855  x
648004400  x
61156005873  x
03823361025  x

The optimal assignment

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

04600110
200035212
10504852855
648004400
61156005873
03823361025

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

249871506360
202847298048
992289255085
539736591725
493195147497
218791835982

The optimal value equals 181.