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:

48692701467318
6729895173512825
8493208794803639
915366846463719
7511663473539765
612335314387635
554411948574760
9493415975476695

Subtract row minima

We subtract the row minimum from each row:

18389671164015(-3)
4246426482630(-25)
647306774601619(-20)
06275937372810(-9)
640552362428654(-11)
571931270347231(-4)
48374877804053(-7)
53520183462554(-41)

Subtract column minima

We subtract the column minimum from each column:

18389491164015
424648482630
647304974601619
06274137372810
64055562428654
57193190347231
48374697804053
5352003462554
(-18)

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

18389491164015  x
424648482630  x
647304974601619  x
06274137372810  x
64055562428654  x
57193190347231  x
48374697804053  x
5352003462554  x

The optimal assignment

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

18389491164015
424648482630
647304974601619
06274137372810
64055562428654
57193190347231
48374697804053
5352003462554

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

48692701467318
6729895173512825
8493208794803639
915366846463719
7511663473539765
612335314387635
554411948574760
9493415975476695

The optimal value equals 138.