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:

2759606570443477
3645562744467665
262326020969422
7776796679777937
954832766287394
4087632930838465
2513671210487285
5551484330821992

Subtract row minima

We subtract the row minimum from each row:

03233384317750(-27)
91829017194938(-27)
242105818949220(-2)
403942294240420(-37)
910792362246990(-4)
11583401545536(-29)
1535720386275(-10)
363229241163073(-19)

Subtract column minima

We subtract the column minimum from each column:

0323338430750
9182901724938
242105818779220
403942294223420
91079236276990
11583401375536
1535720216275
363229241146073
(-17)

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

0323338430750  x
9182901724938
242105818779220  x
403942294223420  x
91079236276990  x
11583401375536
1535720216275  x
363229241146073  x
x

Create additional zeros

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

0323339430750
8172801614837
242105918779220
403942304223420
91079246276990
10573300365435
1535730216275
363229251146073

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

0323339430750  x
8172801614837
242105918779220  x
403942304223420  x
91079246276990  x
10573300365435
1535730216275
363229251146073  x
xx

Create additional zeros

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

0323340440750
7162701604736
242106019779220
403942314323420
91079256376990
9563200355334
1425630206174
363229261246073

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

0323340440750  x
7162701604736  x
242106019779220  x
403942314323420  x
91079256376990  x
9563200355334  x
1425630206174  x
363229261246073  x

The optimal assignment

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

0323340440750
7162701604736
242106019779220
403942314323420
91079256376990
9563200355334
1425630206174
363229261246073

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

2759606570443477
3645562744467665
262326020969422
7776796679777937
954832766287394
4087632930838465
2513671210487285
5551484330821992

The optimal value equals 174.