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:

59993612679
377848787524
652249582266
246739302163
336882982416
112151741698

Subtract row minima

We subtract the row minimum from each row:

5393306073(-6)
13542454510(-24)
4302736044(-22)
346189042(-21)
1752668280(-16)
0104063587(-11)

Subtract column minima

We subtract the column minimum from each column:

5393120073
1354648510
430930044
34603042
1752487680
0102257587
(-18)(-6)

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

5393120073  x
1354648510
430930044  x
34603042  x
1752487680
0102257587  x
x

Create additional zeros

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

5393120079
748042450
430930050
34603048
1146427020
0102257593

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

5393120079  x
748042450  x
430930050  x
34603048  x
1146427020  x
0102257593  x

The optimal assignment

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

5393120079
748042450
430930050
34603048
1146427020
0102257593

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

59993612679
377848787524
652249582266
246739302163
336882982416
112151741698

The optimal value equals 130.