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:

2321745592745106335
654288668093035147
796175415883863352
16958398115748399374
66476295709887685768
24718639534797757523
84879715248846126855
6329158841446948223
2883213731761756817
9748772570275323742

Subtract row minima

We subtract the row minimum from each row:

210154357254386133(-2)
623985637762704844(-3)
765872382850833049(-3)
584728704637288263(-11)
1901548235140211021(-47)
148631630247452520(-23)
727585312763405643(-12)
6026128538416645190(-3)
2176143024691049740(-7)
9546752368255103540(-2)

Subtract column minima

We subtract the column minimum from each column:

20034057194385133
613973607702703844
755860352790832049
484608404037287263
18034523454021021
048511330187452420
717573012703404643
59260823835664590
207622724631049640
9446632068195102540
(-1)(-12)(-3)(-6)(-10)

Cover all zeros with a minimum number of lines

There are 10 lines required to cover all zeros:

20034057194385133  x
613973607702703844  x
755860352790832049  x
484608404037287263  x
18034523454021021  x
048511330187452420  x
717573012703404643  x
59260823835664590  x
207622724631049640  x
9446632068195102540  x

The optimal assignment

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

20034057194385133
613973607702703844
755860352790832049
484608404037287263
18034523454021021
048511330187452420
717573012703404643
59260823835664590
207622724631049640
9446632068195102540

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

2321745592745106335
654288668093035147
796175415883863352
16958398115748399374
66476295709887685768
24718639534797757523
84879715248846126855
6329158841446948223
2883213731761756817
9748772570275323742

The optimal value equals 145.