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:

5824027324
3519886657
2476202576
6244131375
103679284386
156535799584

Subtract row minima

We subtract the row minimum from each row:

1783623280(-4)
3409785556(-1)
0274182374(-2)
57398820(-5)
02669183376(-10)
05020648069(-15)

Subtract column minima

We subtract the column minimum from each column:

1782815260
3408977356
0266102174
57390000
02661103176
05012567869
(-8)(-8)(-2)

Cover all zeros with a minimum number of lines

There are 4 lines required to cover all zeros:

1782815260  x
3408977356  x
0266102174
57390000  x
02661103176
05012567869
x

Create additional zeros

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

3782815260
3608977356
006481972
59390000
0245982974
04810547667

Cover all zeros with a minimum number of lines

There are 4 lines required to cover all zeros:

3782815260  x
3608977356
006481972
59390000  x
0245982974
04810547667
xx

Create additional zeros

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

6812815260
3608674053
006151669
62420000
0245652671
0487517364

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

6812815260  x
3608674053  x
006151669  x
62420000  x
0245652671
0487517364
x

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:

11812815260
4108674053
506151669
67420000
0195102166
0432466859

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

11812815260  x
4108674053  x
506151669  x
67420000  x
0195102166  x
0432466859  x

The optimal assignment

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

11812815260
4108674053
506151669
67420000
0195102166
0432466859

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

5824027324
3519886657
2476202576
6244131375
103679284386
156535799584

The optimal value equals 70.