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:

802659978340
90813912838537
1936333265298
8606881631231
52328149346380
76798536823673
7718837255350

Subtract row minima

We subtract the row minimum from each row:

772329675037(-3)
7869270717325(-12)
1633300234995(-3)
052607355423(-8)
200491723148(-32)
404349046037(-36)
7213786704845(-5)

Subtract column minima

We subtract the column minimum from each column:

772309675014
786925071732
1633280234972
05258735540
200471723125
404347046014
7213766704822
(-2)(-23)

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

772309675014  x
786925071732
1633280234972
05258735540  x
200471723125  x
404347046014  x
7213766704822  x
x

Create additional zeros

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

772309875014
766723069710
1431260214770
05258755540
200471923125
404347246014
7213766904822

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

772309875014  x
766723069710  x
1431260214770  x
05258755540  x
200471923125  x
404347246014  x
7213766904822  x

The optimal assignment

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

772309875014
766723069710
1431260214770
05258755540
200471923125
404347246014
7213766904822

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

802659978340
90813912838537
1936333265298
8606881631231
52328149346380
76798536823673
7718837255350

The optimal value equals 126.