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:

3848294570429928
5781365926781822
3438605352468078
3066634877848298
218264961436053
18230865457116
8811875383388560
949791594462761

Subtract row minima

We subtract the row minimum from each row:

10201174214710(-28)
3963184186004(-18)
04261918124644(-34)
036331847545268(-30)
127355052345144(-9)
08129855356015(-1)
770764272277449(-11)
04070685371852(-9)

Subtract column minima

We subtract the column minimum from each column:

1020017342710
3963174104804
0425191004644
036321839425268
127354044225144
08128854544015
770754264157449
04069677251852
(-1)(-8)(-12)

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

1020017342710  x
3963174104804  x
0425191004644  x
036321839425268
127354044225144  x
08128854544015  x
770754264157449  x
04069677251852
x

Create additional zeros

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

1620017342710
4563174104804
6425191004644
030261233364662
187354044225144
68128854544015
830754264157449
03463071191246

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

1620017342710  x
4563174104804  x
6425191004644  x
030261233364662
187354044225144
68128854544015  x
830754264157449  x
03463071191246
xx

Create additional zeros

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

2820029342710
5763175304804
18425311004644
018141221243450
186142032103932
188128974544015
950755464157449
022510597034

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

2820029342710  x
5763175304804  x
18425311004644  x
018141221243450
186142032103932
188128974544015
950755464157449  x
022510597034
xxx

Create additional zeros

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

3520036342780
6463176004874
25425381005344
01171214173443
18543502533925
18742197383708
1020756164158149
015440520027

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

3520036342780  x
6463176004874  x
25425381005344
01171214173443
18543502533925
18742197383708
1020756164158149  x
015440520027
xxxx

Create additional zeros

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

3920040346820
68631764052114
2502138605340
0731210173439
18503102133921
18701797343704
1060756564198549
011400480023

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

3920040346820  x
68631764052114  x
2502138605340
0731210173439
18503102133921
18701797343704
1060756564198549
011400480023
xxxxx

Create additional zeros

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

4223043349850
71661767055144
2501838305337
070127173436
18502801833918
18701497313701
1060726561198546
011370450020

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

4223043349850  x
71661767055144  x
2501838305337  x
070127173436  x
18502801833918  x
18701497313701  x
1060726561198546  x
011370450020  x

The optimal assignment

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

4223043349850
71661767055144
2501838305337
070127173436
18502801833918
18701497313701
1060726561198546
011370450020

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

3848294570429928
5781365926781822
3438605352468078
3066634877848298
218264961436053
18230865457116
8811875383388560
949791594462761

The optimal value equals 193.