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.

24809757453643341077
2512238335651788960
8146043228337896160
66686910806716788735
3420778624631574012
404663947892719552
14341824552521398667
83104055897477841648
4353192438859215772
89173736909855705089

Subtract row minima

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

1470874735263324067(-10)
2411228234640778859(-1)
7705639187933855756(-4)
565859070576687725(-10)
27137079175680335(-7)
384443745872517530(-2)
02041041117257253(-14)
730304579646774638(-10)
0312788398455175368(-4)
7202019738138533372(-17)

Subtract column minima

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

1470834718153324067
2411188217530778859
770523916833855756
565855053466687725
2713667904580335
384403728762517530
0200102407257253
730264562536774638
0312388227355175368
7201619567038533372
(-4)(-17)(-11)

Cover all zeros with a minimum number of lines

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

1470834718153324067x
2411188217530778859x
770523916833855756
565855053466687725x
2713667904580335x
384403728762517530x
0200102407257253x
730264562536774638
0312388227355175368x
7201619567038533372
x

Create additional zeros

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

1471834718153324067
2412188217530778859
760513806732845655
565955053466687725
2714667904580335
384503728762517530
0210102407257253
720254461526673537
0322388227355175368
7101518556937523271

Cover all zeros with a minimum number of lines

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

1471834718153324067x
2412188217530778859x
760513806732845655x
565955053466687725x
2714667904580335x
384503728762517530x
0210102407257253x
720254461526673537
0322388227355175368x
7101518556937523271
x

Create additional zeros

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

1476834718153324067
2417188217530778859
765513806732845655
566455053466687725
2719667904580335
385003728762517530
0260102407257253
670203956476168032
0372388227355175368
6601013506432472766

Cover all zeros with a minimum number of lines

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

1476834718153324067
2417188217530778859x
765513806732845655x
566455053466687725x
2719667904580335x
385003728762517530x
0260102407257253x
670203956476168032
0372388227355175368x
6601013506432472766
xx

Create additional zeros

The number of lines is smaller than 10. The smallest uncovered element is 10. We subtract this value from all uncovered elements and add it to all elements covered twice.

4767337852314057
2427188217530779859
7615513806732846655
567455053466688725
2729667904580435
386003728762517630
0360102407258253
570102946375158022
0472388227355176368
56003405422372756

Cover all zeros with a minimum number of lines

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

4767337852314057x
2427188217530779859x
7615513806732846655x
567455053466688725x
2729667904580435x
386003728762517630x
0360102407258253x
570102946375158022x
0472388227355176368x
56003405422372756x

The optimal assignment

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

4767337852314057
2427188217530779859
7615513806732846655
567455053466688725
2729667904580435
386003728762517630
0360102407258253
570102946375158022
0472388227355176368
56003405422372756

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

24809757453643341077
2512238335651788960
8146043228337896160
66686910806716788735
3420778624631574012
404663947892719552
14341824552521398667
83104055897477841648
4353192438859215772
89173736909855705089

The total minimum cost is 128.


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