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:

54712496279
32358285640
376241326783
51056249719
12225593390
534694951465

Subtract row minima

We subtract the row minimum from each row:

52692294077(-2)
24270204832(-8)
530903551(-32)
0551199214(-5)
02124583289(-1)
39328081051(-14)

Subtract column minima

We subtract the column minimum from each column:

52642294063
24220204818
525903537
005119920
01624583275
39278081037
(-5)(-14)

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

52642294063
24220204818  x
525903537  x
005119920  x
01624583275  x
39278081037
x

Create additional zeros

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

3042072041
24220207018
525905737
0051191140
01624585475
1755859015

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

3042072041
24220207018
525905737  x
0051191140  x
01624585475  x
1755859015
xx

Create additional zeros

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

2537067036
19170157013
5251406237
0056191190
01629585975
1205854010

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

2537067036  x
19170157013  x
5251406237  x
0056191190  x
01629585975  x
1205854010  x

The optimal assignment

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

2537067036
19170157013
5251406237
0056191190
01629585975
1205854010

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

54712496279
32358285640
376241326783
51056249719
12225593390
534694951465

The optimal value equals 108.