Logo HungarianAlgorithm.com

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



Solution

This is the cost matrix.

515271594412619180
858387264448356920
274648969578305298
45228822648831949
472370971857732277
226644573728789172
53293181371113757
5484642828272794
77519981128589918

Subtract row minima

For each row, the minimum element is subtracted from all elements in that row.

39405947320497968(-12)
6563676242815490(-20)
0192169685132571(-27)
39168216042771343(-6)
295527903955459(-18)
0442235156566950(-22)
5109116116993555(-2)
4878036222212188(-6)
6943910320509110(-8)

Subtract column minima

For each column, the minimum element is subtracted from all elements in that column.

39405947320467568
6563676242812450
0192169685102171
3916821604274943
295527903952059
0442235156536550
5109116116963155
4878036222181788
6943910320478710
(-3)(-4)

Cover all zeros with a minimum number of lines

A total of 9 lines are required to cover all zeros.

39405947320467568x
6563676242812450x
0192169685102171x
3916821604274943x
295527903952059x
0442235156536550x
5109116116963155x
4878036222181788x
6943910320478710x

The optimal assignment

Because there are 9 lines required, an optimal assignment exists among the zeros.

39405947320467568
6563676242812450
0192169685102171
3916821604274943
295527903952059
0442235156536550
5109116116963155
4878036222181788
6943910320478710

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

515271594412619180
858387264448356920
274648969578305298
45228822648831949
472370971857732277
226644573728789172
53293181371113757
5484642828272794
77519981128589918

The total minimum cost is 128.


HungarianAlgorithm.com © 2026. All rights reserved.
Part of Echion, KvK 50713795, BTW NL001446762B10.