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:

97655146837619456723
9689961478418637345
65539317601036744742
58858470441383123331
22597819093142510
3831462558536046917
4390622957929502748
91363284339613678425
5398464791536788569
906482734040682252

Subtract row minima

We subtract the row minimum from each row:

784632276457026484(-19)
8809153397610556537(-8)
554383750026643732(-10)
467372583217102119(-12)
2149680899203249(-1)
3124391851465339840(-7)
3481532048020411839(-9)
7823197120830547112(-13)
4893414286031738064(-5)
886280713838662030(-2)

Subtract column minima

We subtract the column minimum from each column:

574613204457026454
6707246197610556237
344364030026643432
257353511217101819
047773699203219
1024201131465339810
1381341328020411539
57230640830546812
2793223566031737764
676261641838662000
(-21)(-19)(-7)(-20)(-3)

Cover all zeros with a minimum number of lines

There are 9 lines required to cover all zeros:

574613204457026454  x
6707246197610556237  x
344364030026643432  x
257353511217101819  x
047773699203219  x
1024201131465339810  x
1381341328020411539
57230640830546812  x
2793223566031737764
676261641838662000  x
x

Create additional zeros

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

574613204470026454
6707246198910556237
3443640301326643432
2573535112147101819
0477736910503219
1024201131595339810
068210150728226
57230640960546812
148092253018606451
676261641851662000

Cover all zeros with a minimum number of lines

There are 9 lines required to cover all zeros:

574613204470026454
6707246198910556237  x
3443640301326643432
2573535112147101819  x
0477736910503219
1024201131595339810  x
068210150728226
57230640960546812  x
148092253018606451
676261641851662000  x
xxxx

Create additional zeros

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

574411204270024432
6907248199112556237
3441620281326623230
2773535312167301819
0275736710501197
1224201331615539810
066190130726024
59230660982546812
147872251018586249
696261661853682000

Cover all zeros with a minimum number of lines

There are 9 lines required to cover all zeros:

574411204270024432
6907248199112556237  x
3441620281326623230
2773535312167301819  x
0275736710501197
1224201331615539810
066190130726024
59230660982546812  x
147872251018586249
696261661853682000
xxxxxx

Create additional zeros

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

574310204170023432
7007249199213556338
3440610271326613230
2873535412177401920
0174736610500197
1223191330615538810
065180120725024
60230670993546913
147762250018576249
696160661753681900

Cover all zeros with a minimum number of lines

There are 9 lines required to cover all zeros:

574310204170023432
7007249199213556338  x
3440610271326613230
2873535412177401920
0174736610500197
1223191330615538810
065180120725024
60230670993546913  x
147762250018576249
696160661753681900
xxxxxxx

Create additional zeros

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

57429204070023432
7107250199314566439
3439600261326613230
2872525411177401920
0073736510500197
1222181329615538810
064170110725024
612306801004557014
147652249018576249
696059661653681900

Cover all zeros with a minimum number of lines

There are 9 lines required to cover all zeros:

57429204070023432
7107250199314566439
3439600261326613230
2872525411177401920
0073736510500197
1222181329615538810
064170110725024
612306801004557014  x
147652249018576249
696059661653681900
xxxxxxxx

Create additional zeros

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

57424203570023432
7106750149314566439
3439550211326613230
287247546177401920
0068736010500197
1222131324615538810
06412060725024
662807301059607519
147602244018576249
696054661153681900

Cover all zeros with a minimum number of lines

There are 10 lines required to cover all zeros:

57424203570023432  x
7106750149314566439  x
3439550211326613230  x
287247546177401920  x
0068736010500197  x
1222131324615538810  x
06412060725024  x
662807301059607519  x
147602244018576249  x
696054661153681900  x

The optimal assignment

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

57424203570023432
7106750149314566439
3439550211326613230
287247546177401920
0068736010500197
1222131324615538810
06412060725024
662807301059607519
147602244018576249
696054661153681900

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

97655146837619456723
9689961478418637345
65539317601036744742
58858470441383123331
22597819093142510
3831462558536046917
4390622957929502748
91363284339613678425
5398464791536788569
906482734040682252

The optimal value equals 178.