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:

97851824
85711724
2485030
1184834

Subtract row minima

We subtract the row minimum from each row:

796706(-18)
685407(-17)
1604222(-8)
376026(-8)

Subtract column minima

We subtract the column minimum from each column:

766700
655401
1304216
076020
(-3)(-6)

Cover all zeros with a minimum number of lines

There are 4 lines required to cover all zeros:

766700  x
655401  x
1304216  x
076020  x

The optimal assignment

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

766700
655401
1304216
076020

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

97851824
85711724
2485030
1184834

The optimal value equals 60.