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:

169194431283
8769696763730
733440357871
6603576897029
66819833298783
43213974841241
395872693686

Subtract row minima

We subtract the row minimum from each row:

159093420182(-1)
8163636103124(-6)
700137327568(-3)
0542970836423(-6)
375269405854(-29)
319276272029(-12)
325101922979(-7)

Subtract column minima

We subtract the column minimum from each column:

159093380159
816363570311
700133327545
054296683640
375269005831
31927587206
325101522956
(-4)(-23)

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

159093380159
816363570311
700133327545  x
054296683640  x
375269005831  x
31927587206  x
325101522956  x
x

Create additional zeros

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

148992370058
806262560300
700133337545
054296684640
375269015831
31927587306
325101532956

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

148992370058  x
806262560300  x
700133337545  x
054296684640  x
375269015831  x
31927587306  x
325101532956  x

The optimal assignment

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

148992370058
806262560300
700133337545
054296684640
375269015831
31927587306
325101532956

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

169194431283
8769696763730
733440357871
6603576897029
66819833298783
43213974841241
395872693686

The optimal value equals 92.