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:

777831949489114
7541346684972598
5385529613918543
41199518681625
7954769482325474
831767519847575
217383911452383
5355687963706922

Subtract row minima

We subtract the row minimum from each row:

747501646458811(-3)
50169415972073(-25)
407239830787230(-13)
40098508571524(-1)
472244625002242(-32)
781262014797070(-5)
187080881149080(-3)
313346574148470(-22)

Subtract column minima

We subtract the column minimum from each column:

567501646458811
32169415972073
227239830787230
22098508571524
292244625002242
601262014797070
07080881149080
133346574148470
(-18)

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

567501646458811  x
32169415972073  x
227239830787230  x
22098508571524  x
292244625002242  x
601262014797070  x
07080881149080  x
133346574148470  x

The optimal assignment

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

567501646458811
32169415972073
227239830787230
22098508571524
292244625002242
601262014797070
07080881149080
133346574148470

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

777831949489114
7541346684972598
5385529613918543
41199518681625
7954769482325474
831767519847575
217383911452383
5355687963706922

The optimal value equals 122.