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:

3386475977141
23328085812414
8983163357747
9791872639727
98416333369
4512455161044
38892353342566

Subtract row minima

We subtract the row minimum from each row:

0356172946838(-3)
918667167100(-14)
8680130327444(-3)
9589850619525(-2)
37810272703(-6)
41805112640(-4)
156603011243(-23)

Subtract column minima

We subtract the column minimum from each column:

0276172836838
910667156100
8672130217444
9581850509525
37010271603
4100511640
15580300243
(-8)(-11)

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

0276172836838  x
910667156100  x
8672130217444
9581850509525
37010271603  x
4100511640  x
15580300243  x
x

Create additional zeros

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

0276185836838
910668456100
73590086131
8268720378212
37010401603
4100641640
15580430243

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

0276185836838  x
910668456100  x
73590086131  x
8268720378212  x
37010401603  x
4100641640  x
15580430243  x

The optimal assignment

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

0276185836838
910668456100
73590086131
8268720378212
37010401603
4100641640
15580430243

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

3386475977141
23328085812414
8983163357747
9791872639727
98416333369
4512455161044
38892353342566

The optimal value equals 87.