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:

20617224502281637720
8244151129554594989
2887563689770327032
903778288418292501
29965292797588197
84713234642957341562
7643239117912477812
37886871812357736
92463784722185553314
3091118412755849258

Subtract row minima

We subtract the row minimum from each row:

0415243026143570(-20)
73356220463685080(-9)
2180492982063256325(-7)
893677278317191490(-1)
27943270595567995(-2)
6956171949144219047(-15)
7542229007811467711(-1)
36876770701347635(-1)
783223705877141190(-14)
228330331947768450(-8)

Subtract column minima

We subtract the column minimum from each column:

094943026024570
7333220463566080
214846298206266325
89474278317072490
27620270594377995
692414194914410047
7510199007810277711
36556470700157635
78020705877022190
225100331946578450
(-32)(-3)(-1)(-19)

Cover all zeros with a minimum number of lines

There are 10 lines required to cover all zeros:

094943026024570  x
7333220463566080  x
214846298206266325  x
89474278317072490  x
27620270594377995  x
692414194914410047  x
7510199007810277711  x
36556470700157635  x
78020705877022190  x
225100331946578450  x

The optimal assignment

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

094943026024570
7333220463566080
214846298206266325
89474278317072490
27620270594377995
692414194914410047
7510199007810277711
36556470700157635
78020705877022190
225100331946578450

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

20617224502281637720
8244151129554594989
2887563689770327032
903778288418292501
29965292797588197
84713234642957341562
7643239117912477812
37886871812357736
92463784722185553314
3091118412755849258

The optimal value equals 133.