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:

94134593769
878646903471
89874881486
44142929940
7081039657
98407780553

Subtract row minima

We subtract the row minimum from each row:

8543684670(-9)
53521256037(-34)
8179400678(-8)
43041919839(-1)
631332580(-7)
95377477520(-3)

Subtract column minima

We subtract the column minimum from each column:

4243384670
1052956037
3879370678
0038919839
201032580
52377177520
(-43)(-3)

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

4243384670
1052956037  x
3879370678  x
0038919839  x
201032580  x
52377177520
x

Create additional zeros

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

3802980630
1052956041
3879370682
0038919843
201032584
48336773480

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

3802980630  x
1052956041  x
3879370682  x
0038919843  x
201032584  x
48336773480  x

The optimal assignment

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

3802980630
1052956041
3879370682
0038919843
201032584
48336773480

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

94134593769
878646903471
89874881486
44142929940
7081039657
98407780553

The optimal value equals 112.