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:

3667354937281
17104985165334
60607849104688
4891822861887
23819334769063
58355153971856
9220373061798

Subtract row minima

We subtract the row minimum from each row:

3263310896877(-4)
70397564324(-10)
5050683903678(-10)
4083014781079(-8)
0587011536740(-23)
4017333579038(-18)
8412292253710(-8)

Subtract column minima

Because each column contains a zero, subtracting column minima has no effect.

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

3263310896877  x
70397564324  x
5050683903678  x
4083014781079  x
0587011536740  x
4017333579038  x
8412292253710  x

The optimal assignment

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

3263310896877
70397564324
5050683903678
4083014781079
0587011536740
4017333579038
8412292253710

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

3667354937281
17104985165334
60607849104688
4891822861887
23819334769063
58355153971856
9220373061798

The optimal value equals 81.