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:

406091446364
492253669738
393852189025
154553328121
8096943727
59905835581

Subtract row minima

We subtract the row minimum from each row:

0205142324(-40)
27031447516(-22)
2120340727(-18)
0303817666(-15)
7894923505(-2)
54850785076(-5)

Subtract column minima

We subtract the column minimum from each column:

0205142319
27031447511
2120340722
0303817661
7894923500
54850785071
(-5)

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

0205142319
27031447511  x
2120340722  x
0303817661
7894923500  x
54850785071  x
x

Create additional zeros

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

0195032218
28031447511
2220340722
0293716650
7994923500
55850785071

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

0195032218  x
28031447511  x
2220340722  x
0293716650  x
7994923500  x
55850785071  x

The optimal assignment

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

0195032218
28031447511
2220340722
0293716650
7994923500
55850785071

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

406091446364
492253669738
393852189025
154553328121
8096943727
59905835581

The optimal value equals 108.