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:

40857482465150
7287977063907
7983869415531
877148984191
1545746996821
7098188223865
84163255546624

Subtract row minima

We subtract the row minimum from each row:

045344261110(-40)
6580906356830(-7)
7074770324622(-9)
836704943787(-4)
939680936215(-6)
6593137718810(-5)
680163938508(-16)

Subtract column minima

We subtract the column minimum from each column:

04534420010
6580906350720
7074770263522
836704882687
939680875115
6593137712700
680163932398
(-6)(-11)

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

04534420010  x
6580906350720
7074770263522
836704882687  x
939680875115
6593137712700
680163932398  x
xx

Create additional zeros

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

04534510019
5671816341630
6165680172622
8367013882696
030590784215
56844773610
6801648323917

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

04534510019  x
5671816341630
6165680172622  x
8367013882696  x
030590784215  x
56844773610
6801648323917  x
x

Create additional zeros

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

04534510022
5368786038600
6165680172625
8367013882699
030590784218
53811740580
6801648323920

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

04534510022  x
5368786038600  x
6165680172625  x
8367013882699  x
030590784218  x
53811740580  x
6801648323920  x

The optimal assignment

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

04534510022
5368786038600
6165680172625
8367013882699
030590784218
53811740580
6801648323920

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

40857482465150
7287977063907
7983869415531
877148984191
1545746996821
7098188223865
84163255546624

The optimal value equals 125.