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:

197696742550
63397403261
47172336901
701615668625
460536138
968445924719

Subtract row minima

We subtract the row minimum from each row:

0577755631(-19)
60094372958(-3)
46162235890(-1)
5510517110(-15)
157205835(-3)
77652673280(-19)

Subtract column minima

We subtract the column minimum from each column:

0577755031
60094372358
46162235830
5510516510
157205235
77652673220
(-6)

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

0577755031  x
60094372358  x
46162235830
5510516510  x
157205235  x
77652673220
x

Create additional zeros

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

0577755047
60094372374
300619670
5510516526
157205251
6149105760

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

0577755047  x
60094372374
300619670
5510516526  x
157205251  x
6149105760
xx

Create additional zeros

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

0637755053
54088311774
240013610
5570516532
163205257
554945100

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

0637755053  x
54088311774  x
240013610  x
5570516532  x
163205257  x
554945100  x

The optimal assignment

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

0637755053
54088311774
240013610
5570516532
163205257
554945100

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

197696742550
63397403261
47172336901
701615668625
460536138
968445924719

The optimal value equals 88.