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.

919255443536
616777207342
56577478937665
1484241433435
97716720248771
9146510721189
3180149915830

Subtract row minima

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

888952410503(-3)
586474174039(-3)
01182237209(-56)
97919928380(-5)
775147046751(-20)
87061668785(-4)
3079139805729(-1)

Subtract column minima

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

888939410503
586461174039
0152237209
9796928380
775134046751
87048668785
307909805729
(-13)

Cover all zeros with a minimum number of lines

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

888939410503x
586461174039x
0152237209x
9796928380x
775134046751x
87048668785x
307909805729x

The optimal assignment

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

888939410503
586461174039
0152237209
9796928380
775134046751
87048668785
307909805729

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

919255443536
616777207342
56577478937665
1484241433435
97716720248771
9146510721189
3180149915830

The total minimum cost is 105.


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