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:

471812307155933378
24933557809739482
438183715892263651
143951962160887244
7095462944878914
78862772538715343
53969451538239372
202887119352131592
17986164339298725

Subtract row minima

We subtract the row minimum from each row:

3560185943812166(-12)
20893153769335078(-4)
17555745326601025(-26)
0253782746745830(-14)
6893440924676712(-2)
77852671528605242(-1)
45888643450158564(-8)
91776082412481(-11)
11925503733238119(-6)

Subtract column minima

We subtract the column minimum from each column:

3500185243812154
20833153699335066
17495745256601013
0193782046745818
688744085467670
77792671458605230
45828643380158552
91176075412469
1186550303323817
(-6)(-7)(-12)

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

3500185243812154  x
20833153699335066  x
17495745256601013
0193782046745818  x
688744085467670  x
77792671458605230
45828643380158552  x
91176075412469
1186550303323817
xx

Create additional zeros

The number of lines is smaller than 9. The smallest uncovered number is 4. We subtract this number from all uncovered elements and add it to all elements that are covered twice:

3500225243852154
20833157699339066
134553452162069
0193786046785818
688744485468070
73752271418204826
45828647380198552
5772071372065
782510262923773

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

3500225243852154  x
20833157699339066
134553452162069
0193786046785818  x
688744485468070  x
73752271418204826
45828647380198552  x
5772071372065
782510262923773
xxx

Create additional zeros

The number of lines is smaller than 9. The smallest uncovered number is 3. We subtract this number from all uncovered elements and add it to all elements that are covered twice:

3500255243882454
17802857669039063
104250451859066
0193789046816118
6887447854683100
70721971387904823
45828650380228852
2469068342062
479480232623770

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

3500255243882454  x
17802857669039063
104250451859066
0193789046816118  x
6887447854683100
70721971387904823
45828650380228852  x
2469068342062
479480232623770
xxxx

Create additional zeros

The number of lines is smaller than 9. The smallest uncovered number is 2. We subtract this number from all uncovered elements and add it to all elements that are covered twice:

3500275243902656
15782657648839063
84048451657066
0193791046836320
6685427834483100
68701771367704823
45828652380249054
0267066322062
277460212423770

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

3500275243902656  x
15782657648839063  x
84048451657066
0193791046836320  x
6685427834483100  x
68701771367704823
45828652380249054  x
0267066322062  x
277460212423770  x
x

Create additional zeros

The number of lines is smaller than 9. The smallest uncovered number is 6. We subtract this number from all uncovered elements and add it to all elements that are covered twice:

3500275243962656
15782657648845063
23442391051000
0193791046896320
6685427834489100
62641165307104217
45828652380309054
0267066328062
277460212429770

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

3500275243962656  x
15782657648845063
23442391051000
0193791046896320  x
6685427834489100
62641165307104217
45828652380309054  x
0267066328062  x
277460212429770  x
xxx

Create additional zeros

The number of lines is smaller than 9. The smallest uncovered number is 2. We subtract this number from all uncovered elements and add it to all elements that are covered twice:

3500275243982858
13762455628645063
0324037849000
0193791046916522
6483405814289100
6062963286904217
45828652380329256
02670663210264
277460212431792

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

3500275243982858  x
13762455628645063
0324037849000
0193791046916522  x
6483405814289100
6062963286904217
45828652380329256  x
02670663210264
277460212431792
xxxxx

Create additional zeros

The number of lines is smaller than 9. The smallest uncovered number is 2. We subtract this number from all uncovered elements and add it to all elements that are covered twice:

37002952431003060
13742255608445063
0303837647000
2193793046936724
6481385794089100
6060763266704217
47828654380349458
00650643010264
275440192231792

Cover all zeros with a minimum number of lines

There are 9 lines required to cover all zeros:

37002952431003060  x
13742255608445063  x
0303837647000  x
2193793046936724  x
6481385794089100  x
6060763266704217  x
47828654380349458  x
00650643010264  x
275440192231792  x

The optimal assignment

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

37002952431003060
13742255608445063
0303837647000
2193793046936724
6481385794089100
6060763266704217
47828654380349458
00650643010264
275440192231792

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

471812307155933378
24933557809739482
438183715892263651
143951962160887244
7095462944878914
78862772538715343
53969451538239372
202887119352131592
17986164339298725

The optimal value equals 137.