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:

236163214063735
9540591973429041
1313247132608470
724730458965875
3841522733913953
2876521843705724
1941148127852816
1053295917485

Subtract row minima

We subtract the row minimum from each row:

175557153403129(-6)
762140054237122(-19)
00115819477157(-13)
684326054925471(-4)
11142506641226(-27)
10583402552396(-18)
5270671371142(-14)
720265614452(-3)

Subtract column minima

We subtract the column minimum from each column:

175557152801927
762140048235920
00115813475955
684326048924269
1114250064024
10583401952274
52706777120
720265014330
(-6)(-12)(-2)

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

175557152801927  x
762140048235920
00115813475955  x
684326048924269
1114250064024  x
10583401952274
52706777120  x
720265014330  x
x

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:

175557192801927
721736044195516
00116213475955
643922044883865
1114254064024
6543001548230
52707177120
720305014330

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

175557192801927  x
721736044195516
00116213475955  x
643922044883865
1114254064024  x
6543001548230
52707177120
720305014330
xxx

Create additional zeros

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

175559212801929
701536042175316
00136413475957
623722042863665
1114276064026
4523001346210
32507156900
500304812310

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

175559212801929  x
701536042175316
00136413475957  x
623722042863665
1114276064026  x
4523001346210  x
32507156900  x
500304812310  x
x

Create additional zeros

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

175559362801929
550210272381
00137913475957
47227027712150
11142721064026
45230151346210
32508656900
500454812310

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

175559362801929  x
550210272381  x
00137913475957  x
47227027712150  x
11142721064026  x
45230151346210  x
32508656900  x
500454812310  x

The optimal assignment

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

175559362801929
550210272381
00137913475957
47227027712150
11142721064026
45230151346210
32508656900
500454812310

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

236163214063735
9540591973429041
1313247132608470
724730458965875
3841522733913953
2876521843705724
1941148127852816
1053295917485

The optimal value equals 151.