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:

2640995164390
593138304583
79553151857832
75445952244425
14414971355036
206497663973
68707218248571

Subtract row minima

We subtract the row minimum from each row:

173108673481(-9)
562835271550(-3)
482402054471(-31)
512035280201(-24)
0273557213622(-14)
145891057367(-6)
505254066753(-18)

Subtract column minima

We subtract the column minimum from each column:

171108673181
56835271520
48402054441
51035280171
073557213322
143891057067
503254066453
(-20)(-3)

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

171108673181
56835271520  x
48402054441
51035280171  x
073557213322  x
143891057067  x
503254066453  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:

161008563080
56836271520
47301953430
51036280171
073657213322
143892057067
503255066453

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

161008563080
56836271520
47301953430
51036280171  x
073657213322  x
143892057067  x
503255066453  x
xx

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:

15908452980
55736260510
46201852420
51037280172
073757213323
143893057068
503256066454

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

15908452980  x
55736260510  x
46201852420  x
51037280172  x
073757213323  x
143893057068  x
503256066454  x

The optimal assignment

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

15908452980
55736260510
46201852420
51037280172
073757213323
143893057068
503256066454

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

2640995164390
593138304583
79553151857832
75445952244425
14414971355036
206497663973
68707218248571

The optimal value equals 130.