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:

853589627059
957822671164
267568738498
7258868027
943557428746
68513626252

Subtract row minima

We subtract the row minimum from each row:

50054273524(-35)
84671156053(-11)
04942475872(-26)
0181797320(-7)
5902275211(-35)
0797565646(-6)

Subtract column minima

We subtract the column minimum from each column:

50053203513
84671049042
04941405861
018072739
590210520
0796495635
(-1)(-7)(-11)

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

50053203513  x
84671049042  x
04941405861
018072739  x
590210520  x
0796495635
x

Create additional zeros

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

56053203513
90671049042
04335345255
618072739
650210520
0730435029

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

56053203513  x
90671049042  x
04335345255
618072739
650210520  x
0730435029
xx

Create additional zeros

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

65062203513
99671949042
03435254346
69063640
740300520
0640344120

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

65062203513  x
99671949042  x
03435254346  x
69063640  x
740300520  x
0640344120  x

The optimal assignment

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

65062203513
99671949042
03435254346
69063640
740300520
0640344120

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

853589627059
957822671164
267568738498
7258868027
943557428746
68513626252

The optimal value equals 154.