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:

7582544886454398
958246815538011
9813242259976084
74566419780603
493082965968261
9769569188956998
2128435613188874
6599221727524866

Subtract row minima

We subtract the row minimum from each row:

3239115432055(-43)
8774380745723(-8)
85011946844771(-13)
71533389477570(-3)
482981955867250(-1)
411303532391342(-56)
8153043057561(-13)
48825010353149(-17)

Subtract column minima

We subtract the column minimum from each column:

2439115430055
7974380743723
77011946824771
63533389475570
402981955865250
331303532371342
0153043037561
40825010333149
(-8)(-2)

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

2439115430055  x
7974380743723
77011946824771  x
63533389475570
402981955865250
331303532371342  x
0153043037561  x
40825010333149
xx

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:

2439118430058
7671350440693
770111246824774
60500389172540
372678955562220
331303832371345
0153046037564
3779207302849

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

2439118430058  x
7671350440693
770111246824774  x
60500389172540
372678955562220
331303832371345
0153046037564  x
3779207302849
xxx

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:

24391512430062
7267350036653
770151646824778
56460388768500
332278955158180
2990382833945
0153450037568
3375203262449

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

24391512430062  x
7267350036653  x
770151646824778  x
56460388768500
332278955158180
2990382833945
0153450037568  x
3375203262449  x
xx

Create additional zeros

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

24392412430071
72674400366512
770241646824787
47370297859410
24137886424990
2000291924045
0154350037577
33751103262458

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

24392412430071  x
72674400366512  x
770241646824787  x
47370297859410  x
24137886424990  x
2000291924045  x
0154350037577  x
33751103262458  x

The optimal assignment

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

24392412430071
72674400366512
770241646824787
47370297859410
24137886424990
2000291924045
0154350037577
33751103262458

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

7582544886454398
958246815538011
9813242259976084
74566419780603
493082965968261
9769569188956998
2128435613188874
6599221727524866

The optimal value equals 187.