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.

2904730709329833234
5252758927297412167
1398287093668323896
1361957241435431310
7189989694815691967
521951310518932358
1160695748572944424
2574623767959584944
952728215668351498
43332617486980522618

Subtract row minima

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

0884528689127813032(-2)
4545688220220341460(-7)
489196102759232987(-9)
452048155263441(-9)
011928262418621260(-7)
4714085468427303(-5)
756655308168904020(-4)
2170583363919180900(-4)
922425185365048195(-3)
2616903152633591(-17)

Subtract column minima

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

0774528688627582932
4534688220170111360
47819610225902887
441048150261131
00928262368391160
47308541844293
745655307668673920
2159583363869157890
921325185360025095
265903147631281
(-11)(-5)(-23)(-1)

Cover all zeros with a minimum number of lines

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

0774528688627582932x
4534688220170111360x
47819610225902887x
441048150261131x
00928262368391160x
47308541844293x
745655307668673920x
2159583363869157890x
921325185360025095x
265903147631281x

The optimal assignment

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

0774528688627582932
4534688220170111360
47819610225902887
441048150261131
00928262368391160
47308541844293
745655307668673920
2159583363869157890
921325185360025095
265903147631281

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

2904730709329833234
5252758927297412167
1398287093668323896
1361957241435431310
7189989694815691967
521951310518932358
1160695748572944424
2574623767959584944
952728215668351498
43332617486980522618

The total minimum cost is 107.


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