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:

92664154292124219
3753449457338757
791936591252889787
70191159453752234
9987834546199185
958636661524807155
58965879763425248
74363494882122326
297856913117348772

Subtract row minima

We subtract the row minimum from each row:

860589368663613(-6)
3349405053298353(-4)
6772447040768575(-12)
6514654403201729(-5)
9179026465318377(-8)
8071215109655640(-15)
08460829258374743(-5)
71333191851819023(-3)
12613974140177055(-17)

Subtract column minima

We subtract the column minimum from each column:

86058436866360
3349400053298340
6772442040768562
6514649403201716
9179021465318364
8071214609655627
08460779258374730
71333186851819010
12613969140177042
(-5)(-13)

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

86058436866360  x
3349400053298340  x
6772442040768562
6514649403201716  x
9179021465318364  x
8071214609655627
08460779258374730  x
71333186851819010  x
12613969140177042  x
x

Create additional zeros

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

86058443866360
3349400753298340
6001735033697855
6514649473201716
9179021535318364
7364143902584920
08460779958374730
71333186921819010
12613969210177042

Cover all zeros with a minimum number of lines

There are 9 lines required to cover all zeros:

86058443866360  x
3349400753298340  x
6001735033697855  x
6514649473201716  x
9179021535318364  x
7364143902584920  x
08460779958374730  x
71333186921819010  x
12613969210177042  x

The optimal assignment

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

86058443866360
3349400753298340
6001735033697855
6514649473201716
9179021535318364
7364143902584920
08460779958374730
71333186921819010
12613969210177042

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

92664154292124219
3753449457338757
791936591252889787
70191159453752234
9987834546199185
958636661524807155
58965879763425248
74363494882122326
297856913117348772

The optimal value equals 100.