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:

584392986
845135266372
2434872291
79839128043
30184731533
196499434013

Subtract row minima

We subtract the row minimum from each row:

551089953(-3)
5825903746(-26)
0232852089(-2)
0913257336(-7)
29083721432(-1)
6518630270(-13)

Subtract column minima

We subtract the column minimum from each column:

551089813
5825902346
023285689
0913255936
2908372032
6518630130
(-14)

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

551089813  x
5825902346  x
023285689
0913255936
2908372032  x
6518630130  x
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:

571089813
6025902346
003083487
0893035734
3108372032
8518630130

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

571089813  x
6025902346  x
003083487  x
0893035734  x
3108372032  x
8518630130  x

The optimal assignment

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

571089813
6025902346
003083487
0893035734
3108372032
8518630130

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

584392986
845135266372
2434872291
79839128043
30184731533
196499434013

The optimal value equals 68.