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:

526862671
1415967977
1585939350
5079354846
5832355580

Subtract row minima

We subtract the row minimum from each row:

466202065(-6)
01826563(-14)
070787835(-15)
154401311(-35)
26032348(-32)

Subtract column minima

We subtract the column minimum from each column:

46620754
01825252
070786524
1544000
26031037
(-13)(-11)

Cover all zeros with a minimum number of lines

There are 4 lines required to cover all zeros:

46620754  x
01825252
070786524
1544000  x
26031037  x
x

Create additional zeros

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

47620754
00815151
069776423
1644000
27031037

Cover all zeros with a minimum number of lines

There are 4 lines required to cover all zeros:

47620754  x
00815151
069776423
1644000  x
27031037
xx

Create additional zeros

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

50650754
00784848
069746120
1947000
2700734

Cover all zeros with a minimum number of lines

There are 4 lines required to cover all zeros:

50650754
00784848
069746120
1947000  x
2700734
xxx

Create additional zeros

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

50650047
00784141
069745413
2654700
2700027

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

50650047  x
00784141  x
069745413  x
2654700  x
2700027  x

The optimal assignment

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

50650047
00784141
069745413
2654700
2700027

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

526862671
1415967977
1585939350
5079354846
5832355580

The optimal value equals 137.