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:

3687845151
1634193669
451043648
539365679
712604760

Subtract row minima

We subtract the row minimum from each row:

051481515(-36)
01832053(-16)
39437042(-6)
034315174(-5)
05534053(-7)

Subtract column minima

We subtract the column minimum from each column:

04745150
01402038
39034027
030285159
01504038
(-4)(-3)(-15)

Cover all zeros with a minimum number of lines

There are 4 lines required to cover all zeros:

04745150  x
01402038  x
39034027  x
030285159
01504038
x

Create additional zeros

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

14745150
11402038
40034027
029275058
00493937

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

14745150  x
11402038  x
40034027  x
029275058  x
00493937  x

The optimal assignment

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

14745150
11402038
40034027
029275058
00493937

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

3687845151
1634193669
451043648
539365679
712604760

The optimal value equals 93.