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:

15844801028
821846584996
865287885098
42759597218
82105436339
31339489036

Subtract row minima

We subtract the row minimum from each row:

703672220(-8)
64028403178(-18)
3623738048(-50)
40739395016(-2)
7975106036(-3)
28036458733(-3)

Subtract column minima

We subtract the column minimum from each column:

0087224
5700403162
292938032
3373659500
7272306020
2108458717
(-7)(-28)(-16)

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

0087224  x
5700403162  x
292938032  x
3373659500  x
7272306020  x
2108458717  x

The optimal assignment

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

0087224
5700403162
292938032
3373659500
7272306020
2108458717

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

15844801028
821846584996
865287885098
42759597218
82105436339
31339489036

The optimal value equals 135.