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:

426620119870
84258334519
6423408812
869516868277
98534448446
1453216572

Subtract row minima

We subtract the row minimum from each row:

3155908759(-11)
03450253711(-8)
561532004(-8)
70790706661(-16)
94494008042(-4)
1343106471(-1)

Subtract column minima

We subtract the column minimum from each column:

3151908755
0305025377
561132000
70750706657
94454008038
1303106467
(-4)(-4)

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

3151908755
0305025377  x
561132000  x
70750706657  x
94454008038
1303106467  x
x

Create additional zeros

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

2242007846
0305034377
561132900
70750796657
85363107129
1303196467

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

2242007846
0305034377  x
561132900  x
70750796657
85363107129
1303196467  x
xx

Create additional zeros

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

020005624
0307256377
5611543100
48530794435
6314310497
13053316467

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

020005624
0307256377
5611543100  x
48530794435
6314310497
13053316467  x
xxx

Create additional zeros

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

013004917
0237256300
6311613800
48460793728
637310420
20060386467

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

013004917  x
0237256300  x
6311613800  x
48460793728  x
637310420  x
20060386467  x

The optimal assignment

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

013004917
0237256300
6311613800
48460793728
637310420
20060386467

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

426620119870
84258334519
6423408812
869516868277
98534448446
1453216572

The optimal value equals 94.